core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/BuildContextSBSv2.java
branchC3_BUILDER_WORK
changeset 1438 03403c6a4740
parent 1437 8534c28043b9
child 1439 8266d8737e89
equal deleted inserted replaced
1437:8534c28043b9 1438:03403c6a4740
    13 import com.nokia.carbide.cpp.sdk.core.IRVCTToolChainInfo;
    13 import com.nokia.carbide.cpp.sdk.core.IRVCTToolChainInfo;
    14 import com.nokia.carbide.cpp.sdk.core.ISBSv2BuildContext;
    14 import com.nokia.carbide.cpp.sdk.core.ISBSv2BuildContext;
    15 import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext;
    15 import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext;
    16 import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
    16 import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
    17 import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin;
    17 import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin;
       
    18 import com.nokia.cpp.internal.api.utils.core.Check;
    18 
    19 
    19 public class BuildContextSBSv2 implements ISBSv2BuildContext {
    20 public class BuildContextSBSv2 implements ISBSv2BuildContext {
    20 	
    21 	
    21 	private String platform;
    22 	private String platform;
    22 	private String target;
    23 	private String target;
    53 		return configID;
    54 		return configID;
    54 	}
    55 	}
    55 	
    56 	
    56 	@Override
    57 	@Override
    57 	public String getDisplayString() {
    58 	public String getDisplayString() {
    58 		
    59 		Check.checkState(displayString != null);
    59 		
       
    60 		// TODO: Still need to decide on how to set display string
       
    61 		// and how it's used for legacy SBSv2 configs
       
    62 		if (displayString != null){
       
    63 			return displayString;
       
    64 		}
       
    65 		
       
    66 		// TODO: else fallback for old configs, we should convert
       
    67 		String EMULATOR_DISPLAY_TEXT = "Emulator"; //$NON-NLS-1$
       
    68 		String PHONE_DISPLAY_TEXT = "Phone"; //$NON-NLS-1$
       
    69 		String DEBUG_DISPLAY_TEXT = "Debug"; //$NON-NLS-1$
       
    70 		String RELEASE_DISPLAY_TEXT = "Release"; //$NON-NLS-1$
       
    71 		String SPACE_DISPLAY_TEXT = " "; //$NON-NLS-1$
       
    72 		String SDK_NOT_INSTALLED = "SDK not installed"; //$NON-NLS-1$
       
    73 		String displayString = null;
       
    74 		if (displayString == null) {
       
    75 			// in the form Emulation Debug (WINSCW) [S60_3rd_MR] or
       
    76 			// Phone Release (GCCE) [S60_3rd_MR]
       
    77 			if (platform.compareTo(ISymbianBuildContext.EMULATOR_PLATFORM) == 0) {
       
    78 				displayString = EMULATOR_DISPLAY_TEXT;
       
    79 			} else {
       
    80 				displayString = PHONE_DISPLAY_TEXT;
       
    81 			}
       
    82 			
       
    83 			if (target.compareTo(ISymbianBuildContext.DEBUG_TARGET) == 0) {
       
    84 				displayString = displayString + SPACE_DISPLAY_TEXT + DEBUG_DISPLAY_TEXT;
       
    85 			} else {
       
    86 				displayString = displayString + SPACE_DISPLAY_TEXT + RELEASE_DISPLAY_TEXT;
       
    87 			}
       
    88 			
       
    89 			String basePlatform = sbsv2Alias;
       
    90 			
       
    91 			displayString = displayString + " (" + basePlatform + ") [" + getSDK().getUniqueId() + "]"; //$NON-NLS-1$
       
    92 		}
       
    93 		return displayString;
    60 		return displayString;
    94 	}
    61 	}
    95 
    62 
    96 	@Override
    63 	@Override
    97 	public String toString() {
    64 	public String toString() {
   300 	public List<File> getCachedSystemIncludePaths() {
   267 	public List<File> getCachedSystemIncludePaths() {
   301 		// TODO: Still need to consider this for SBSv2 refactoring / Raptor query
   268 		// TODO: Still need to consider this for SBSv2 refactoring / Raptor query
   302 		return getCachedData().getSystemIncludePaths();
   269 		return getCachedData().getSystemIncludePaths();
   303 	}
   270 	}
   304 	
   271 	
   305 	
       
   306 	// Fall-back to get SDK id from old config name
       
   307 	public static String getSDKIDFromConfigName(String configName) {
       
   308 		int indexBegin = configName.indexOf("[");  //$NON-NLS-1$
       
   309 		int indexEnd = configName.indexOf("]");  //$NON-NLS-1$
       
   310 		if (indexBegin > 0 && indexEnd > 0){
       
   311 			return configName.substring(indexBegin+1, indexEnd);
       
   312 		} else {
       
   313 			return ""; //$NON-NLS-1$
       
   314 		}
       
   315 	}
       
   316 	
       
   317 	@Override
   272 	@Override
   318 	public int hashCode() {
   273 	public int hashCode() {
   319 		final int prime = 31;
   274 		final int prime = 31;
   320 		int result = 1;
   275 		int result = 1;
   321 		result = prime * result
   276 		result = prime * result
   355 			return false;
   310 			return false;
   356 		}
   311 		}
   357 		return true;
   312 		return true;
   358 	}
   313 	}
   359 
   314 
       
   315 	public static String getPlatformFromV1ConfigName(String displayString) {
       
   316 		String[] tokens = displayString.split(" ");
       
   317 		String sdkIdToken = tokens[2];
       
   318 		if (sdkIdToken.contains("_")){
       
   319 			sdkIdToken = sdkIdToken.substring(1, sdkIdToken.length()-1);
       
   320 			String[] aliasTokens = sdkIdToken.split("_");
       
   321 			return aliasTokens[0];
       
   322 		} else {
       
   323 			return sdkIdToken.substring(1, sdkIdToken.length()-1);
       
   324 		}
       
   325 	}
       
   326 
       
   327 	public static String getTargetFromV1ConfigName(String displayString) {
       
   328 		String[] tokens = displayString.split(" ");
       
   329 		if (tokens[1].compareTo("Debug") == 0) {
       
   330 			return ISymbianBuildContext.DEBUG_TARGET;
       
   331 		} else {
       
   332 			return ISymbianBuildContext.RELEASE_TARGET;
       
   333 		}
       
   334 	}
       
   335 
       
   336 	public static String getBuildAliasFromV1ConfigName(String displayString) {
       
   337 		String target = getTargetFromV1ConfigName(displayString);
       
   338 		String platform = getPlatformFromV1ConfigName(displayString);
       
   339 		return platform.toLowerCase() + "_" + target.toLowerCase();
       
   340 	}
       
   341 	
       
   342 	// Fall-back to get SDK id from old config name
       
   343 	public static String getSDKIDFromV1ConfigName(String configName) {
       
   344 		int indexBegin = configName.indexOf("[");  //$NON-NLS-1$
       
   345 		int indexEnd = configName.indexOf("]");  //$NON-NLS-1$
       
   346 		if (indexBegin > 0 && indexEnd > 0){
       
   347 			return configName.substring(indexBegin+1, indexEnd);
       
   348 		} else {
       
   349 			return ""; //$NON-NLS-1$
       
   350 		}
       
   351 	}
       
   352 
   360 
   353 
   361 
   354 
   362 }
   355 }