core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SymbianBuildContextDataCache.java
branchC3_BUILDER_WORK
changeset 1462 b38491fd06da
parent 1434 79471fd1fd69
child 1471 62024a5fa81d
equal deleted inserted replaced
1460:26f585ac8a88 1462:b38491fd06da
   100 	private List<IDefine> variantHRHMacros = new ArrayList<IDefine>();
   100 	private List<IDefine> variantHRHMacros = new ArrayList<IDefine>();
   101 	private List<IDefine> compilerPrefixMacros = new ArrayList<IDefine>();
   101 	private List<IDefine> compilerPrefixMacros = new ArrayList<IDefine>();
   102 	private ExternalFileInfoCollection compilerPrefixFileInfo = null; 
   102 	private ExternalFileInfoCollection compilerPrefixFileInfo = null; 
   103 	private List<File> systemIncludes;
   103 	private List<File> systemIncludes;
   104 	private ISymbianSDK sdk;
   104 	private ISymbianSDK sdk;
   105 	ISBSv1BuildInfo sbsv1BuildInfo;
       
   106 	ISBSv2BuildInfo sbsv2BuildInfo;
       
   107 	private IPath compilerPrefixFile;
   105 	private IPath compilerPrefixFile;
   108 
   106 
   109 	private String platformString;
   107 	private String platformString;
   110 
   108 
   111 	private String displayString;
   109 	private String displayString;
   112 
   110 
   113 	private String contextKey;
   111 	private String contextKey;
   114 	
   112 
       
   113 	private String builderId;
       
   114 
   115 	private boolean changed;
   115 	private boolean changed;
   116 
   116 
   117 	private File cacheFile;
   117 	private File cacheFile;
   118 
   118 
   119 	private SymbianBuildContextDataCache(ISymbianBuildContext context) {
   119 	private SymbianBuildContextDataCache(ISymbianBuildContext context) {
   120 		if (DEBUG) System.out.println("Creating cache for " + context.getDisplayString());
   120 		if (DEBUG) System.out.println("Creating cache for " + context.getDisplayString());
   121 		this.platformString = context.getPlatformString();
   121 		this.platformString = context.getPlatformString();
   122 		this.displayString = context.getDisplayString();
   122 		this.displayString = context.getDisplayString();
   123 		this.sdk = context.getSDK();
   123 		this.sdk = context.getSDK();
   124 		sbsv1BuildInfo = (ISBSv1BuildInfo)sdk.getBuildInfo(ISymbianBuilderID.SBSV1_BUILDER);
       
   125 		sbsv2BuildInfo = (ISBSv2BuildInfo)sdk.getBuildInfo(ISymbianBuilderID.SBSV2_BUILDER);
       
   126 		this.contextKey = getBuildContextKey(context);
   124 		this.contextKey = getBuildContextKey(context);
       
   125 		if (context instanceof ISBSv1BuildContext) {
       
   126 			builderId = ISymbianBuilderID.SBSV1_BUILDER;
       
   127 		} else {
       
   128 			builderId = ISymbianBuilderID.SBSV2_BUILDER;
       
   129 		}
   127 	}
   130 	}
   128 
   131 
   129 	/* (non-Javadoc)
   132 	/* (non-Javadoc)
   130 	 * @see java.lang.Object#toString()
   133 	 * @see java.lang.Object#toString()
   131 	 */
   134 	 */
   168 		
   171 		
   169 		synchronized (this) {
   172 		synchronized (this) {
   170 
   173 
   171 			List<IDefine> macros = new ArrayList<IDefine>();
   174 			List<IDefine> macros = new ArrayList<IDefine>();
   172 			Map<String, IDefine> namedMacros = new HashMap<String, IDefine>();
   175 			Map<String, IDefine> namedMacros = new HashMap<String, IDefine>();
   173 			File prefixFile = null;
   176 			File prefixFile = sdk.getPrefixFile(builderId);
   174 			if (sbsv1BuildInfo != null) {
       
   175 				prefixFile = sbsv1BuildInfo.getPrefixFile(sdk);
       
   176 			} else if (sbsv2BuildInfo != null) {
       
   177 				prefixFile = sbsv2BuildInfo.getPrefixFile(sdk);
       
   178 			}
       
   179 			
   177 			
   180 			if (prefixFile == null){
   178 			if (prefixFile == null){
   181 				// Check that the prefix file may have become available since the SDK was scanned last.
   179 				// Check that the prefix file may have become available since the SDK was scanned last.
   182 				// This can happen, for e.g., if the user opens the IDE _then_ does a subst on a drive that already has an SDK entry.
   180 				// This can happen, for e.g., if the user opens the IDE _then_ does a subst on a drive that already has an SDK entry.
   183 				IPath prefixCheck = ((SymbianSDK)sdk).getPrefixFromVariantCfg();
   181 				ISDKBuildInfo buildInfo = sdk.getBuildInfo(builderId);
       
   182 				IPath prefixCheck = buildInfo.getPrefixFromVariantCfg();
   184 				if (prefixCheck != null){
   183 				if (prefixCheck != null){
   185 					prefixFile = prefixCheck.toFile();
   184 					prefixFile = prefixCheck.toFile();
   186 					if (sbsv1BuildInfo != null) {
   185 					((SymbianSDK)sdk).setPrefixFile(prefixCheck, builderId);
   187 						sbsv1BuildInfo.setPrefixFile(sdk, prefixCheck);
       
   188 					} else if (sbsv2BuildInfo != null) {
       
   189 						sbsv2BuildInfo.setPrefixFile(sdk, prefixCheck);
       
   190 					}
       
   191 				}
   186 				}
   192 			}
   187 			}
   193 			
   188 			
   194 			File[] includedFiles = null;
   189 			File[] includedFiles = null;
   195 
   190 
   200 				systemPaths.add(new File(sdk.getEPOCROOT() + "epoc32/include"));
   195 				systemPaths.add(new File(sdk.getEPOCROOT() + "epoc32/include"));
   201 				
   196 				
   202 				// add any BSF/SBV includes so the headers are picked up from the correct location
   197 				// add any BSF/SBV includes so the headers are picked up from the correct location
   203 				IBSFPlatform bsfPlat = null;
   198 				IBSFPlatform bsfPlat = null;
   204 				ISBVPlatform sbvPlat = null;
   199 				ISBVPlatform sbvPlat = null;
   205 				if (sbsv1BuildInfo != null) {
   200 				ISDKBuildInfo buildInfo = sdk.getBuildInfo(builderId);
   206 					bsfPlat = sbsv1BuildInfo.getBSFCatalog(sdk).findPlatform(platformString);
   201 				if (buildInfo instanceof ISBSv1BuildInfo) {
   207 					sbvPlat = sbsv1BuildInfo.getSBVCatalog(sdk).findPlatform(platformString);
   202 					ISBSv1BuildInfo sbsv1BuildInfo = (ISBSv1BuildInfo)buildInfo;
   208 				} else if (sbsv2BuildInfo != null) {
   203 					bsfPlat = sbsv1BuildInfo.getBSFCatalog().findPlatform(platformString);
   209 					bsfPlat = sbsv2BuildInfo.getBSFCatalog(sdk).findPlatform(platformString);
   204 					sbvPlat = sbsv1BuildInfo.getSBVCatalog().findPlatform(platformString);
   210 					sbvPlat = sbsv2BuildInfo.getSBVCatalog(sdk).findPlatform(platformString);
   205 				} else {
       
   206 					ISBSv2BuildInfo sbsv2BuildInfo = (ISBSv2BuildInfo)buildInfo;
       
   207 					bsfPlat = sbsv2BuildInfo.getBSFCatalog().findPlatform(platformString);
       
   208 					sbvPlat = sbsv2BuildInfo.getSBVCatalog().findPlatform(platformString);
   211 				}
   209 				}
   212 				if (bsfPlat != null) {
   210 				if (bsfPlat != null) {
   213 					for (IPath path : bsfPlat.getSystemIncludePaths()) {
   211 					for (IPath path : bsfPlat.getSystemIncludePaths()) {
   214 						systemPaths.add(path.toFile());
   212 						systemPaths.add(path.toFile());
   215 					}
   213 					}
   311 					List<File> userPaths = new ArrayList<File>();
   309 					List<File> userPaths = new ArrayList<File>();
   312 					List<File> systemPaths = new ArrayList<File>();
   310 					List<File> systemPaths = new ArrayList<File>();
   313 					
   311 					
   314 					userPaths.add(prefixFile.removeLastSegments(1).toFile());
   312 					userPaths.add(prefixFile.removeLastSegments(1).toFile());
   315 					systemPaths.add(prefixFile.removeLastSegments(1).toFile());
   313 					systemPaths.add(prefixFile.removeLastSegments(1).toFile());
   316 					IPath includePath = null;
   314 					IPath includePath = sdk.getIncludePath();
   317 					if (sbsv1BuildInfo != null) {
       
   318 						includePath = sbsv1BuildInfo.getIncludePath(sdk);
       
   319 					} else if (sbsv2BuildInfo != null) {
       
   320 						includePath = sbsv2BuildInfo.getIncludePath(sdk);
       
   321 					}
       
   322 					if (includePath != null) {
   315 					if (includePath != null) {
   323 						File includeDir = includePath.toFile().getAbsoluteFile();
   316 						File includeDir = includePath.toFile().getAbsoluteFile();
   324 						userPaths.add(includeDir);
   317 						userPaths.add(includeDir);
   325 						systemPaths.add(includeDir);
   318 						systemPaths.add(includeDir);
   326 					}
   319 					}
   379 		
   372 		
   380 		if (DEBUG) System.out.println("Scanning include paths for " + displayString);
   373 		if (DEBUG) System.out.println("Scanning include paths for " + displayString);
   381 		
   374 		
   382 		IBSFPlatform bsfplatform = null;
   375 		IBSFPlatform bsfplatform = null;
   383 		ISBVPlatform sbvPlatform = null;
   376 		ISBVPlatform sbvPlatform = null;
   384 		if (sbsv1BuildInfo != null) {
   377 		ISDKBuildInfo buildInfo = sdk.getBuildInfo(builderId);
   385 			bsfplatform = sbsv1BuildInfo.getBSFCatalog(sdk).findPlatform(platformString);
   378 		if (buildInfo instanceof ISBSv1BuildInfo) {
   386 			sbvPlatform = sbsv1BuildInfo.getSBVCatalog(sdk).findPlatform(platformString);
   379 			ISBSv1BuildInfo sbsv1BuildInfo = (ISBSv1BuildInfo)buildInfo;
   387 		} else if (sbsv2BuildInfo != null) {
   380 			bsfplatform = sbsv1BuildInfo.getBSFCatalog().findPlatform(platformString);
   388 			bsfplatform = sbsv2BuildInfo.getBSFCatalog(sdk).findPlatform(platformString);
   381 			sbvPlatform = sbsv1BuildInfo.getSBVCatalog().findPlatform(platformString);
   389 			sbvPlatform = sbsv2BuildInfo.getSBVCatalog(sdk).findPlatform(platformString);
   382 		} else {
       
   383 			ISBSv2BuildInfo sbsv2BuildInfo = (ISBSv2BuildInfo)buildInfo;
       
   384 			bsfplatform = sbsv2BuildInfo.getBSFCatalog().findPlatform(platformString);
       
   385 			sbvPlatform = sbsv2BuildInfo.getSBVCatalog().findPlatform(platformString);
   390 		}
   386 		}
   391 
   387 
   392 		// look in the epoc32 directory of the SDK
   388 		// look in the epoc32 directory of the SDK
   393 		IPath includePath = null;
   389 		IPath includePath = sdk.getIncludePath();
   394 		if (sbsv1BuildInfo != null) {
       
   395 			includePath = sbsv1BuildInfo.getIncludePath(sdk);
       
   396 		} else if (sbsv2BuildInfo != null) {
       
   397 			includePath = sbsv2BuildInfo.getIncludePath(sdk);
       
   398 		}
       
   399 		if (includePath != null) {
   390 		if (includePath != null) {
   400 			File includeDir = includePath.toFile().getAbsoluteFile();
   391 			File includeDir = includePath.toFile().getAbsoluteFile();
   401 			File dir;
   392 			File dir;
   402 			
   393 			
   403 			// get additional include directories from BSF platform, if defined
   394 			// get additional include directories from BSF platform, if defined
   454 				}	
   445 				}	
   455 			}
   446 			}
   456 		}
   447 		}
   457 		
   448 		
   458 		// also search files in same folder as variant.hrh
   449 		// also search files in same folder as variant.hrh
   459 		File prefix = null;
   450 		File prefix = sdk.getPrefixFile(builderId);
   460 		if (sbsv1BuildInfo != null) {
       
   461 			prefix = sbsv1BuildInfo.getPrefixFile(sdk);
       
   462 		} else if (sbsv2BuildInfo != null) {
       
   463 			prefix = sbsv2BuildInfo.getPrefixFile(sdk);
       
   464 		}
       
   465 		if (sbvPlatform != null){
   451 		if (sbvPlatform != null){
   466 			// might be an alternate HRH file to use
   452 			// might be an alternate HRH file to use
   467 			IPath varVarHRH = sbvPlatform.getBuildVariantHRHFile();
   453 			IPath varVarHRH = sbvPlatform.getBuildVariantHRHFile();
   468 			if (!varVarHRH.toFile().equals(prefix) && varVarHRH.toFile().exists()){
   454 			if (!varVarHRH.toFile().equals(prefix) && varVarHRH.toFile().exists()){
   469 				prefix = varVarHRH.toFile();
   455 				prefix = varVarHRH.toFile();