add support to add BUILD_INCLUDE system paths defined from build variants to project configurations.
authortimkelly
Tue, 12 May 2009 12:19:40 -0500
changeset 147 2bb08686aa38
parent 146 8eed74449d21
child 148 c7e636e6e9cd
add support to add BUILD_INCLUDE system paths defined from build variants to project configurations.
builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/DefaultIncludeFileLocator.java
builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java
core/com.nokia.carbide.cpp.sdk.core.test/src/com/nokia/carbide/cpp/sdk/core/test/SBVCatalogTest.java
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SymbianBuildContext.java
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBVCatalog.java
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBVPlatform.java
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISBVPlatform.java
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISymbianSDK.java
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/DefaultIncludeFileLocator.java	Tue May 12 10:46:48 2009 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/DefaultIncludeFileLocator.java	Tue May 12 12:19:40 2009 -0500
@@ -20,15 +20,14 @@
 package com.nokia.carbide.cdt.builder;
 
 import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.IPath;
 
 import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo;
-import com.nokia.carbide.cpp.sdk.core.IBSFPlatform;
-import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext;
+import com.nokia.carbide.cpp.epoc.engine.model.sbv.ISBVView;
+import com.nokia.carbide.cpp.sdk.core.*;
 import com.nokia.carbide.internal.api.cpp.epoc.engine.preprocessor.BasicIncludeFileLocator;
 
 public class DefaultIncludeFileLocator extends BasicIncludeFileLocator {
@@ -60,16 +59,29 @@
 				File dir;
 				
 				// get additional include directories from BSF platform, if defined
-				IBSFPlatform platform = buildContext.getSDK().getBSFCatalog().findPlatform(buildContext.getPlatformString());
-				if (platform != null) {
-					IPath[] systemIncludePaths = platform.getSystemIncludePaths();
+				IBSFPlatform bsfplatform = buildContext.getSDK().getBSFCatalog().findPlatform(buildContext.getPlatformString());
+				ISBVPlatform sbvPlatform = buildContext.getSDK().getSBVCatalog().findPlatform(buildContext.getPlatformString());
+				if (bsfplatform != null) {
+					IPath[] systemIncludePaths = bsfplatform.getSystemIncludePaths();
 					for (IPath path : systemIncludePaths) {
 						dir = path.toFile();
 						if (dir.exists() && dir.isDirectory()) {
 							systemPaths.add(dir);
 						}
 					}
-				} else {
+				} else if (sbvPlatform != null){
+					
+					Map<IPath, String> platPaths = sbvPlatform.getBuildIncludePaths();
+					Set<IPath> set = platPaths.keySet();
+					for (IPath path : set) {
+						String pathType = platPaths.get(path);
+						if (pathType.equalsIgnoreCase(ISBVView.INCLUDE_FLAG_PREPEND) || pathType.equalsIgnoreCase(ISBVView.INCLUDE_FLAG_SET)){
+							dir = path.toFile();
+							systemPaths.add(dir);
+						}
+					}
+				}
+				else {
 					// legacy behavior 
 					if (buildContext.getPlatformString().equals(ISymbianBuildContext.EMULATOR_PLATFORM)) {
 						dir = new File(includeDir, "wins"); //$NON-NLS-1$
@@ -87,6 +99,20 @@
 	
 				// and finally the normal include dir
 				systemPaths.add(includeDir);
+				
+				// and finally, finally, if this is an SBV add any paths with the append flag
+				if (sbvPlatform != null){
+					
+					Map<IPath, String> platPaths = sbvPlatform.getBuildIncludePaths();
+					Set<IPath> set = platPaths.keySet();
+					for (IPath path : set) {
+						String pathType = platPaths.get(path);
+						if (pathType.equalsIgnoreCase(ISBVView.INCLUDE_FLAG_APPEND)){
+							dir = path.toFile();
+							systemPaths.add(dir);
+						}
+					}	
+				}
 			}
 			
 			// also search files in same folder as variant.hrh
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java	Tue May 12 10:46:48 2009 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java	Tue May 12 12:19:40 2009 -0500
@@ -17,40 +17,24 @@
 package com.nokia.carbide.cdt.internal.builder;
 
 import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 import org.eclipse.cdt.core.CCorePlugin;
 import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
-import org.eclipse.cdt.core.settings.model.CMacroEntry;
-import org.eclipse.cdt.core.settings.model.CMacroFileEntry;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
-import org.eclipse.cdt.core.settings.model.ICProjectDescription;
-import org.eclipse.cdt.core.settings.model.ICSettingEntry;
-import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.*;
 import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.core.runtime.content.IContentTypeManager;
-import org.eclipse.core.runtime.content.IContentTypeSettings;
+import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.content.*;
 
 import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin;
 import com.nokia.carbide.cdt.builder.EpocEngineHelper;
 import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration;
+import com.nokia.carbide.cpp.epoc.engine.model.sbv.ISBVView;
 import com.nokia.carbide.cpp.epoc.engine.preprocessor.IDefine;
 import com.nokia.carbide.cpp.sdk.core.IBSFPlatform;
+import com.nokia.carbide.cpp.sdk.core.ISBVPlatform;
 import com.nokia.cpp.internal.api.utils.core.FileUtils;
 /**
  * Part of the new CDT 4.0 project model requirements.  All this class
@@ -186,13 +170,25 @@
 
 		// add platform includes first
 		IBSFPlatform platform = carbideBuildConfig.getSDK().getBSFCatalog().findPlatform(carbideBuildConfig.getPlatformString());
+		ISBVPlatform sbvPlat = carbideBuildConfig.getSDK().getSBVCatalog().findPlatform(carbideBuildConfig.getPlatformString());
 		if (platform != null) {
 			IPath[] systemIncludePaths = platform.getSystemIncludePaths();
 			for (IPath path : systemIncludePaths) {
 				includeEntries.add(new CIncludePathEntry(path, 0));
 			}
 		}
-
+		else if (sbvPlat != null){
+			
+			Map<IPath, String> platPaths = sbvPlat.getBuildIncludePaths();
+			Set<IPath> set = platPaths.keySet();
+			for (IPath path : set) {
+				String pathType = platPaths.get(path);
+				if (pathType.equalsIgnoreCase(ISBVView.INCLUDE_FLAG_PREPEND) || pathType.equalsIgnoreCase(ISBVView.INCLUDE_FLAG_SET)){
+					includeEntries.add(new CIncludePathEntry(path, 0));
+				}
+			}
+		}
+		
 		// get the user and system includes
 		List<File> userIncludes = new ArrayList<File>();
 		List<File> systemIncludes = new ArrayList<File>();
--- a/core/com.nokia.carbide.cpp.sdk.core.test/src/com/nokia/carbide/cpp/sdk/core/test/SBVCatalogTest.java	Tue May 12 10:46:48 2009 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core.test/src/com/nokia/carbide/cpp/sdk/core/test/SBVCatalogTest.java	Tue May 12 12:19:40 2009 -0500
@@ -18,7 +18,8 @@
 package com.nokia.carbide.cpp.sdk.core.test;
 
 import java.net.URL;
-import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import junit.framework.TestCase;
 
@@ -110,9 +111,12 @@
 		assertNotNull(platform);
 		assertEquals(4, platform.getBuildIncludePaths().size());
 		
-		List<IPath> incPaths = platform.getBuildIncludePaths();
-		for (IPath path : incPaths){
-			System.out.println("Include path for dino79 bianry variant: " + path.toOSString());
+		Map<IPath, String> systemPaths = platform.getBuildIncludePaths();
+		Set<IPath> set = systemPaths.keySet();
+		for (IPath path : set) {
+			String pathType = systemPaths.get(path);
+			assertNotNull(pathType);
+			System.out.println("BUILD_INCLUDE = " + path.toOSString() + " Type = " + pathType);
 		}
 		
 		assertEquals(16, platform.getROMBuildIncludePaths().size());
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SymbianBuildContext.java	Tue May 12 10:46:48 2009 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SymbianBuildContext.java	Tue May 12 12:19:40 2009 -0500
@@ -13,25 +13,15 @@
 package com.nokia.carbide.cpp.internal.api.sdk;
 
 import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 import org.eclipse.core.runtime.IPath;
 import org.osgi.framework.Version;
 
-import com.nokia.carbide.cpp.epoc.engine.preprocessor.DefaultModelDocumentProvider;
-import com.nokia.carbide.cpp.epoc.engine.preprocessor.DefaultTranslationUnitProvider;
-import com.nokia.carbide.cpp.epoc.engine.preprocessor.DefineFactory;
-import com.nokia.carbide.cpp.epoc.engine.preprocessor.IDefine;
+import com.nokia.carbide.cpp.epoc.engine.model.sbv.ISBVView;
+import com.nokia.carbide.cpp.epoc.engine.preprocessor.*;
 import com.nokia.carbide.cpp.internal.sdk.core.model.SymbianMissingSDKFactory;
-import com.nokia.carbide.cpp.sdk.core.IBSFCatalog;
-import com.nokia.carbide.cpp.sdk.core.IBSFPlatform;
-import com.nokia.carbide.cpp.sdk.core.IRVCTToolChainInfo;
-import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext;
-import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
-import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin;
+import com.nokia.carbide.cpp.sdk.core.*;
 import com.nokia.carbide.internal.api.cpp.epoc.engine.preprocessor.BasicIncludeFileLocator;
 import com.nokia.carbide.internal.api.cpp.epoc.engine.preprocessor.MacroScanner;
 
@@ -384,13 +374,23 @@
 				File prefixFile = getSDK().getPrefixFile();
 				if (prefixFile != null) {
 
-					// add any BSF includes so the headers are picked up from the correct location
+					// add any BSF/SBV includes so the headers are picked up from the correct location
 					List<File> systemPaths = new ArrayList<File>();
-					IBSFPlatform plat = getSDK().getBSFCatalog().findPlatform(platform);
-					if (plat != null) {
-						for (IPath path : plat.getSystemIncludePaths()) {
+					IBSFPlatform bsfPlat = getSDK().getBSFCatalog().findPlatform(platform);
+					ISBVPlatform sbvPlat = getSDK().getSBVCatalog().findPlatform(platform);
+					if (bsfPlat != null) {
+						for (IPath path : bsfPlat.getSystemIncludePaths()) {
 							systemPaths.add(path.toFile());
 						}
+					} else if (sbvPlat != null) {
+						Map<IPath, String> platPaths = sbvPlat.getBuildIncludePaths();
+						Set<IPath> set = platPaths.keySet();
+						for (IPath path : set) {
+							String pathType = platPaths.get(path);
+							if (pathType.equalsIgnoreCase(ISBVView.INCLUDE_FLAG_PREPEND) || pathType.equalsIgnoreCase(ISBVView.INCLUDE_FLAG_SET)){
+								systemPaths.add(path.toFile());
+							}
+						}
 					}
 					
 					MacroScanner scanner = new MacroScanner(
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBVCatalog.java	Tue May 12 10:46:48 2009 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBVCatalog.java	Tue May 12 12:19:40 2009 -0500
@@ -74,8 +74,16 @@
 	 * @see com.nokia.carbide.cpp.sdk.core.ISBVCatalog#findPlatform(java.lang.String)
 	 */
 	public ISBVPlatform findPlatform(String platformName) {
+		
+		// The platform name for a symbian binary variant should be <plat>.<variant>
+		//So we will only care about the second part to find the actual SBV platform
+		String searchName = platformName;
+		String[] token = platformName.split("\\.");
+		if (token.length == 2){
+			searchName = token[1];
+		}
 		for (ISBVPlatform platform : platforms) {
-			if (platform.getName().equalsIgnoreCase(platformName))
+			if (platform.getName().equalsIgnoreCase(searchName))
 				return platform;
 		}
 		return null;
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBVPlatform.java	Tue May 12 10:46:48 2009 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBVPlatform.java	Tue May 12 12:19:40 2009 -0500
@@ -36,8 +36,8 @@
 	private IPath path;
 	private ISBVPlatform extendedPlatform;
 	private String extendedPlatName;
-	private List<IPath> systemBuildIncludePaths = new ArrayList<IPath>();
-	private List<IPath> romBuildIncludePaths = new ArrayList<IPath>();
+	private Map<IPath, String> systemBuildIncludePaths = new HashMap<IPath, String>();
+	private Map<IPath, String> romBuildIncludePaths = new HashMap<IPath, String>();
 	private IPath sdkIncludePath;
 	private IPath bldVarintHRH;
 	private ISBVCatalog catalog;
@@ -189,20 +189,21 @@
 			Set<String> set = incPaths.keySet();
 			for (String currPath : set) {
 				IPath path = new Path(getEPOCRoot() + currPath);
-				systemBuildIncludePaths.add(path);
+				String pathProperty = incPaths.get(currPath);
+				systemBuildIncludePaths.put(path, pathProperty);
 			}
 		}
 		
 	}
 	
-	protected List<IPath> getBuildIncludePathsFromParents(){
+	protected Map<IPath, String> getBuildIncludePathsFromParents(){
 		
-		List<IPath> parentBuildIncludes = new ArrayList<IPath>();
+		Map<IPath, String> parentBuildIncludes = new HashMap<IPath, String>();
 		
 		ISBVPlatform platform = getExtendedVariant();
 		ISBVPlatform prevPlat;
 		while (platform != null) {
-			parentBuildIncludes.addAll(platform.getBuildIncludePaths());
+			parentBuildIncludes.putAll(platform.getBuildIncludePaths());
 			prevPlat = platform;
 			platform = getExtendedVariant();
 			if (prevPlat.getName().equalsIgnoreCase(platform.getName())){
@@ -213,25 +214,26 @@
 		return parentBuildIncludes;
 	}
 	
-	protected void setROMBuildIncludePaths(Map<String, String> incPaths){
+	protected void setROMBuildIncludePaths(Map<String, String> romPaths){
 		synchronized (this)
 		{
-			Set<String> set = incPaths.keySet();
-			for (String currPath : set){
+			Set<String> set = romPaths.keySet();
+			for (String currPath : set) {
 				IPath path = new Path(getEPOCRoot() + currPath);
-				romBuildIncludePaths.add(path);
+				String pathProperty = romPaths.get(currPath);
+				romBuildIncludePaths.put(path, pathProperty);
 			}
 		}
 	}
 	
-	protected List<IPath> getROMBuildIncludePathsFromParents(){
+	protected Map<IPath, String> getROMBuildIncludePathsFromParents(){
 		
-		List<IPath> parentROMBuildIncludes = new ArrayList<IPath>();
+		Map<IPath, String> parentROMBuildIncludes = new HashMap<IPath, String>();
 		
 		ISBVPlatform platform = getExtendedVariant();
 		ISBVPlatform prevPlat;
 		while (platform != null) {
-			parentROMBuildIncludes.addAll(platform.getROMBuildIncludePaths());
+			parentROMBuildIncludes.putAll(platform.getROMBuildIncludePaths());
 			prevPlat = platform;
 			platform = getExtendedVariant();
 			if (prevPlat.getName().equalsIgnoreCase(platform.getName())){
@@ -252,22 +254,23 @@
 		return sdkIncludePath.toOSString();
 	}
 	
-	public List<IPath> getBuildIncludePaths(){
-		List<IPath> fullList = new ArrayList<IPath>();
+	public Map<IPath, String> getBuildIncludePaths(){
+		
+		Map<IPath, String> fullPathMap = new HashMap<IPath, String>();
 		
-		fullList.addAll(systemBuildIncludePaths);
-		fullList.addAll(getBuildIncludePathsFromParents());
+		fullPathMap.putAll(systemBuildIncludePaths);
+		fullPathMap.putAll(getBuildIncludePathsFromParents());
 		
-		return fullList;
+		return fullPathMap;
 	}
 	
-	public List<IPath> getROMBuildIncludePaths(){
-		List<IPath> fullList = new ArrayList<IPath>();
+	public Map<IPath, String> getROMBuildIncludePaths(){
+		Map<IPath, String> fullPathMap = new HashMap<IPath, String>();
 		
-		fullList.addAll(romBuildIncludePaths);
-		fullList.addAll(getROMBuildIncludePathsFromParents());
+		fullPathMap.putAll(romBuildIncludePaths);
+		fullPathMap.putAll(getROMBuildIncludePathsFromParents());
 		
-		return fullList;
+		return fullPathMap;
 	}
 	
 	
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISBVPlatform.java	Tue May 12 10:46:48 2009 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISBVPlatform.java	Tue May 12 12:19:40 2009 -0500
@@ -13,6 +13,7 @@
 package com.nokia.carbide.cpp.sdk.core;
 
 import java.util.List;
+import java.util.Map;
 
 import org.eclipse.core.runtime.IPath;
 
@@ -75,15 +76,15 @@
 	public IPath getBuildVariantHRHFile();
 	
 	/**
-	 * The list of BUILD_INCLUDE paths from the variant and all it's parents
-	 * @return list of paths
+	 * The MAP of BUILD_INCLUDE paths from the variant and all it's parents
+	 * @return Map of IPaths and the operation to perform (set, prepend, append)
 	 */
-	List<IPath> getBuildIncludePaths();
+	Map<IPath, String> getBuildIncludePaths();
 	
 	/**
-	 * The list of ROM_INCLUDE paths from the variant and all it's parents
+	 * The MAP of ROM_INCLUDE paths from the variant and all it's parents
 	 * @return list of paths
 	 */
-	List<IPath> getROMBuildIncludePaths();
+	Map<IPath, String> getROMBuildIncludePaths();
 	
 }
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISymbianSDK.java	Tue May 12 10:46:48 2009 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISymbianSDK.java	Tue May 12 12:19:40 2009 -0500
@@ -359,4 +359,9 @@
 	 * Get the BSF catalog for the SDK.
 	 */
 	IBSFCatalog getBSFCatalog();
+	
+	/**
+	 * Get the Symbian Binary Variation (SBV) catalog for the SDK.
+	 */
+	ISBVCatalog getSBVCatalog();
 }