Use LinkedHashMap instead of Map to preserve build include order.
authortimkelly
Thu, 21 May 2009 11:38:31 -0500
changeset 185 a0a675250e30
parent 184 758f05682b77
child 186 7e54d0e1a873
Use LinkedHashMap instead of Map to preserve build include order. Add test to insure expected order
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/SBVPlatform.java
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISBVPlatform.java
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/DefaultIncludeFileLocator.java	Thu May 21 11:06:02 2009 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/DefaultIncludeFileLocator.java	Thu May 21 11:38:31 2009 -0500
@@ -72,7 +72,7 @@
 					}
 				} else if (sbvPlatform != null){
 					
-					Map<IPath, String> platPaths = sbvPlatform.getBuildIncludePaths();
+					LinkedHashMap<IPath, String> platPaths = sbvPlatform.getBuildIncludePaths();
 					Set<IPath> set = platPaths.keySet();
 					for (IPath path : set) {
 						String pathType = platPaths.get(path);
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java	Thu May 21 11:06:02 2009 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java	Thu May 21 11:38:31 2009 -0500
@@ -179,7 +179,7 @@
 		}
 		else if (sbvPlat != null){
 			
-			Map<IPath, String> platPaths = sbvPlat.getBuildIncludePaths();
+			LinkedHashMap<IPath, String> platPaths = sbvPlat.getBuildIncludePaths();
 			Set<IPath> set = platPaths.keySet();
 			for (IPath path : set) {
 				String pathType = platPaths.get(path);
--- a/core/com.nokia.carbide.cpp.sdk.core.test/src/com/nokia/carbide/cpp/sdk/core/test/SBVCatalogTest.java	Thu May 21 11:06:02 2009 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core.test/src/com/nokia/carbide/cpp/sdk/core/test/SBVCatalogTest.java	Thu May 21 11:38:31 2009 -0500
@@ -18,8 +18,7 @@
 package com.nokia.carbide.cpp.sdk.core.test;
 
 import java.net.URL;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 import junit.framework.TestCase;
 
@@ -106,12 +105,38 @@
 		platform = catalog.findPlatform("wilma88");
 		assertNull(platform);
 		
+	}	
+	
+	/**
+	 * Test the number and order of build include paths
+	 * @throws Exception
+	 */
+	public void testBuildIncludePaths() throws Exception {
+		setupForSDK(new Path("Data/var/group1"));
+		ISBVPlatform[] platforms = catalog.getPlatforms();
+		assertEquals(7, platforms.length);
+		
+		ISBVPlatform platform;
+		
 		// test build include paths
 		platform = catalog.findPlatform("dino79");
 		assertNotNull(platform);
 		assertEquals(4, platform.getBuildIncludePaths().size());
 		
-		Map<IPath, String> systemPaths = platform.getBuildIncludePaths();
+		LinkedHashMap<IPath, String> systemPaths = platform.getBuildIncludePaths();
+
+		Set<IPath> pathSet = systemPaths.keySet();
+		Object[] paths = pathSet.toArray();
+		IPath p;
+		p = (IPath)paths[0];
+		assertTrue("Variant build include Paths possibly in wrong order", p.toPortableString().contains("epoc32/include/config/flintstone500/dino79"));
+		p = (IPath)paths[1];
+		assertTrue("Variant build include Paths possibly in wrong order", p.toPortableString().contains("/epoc32/include/config/flintstone500"));
+		p = (IPath)paths[2];
+		assertTrue("Variant build include Paths possibly in wrong order", p.toPortableString().contains("/epoc32/include/config"));
+		p = (IPath)paths[3];
+		assertTrue("Variant build include Paths possibly in wrong order", p.toPortableString().contains("/epoc32/include"));
+		
 		Set<IPath> set = systemPaths.keySet();
 		for (IPath path : set) {
 			String pathType = systemPaths.get(path);
@@ -121,7 +146,8 @@
 		
 		assertEquals(16, platform.getROMBuildIncludePaths().size());
 		
-	}	
+		
+	}
 	
 	/**
 	 * @param built
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SymbianBuildContext.java	Thu May 21 11:06:02 2009 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SymbianBuildContext.java	Thu May 21 11:38:31 2009 -0500
@@ -383,7 +383,7 @@
 							systemPaths.add(path.toFile());
 						}
 					} else if (sbvPlat != null) {
-						Map<IPath, String> platPaths = sbvPlat.getBuildIncludePaths();
+						LinkedHashMap<IPath, String> platPaths = sbvPlat.getBuildIncludePaths();
 						Set<IPath> set = platPaths.keySet();
 						for (IPath path : set) {
 							String pathType = platPaths.get(path);
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBVPlatform.java	Thu May 21 11:06:02 2009 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBVPlatform.java	Thu May 21 11:38:31 2009 -0500
@@ -197,9 +197,9 @@
 		
 	}
 	
-	protected Map<IPath, String> getBuildIncludePathsFromParents(){
+	protected LinkedHashMap<IPath, String> getBuildIncludePathsFromParents(){
 		
-		Map<IPath, String> parentBuildIncludes = new HashMap<IPath, String>();
+		LinkedHashMap<IPath, String> parentBuildIncludes = new LinkedHashMap<IPath, String>();
 		
 		ISBVPlatform platform = getExtendedVariant();
 		ISBVPlatform prevPlat;
@@ -255,9 +255,9 @@
 		return sdkIncludePath.toOSString();
 	}
 	
-	public Map<IPath, String> getBuildIncludePaths(){
+	public LinkedHashMap<IPath, String> getBuildIncludePaths(){
 		
-		Map<IPath, String> fullPathMap = new HashMap<IPath, String>();
+		LinkedHashMap<IPath, String> fullPathMap = new LinkedHashMap<IPath, String>();
 		
 		fullPathMap.putAll(systemBuildIncludePaths);
 		fullPathMap.putAll(getBuildIncludePathsFromParents());
@@ -265,8 +265,8 @@
 		return fullPathMap;
 	}
 	
-	public Map<IPath, String> getROMBuildIncludePaths(){
-		Map<IPath, String> fullPathMap = new HashMap<IPath, String>();
+	public LinkedHashMap<IPath, String> getROMBuildIncludePaths(){
+		LinkedHashMap<IPath, String> fullPathMap = new LinkedHashMap<IPath, String>();
 		
 		fullPathMap.putAll(romBuildIncludePaths);
 		fullPathMap.putAll(getROMBuildIncludePathsFromParents());
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISBVPlatform.java	Thu May 21 11:06:02 2009 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISBVPlatform.java	Thu May 21 11:38:31 2009 -0500
@@ -12,12 +12,12 @@
 */
 package com.nokia.carbide.cpp.sdk.core;
 
-import java.util.List;
-import java.util.Map;
+import java.util.LinkedHashMap;
 
 import org.eclipse.core.runtime.IPath;
 
 import com.nokia.carbide.cpp.epoc.engine.EpocEnginePlugin;
+import com.nokia.carbide.cpp.epoc.engine.model.sbv.ISBVView;
 
 /**
  * This interface defines a single Symbian Binary Variation (SBV) platform.
@@ -81,12 +81,12 @@
 	 * 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)
 	 */
-	Map<IPath, String> getBuildIncludePaths();
+	LinkedHashMap<IPath, String> getBuildIncludePaths();
 	
 	/**
 	 * The MAP of ROM_INCLUDE paths from the variant and all it's parents
 	 * @return list of paths
 	 */
-	Map<IPath, String> getROMBuildIncludePaths();
+	LinkedHashMap<IPath, String> getROMBuildIncludePaths();
 	
 }