Added caching of Raptor query data for aliases, products and configs. C3_BUILDER_WORK
authorstechong
Thu, 01 Jul 2010 16:36:11 -0500
branchC3_BUILDER_WORK
changeset 1568 508bfdb3a934
parent 1553 a0d518fc91ea
child 1621 393b985a50f3
Added caching of Raptor query data for aliases, products and configs.
builder/com.nokia.carbide.cdt.builder.test/src/com/nokia/carbide/cdt/builder/test/SBSv2QueryTests.java
builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/DefaultViewConfiguration.java
builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/api/builder/CarbideConfigurationDataProvider.java
builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java
builder/com.nokia.carbide.cpp.builder.utils/src/com/nokia/carbide/cpp/internal/builder/utils/handlers/PreprocessHandler.java
core/com.nokia.carbide.cpp.sdk.core.test/src/com/nokia/carbide/cpp/sdk/core/test/TestCarbideSDKCache.java
core/com.nokia.carbide.cpp.sdk.core/META-INF/MANIFEST.MF
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/BuildContextSBSv2.java
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/ISBSv2BuildInfo.java
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/sbsv2/SBSv2ConfigQueryData.java
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/sbsv2/SBSv2QueryUtils.java
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/sbsv2/SBSv2SDKKey.java
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/AbstractSDKManager.java
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBSv2BuildInfo.java
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SDKManager.java
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISBSv2BuildContext.java
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISBSv2ConfigQueryData.java
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/SDKCorePlugin.java
core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/sdk/ui/shared/BuildTargetTreeNode.java
core/com.nokia.cpp.utils.core/src/com/nokia/cpp/internal/api/utils/core/CacheUtils.java
--- a/builder/com.nokia.carbide.cdt.builder.test/src/com/nokia/carbide/cdt/builder/test/SBSv2QueryTests.java	Mon Jun 28 10:14:24 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder.test/src/com/nokia/carbide/cdt/builder/test/SBSv2QueryTests.java	Thu Jul 01 16:36:11 2010 -0500
@@ -18,8 +18,6 @@
 package com.nokia.carbide.cdt.builder.test;
 
 import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 
 import org.osgi.framework.Version;
@@ -77,10 +75,10 @@
 			ISBSv2BuildContext sbsv2Context = (ISBSv2BuildContext)context;
 			
 			assertTrue(sbsv2Context.getVariantHRHDefines().size() > 0);
-			if (sbsv2Context.getConfigurationErrorMessage() == null || sbsv2Context.getConfigurationErrorMessage().length() == 0){
-				assertTrue((new File(sbsv2Context.getmetaDataVariantHRH())).exists());
+			if (sbsv2Context.getConfigQueryData().getConfigurationErrorMessage() == null || sbsv2Context.getConfigQueryData().getConfigurationErrorMessage().length() == 0){
+				assertTrue((new File(sbsv2Context.getConfigQueryData().getMetaDataVariantHRH())).exists());
 			} else {
-				System.out.println("Config " + sbsv2Context.getSBSv2Alias() + " had error, cannot fully test: " + sbsv2Context.getConfigurationErrorMessage());
+				System.out.println("Config " + sbsv2Context.getSBSv2Alias() + " had error, cannot fully test: " + sbsv2Context.getConfigQueryData().getConfigurationErrorMessage());
 			}
 		}
 	}
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/DefaultViewConfiguration.java	Mon Jun 28 10:14:24 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/DefaultViewConfiguration.java	Thu Jul 01 16:36:11 2010 -0500
@@ -209,9 +209,12 @@
 				macros.add(DefineFactory.createDefine("SBSV2", null));
 				ISBSv2BuildInfo sbsv2BuildInfo = (ISBSv2BuildInfo)sdk.getBuildInfo(ISymbianBuilderID.SBSV2_BUILDER);
 				if (sbsv2BuildInfo != null) {
-					for (String platMacro : sbsv2BuildInfo.getPlatformMacros(context.getPlatformString())) {
-						macros.add(DefineFactory.createDefine(platMacro.trim(), platMacro.trim()));
-					}
+					Map<String, String> platMacros = sbsv2BuildInfo.getPlatformMacros(context.getPlatformString());
+					for (Iterator<String> it = platMacros.keySet().iterator(); it.hasNext(); ) { 
+						String name = it.next();
+						String value = platMacros.get(name);
+						macros.add(DefineFactory.createDefine(name, value));
+					} 
 				}
 			} else {
 				ISBSv1BuildInfo sbsv1BuildInfo = (ISBSv1BuildInfo)sdk.getBuildInfo(ISymbianBuilderID.SBSV1_BUILDER);
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/api/builder/CarbideConfigurationDataProvider.java	Mon Jun 28 10:14:24 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/api/builder/CarbideConfigurationDataProvider.java	Thu Jul 01 16:36:11 2010 -0500
@@ -251,6 +251,7 @@
 			}
 		}
 		
+		
 		return null;
 		
 	}
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java	Mon Jun 28 10:14:24 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java	Thu Jul 01 16:36:11 2010 -0500
@@ -282,10 +282,7 @@
 		} else {
 			ISBSv2BuildInfo sbsv2BuildInfo = (ISBSv2BuildInfo)sdk.getBuildInfo(ISymbianBuilderID.SBSV2_BUILDER);
 			// platform macros
-			for (String platMacro : sbsv2BuildInfo.getPlatformMacros(carbideBuildConfig.getPlatformString())) {
-				macros.put("__" + platMacro + "__", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-			}
-			
+			macros.putAll(sbsv2BuildInfo.getPlatformMacros(carbideBuildConfig.getPlatformString()));			
 		}
 		
 		// built in macros
--- a/builder/com.nokia.carbide.cpp.builder.utils/src/com/nokia/carbide/cpp/internal/builder/utils/handlers/PreprocessHandler.java	Mon Jun 28 10:14:24 2010 -0500
+++ b/builder/com.nokia.carbide.cpp.builder.utils/src/com/nokia/carbide/cpp/internal/builder/utils/handlers/PreprocessHandler.java	Thu Jul 01 16:36:11 2010 -0500
@@ -20,7 +20,9 @@
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 import org.eclipse.cdt.core.model.CModelException;
 import org.eclipse.cdt.core.model.CoreModel;
@@ -80,6 +82,7 @@
 import com.nokia.carbide.cpp.epoc.engine.model.mmp.IMMPData;
 import com.nokia.carbide.cpp.epoc.engine.model.mmp.IMMPResource;
 import com.nokia.carbide.cpp.epoc.engine.preprocessor.AcceptedNodesViewFilter;
+import com.nokia.carbide.cpp.epoc.engine.preprocessor.DefineFactory;
 import com.nokia.carbide.cpp.internal.api.sdk.ISBSv1BuildInfo;
 import com.nokia.carbide.cpp.internal.api.sdk.ISBSv2BuildInfo;
 import com.nokia.carbide.cpp.internal.builder.utils.Activator;
@@ -427,9 +430,10 @@
 		} else {
 			ISBSv2BuildInfo sbsv2BuildInfo = (ISBSv2BuildInfo)sdk.getBuildInfo(ISymbianBuilderID.SBSV2_BUILDER);
 			// platform macros
-			for (String platMacro : sbsv2BuildInfo.getPlatformMacros(buildConfig.getPlatformString())) {
-				macros.add("__" + platMacro + "__"); //$NON-NLS-1$ //$NON-NLS-2$
-			}
+			for (Iterator<String> it = sbsv2BuildInfo.getPlatformMacros(buildConfig.getPlatformString()).keySet().iterator(); it.hasNext(); ) { 
+				String platMacro = it.next();
+				macros.add(platMacro);
+			} 
 		}
 		
 		// built in macros
--- a/core/com.nokia.carbide.cpp.sdk.core.test/src/com/nokia/carbide/cpp/sdk/core/test/TestCarbideSDKCache.java	Mon Jun 28 10:14:24 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core.test/src/com/nokia/carbide/cpp/sdk/core/test/TestCarbideSDKCache.java	Thu Jul 01 16:36:11 2010 -0500
@@ -1,18 +1,21 @@
 package com.nokia.carbide.cpp.sdk.core.test;
 
 import java.io.File;
+import java.util.Map;
+
+import junit.framework.TestCase;
 
 import org.eclipse.core.runtime.jobs.IJobChangeEvent;
 import org.eclipse.core.runtime.jobs.IJobChangeListener;
 import org.eclipse.core.runtime.jobs.Job;
 import org.osgi.framework.Version;
 
+import com.nokia.carbide.cpp.internal.api.sdk.sbsv2.SBSv2QueryUtils;
 import com.nokia.carbide.cpp.internal.sdk.core.model.SDKManager;
 import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
+import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin;
 import com.nokia.carbide.cpp.sdk.core.SymbianSDKFactory;
 
-import junit.framework.TestCase;
-
 public class TestCarbideSDKCache extends TestCase {
 
 	private class TestSDKManager extends SDKManager {
@@ -92,6 +95,24 @@
 		assertTrue(manager.getCacheFile().lastModified() > orgTime);
 	}
 
+	public void testSBSv2QueryCache() throws Exception {
+		SBSv2QueryUtils.removeAllCachedQueries();
+		assertNull(SDKCorePlugin.getCache().getCache(SBSv2QueryUtils.ALIAS_CACHE_KEY));
+		assertNull(SDKCorePlugin.getCache().getCache(SBSv2QueryUtils.PRODUCT_CACHE_KEY));
+		assertNull(SDKCorePlugin.getCache().getCache(SBSv2QueryUtils.CONFIG_CACHE_KEY));
+		final TestSDKManager manager = new TestSDKManager();
+		manager.scanSDKs();
+		manager.getScanJob().join();
+		assertNotNull(SDKCorePlugin.getCache().getCachedData(SBSv2QueryUtils.ALIAS_CACHE_KEY, Map.class, 0));
+		assertNotNull(SDKCorePlugin.getCache().getCachedData(SBSv2QueryUtils.PRODUCT_CACHE_KEY, Map.class, 0));
+		assertNotNull(SDKCorePlugin.getCache().getCachedData(SBSv2QueryUtils.CONFIG_CACHE_KEY, Map.class, 0));
+		SDKCorePlugin.getCache().flushAll();
+		SBSv2QueryUtils.removeAllCachedQueries();
+		assertNotNull(SDKCorePlugin.getCache().getCachedData(SBSv2QueryUtils.ALIAS_CACHE_KEY, Map.class, 0));
+		assertNotNull(SDKCorePlugin.getCache().getCachedData(SBSv2QueryUtils.PRODUCT_CACHE_KEY, Map.class, 0));
+		assertNotNull(SDKCorePlugin.getCache().getCachedData(SBSv2QueryUtils.CONFIG_CACHE_KEY, Map.class, 0));
+	}
+
 	private void waitASecond() {
 		try {
 			Thread.sleep(1000);
--- a/core/com.nokia.carbide.cpp.sdk.core/META-INF/MANIFEST.MF	Mon Jun 28 10:14:24 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/META-INF/MANIFEST.MF	Thu Jul 01 16:36:11 2010 -0500
@@ -17,7 +17,7 @@
  com.nokia.cpp.utils.ui
 Bundle-ActivationPolicy: lazy
 Export-Package: com.nokia.carbide.cpp.internal.api.sdk;x-friends:="com.nokia.carbide.cpp.sdk.core.test",
- com.nokia.carbide.cpp.internal.api.sdk.sbsv2;x-friends:="com.nokia.carbide.cdt.builder.test",
+ com.nokia.carbide.cpp.internal.api.sdk.sbsv2;x-friends:="com.nokia.carbide.cdt.builder.test,com.nokia.carbide.cpp.sdk.core.test",
  com.nokia.carbide.cpp.internal.sdk.core.gen.Devices;x-friends:="com.nokia.carbide.cpp.sdk.core.test,com.nokia.carbide.cpp.sdk.ui",
  com.nokia.carbide.cpp.internal.sdk.core.gen.Devices.impl;x-friends:="com.nokia.carbide.cpp.sdk.core.test",
  com.nokia.carbide.cpp.internal.sdk.core.gen.Devices.util;x-friends:="com.nokia.carbide.cpp.sdk.core.test",
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/BuildContextSBSv2.java	Mon Jun 28 10:14:24 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/BuildContextSBSv2.java	Thu Jul 01 16:36:11 2010 -0500
@@ -1,68 +1,49 @@
 package com.nokia.carbide.cpp.internal.api.sdk;
 
 import java.io.File;
-import java.io.StringReader;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
 import org.osgi.framework.Version;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.helpers.DefaultHandler;
 
 import com.nokia.carbide.cpp.epoc.engine.preprocessor.IDefine;
-import com.nokia.carbide.cpp.internal.sdk.core.model.SBSv2BuildInfo;
-import com.nokia.carbide.cpp.internal.sdk.core.model.SymbianSDK;
 import com.nokia.carbide.cpp.sdk.core.IRVCTToolChainInfo;
 import com.nokia.carbide.cpp.sdk.core.ISBSv2BuildContext;
+import com.nokia.carbide.cpp.sdk.core.ISBSv2ConfigQueryData;
 import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext;
-import com.nokia.carbide.cpp.sdk.core.ISymbianBuilderID;
 import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
 import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin;
 import com.nokia.cpp.internal.api.utils.core.Check;
-import com.nokia.cpp.internal.api.utils.core.Logging;
 
 public class BuildContextSBSv2 implements ISBSv2BuildContext {
 	
 	private String platform;
 	private String target;
 	private String sbsv2Alias;
-	private String meaning;
 	private ISymbianSDK sdk;
 	private String displayString;
 	private String configID;  // cconfiguration 'id' attribute from .cproject
 	
 	// Raptor config query data
-	private String outputPathString;
-	private List<String> metaDataMacros = new ArrayList<String>();  // macros to parse the INF/MMPs files (these do not contain values)
-	private List<String> metaDataIncludes = new ArrayList<String>();
-	private String metaDataVariantHRH;
-	private String configParseErrorMessage = null;
+	private ISBSv2ConfigQueryData configQueryData;
 	
-	public BuildContextSBSv2(ISymbianSDK theSDK, String thePlatform, String theTarget, String theSBSv2Alias, String displayName, String configID) {
-		this.sdk = theSDK;
-		this.platform = thePlatform.toUpperCase();
-		this.target = theTarget.toUpperCase();
-		this.sbsv2Alias = theSBSv2Alias;
-		this.displayString = displayName;
+	public BuildContextSBSv2(ISymbianSDK sdk, String platform, String target, String alias, String displayString, String configID) {
+		this.sdk = sdk;
+		this.platform = platform.toUpperCase();
+		this.target = target.toUpperCase();
+		this.sbsv2Alias = alias;
+		this.displayString = displayString;
 		this.configID = configID;
 	}
 
-	public BuildContextSBSv2(ISymbianSDK sdk, String alias, String meaning, String contextQueryXML) {
+	public BuildContextSBSv2(ISymbianSDK sdk, String alias, ISBSv2ConfigQueryData configData) {
 		this.sdk = sdk;
 		this.sbsv2Alias = alias;
-		this.meaning = meaning;
+		this.configQueryData = configData;
+		setPlatformAndTargetFromOutputPath();
 		this.configID = ISBSv2BuildContext.BUILDER_ID + "." + sbsv2Alias + "." + sdk.getUniqueId();
-		parseQueryConfigResults(contextQueryXML);
 		this.displayString = sbsv2Alias + " [" + sdk.getUniqueId() + "]"; 
 	}
 
@@ -75,7 +56,7 @@
 	public String getPlatformString() {
 		
 		if (platform == null){
-			return configParseErrorMessage;
+			return configQueryData.getConfigurationErrorMessage();
 		}
 		
 		if (platform.contains(".")){
@@ -92,7 +73,7 @@
 	@Override
 	public String getTargetString() {
 		if (target == null){
-			return configParseErrorMessage;
+			return configQueryData.getConfigurationErrorMessage();
 		}
 		return target;
 	}
@@ -107,15 +88,6 @@
 		return displayString;
 	}
 
-	private ISBSv2BuildInfo getBuildInfo() {
-		ISBSv2BuildInfo buildInfo = (ISBSv2BuildInfo)getSDK().getBuildInfo(ISymbianBuilderID.SBSV2_BUILDER);
-		if (buildInfo == null) {
-			buildInfo = new SBSv2BuildInfo(getSDK());
-			((SymbianSDK)getSDK()).setBuildInfo(buildInfo, ISymbianBuilderID.SBSV2_BUILDER);
-		}
-		return buildInfo;
-	}
-
 	@Override
 	public String toString() {
 		return getConfigID();
@@ -235,24 +207,6 @@
 		return false;
 	}
 	
-	/**
-	 * See if the build configuration is an SBSv2 alias, and if so get the build-able alias name 
-	 * @param displayName
-	 * @return The full SBSv2 alias that can be used with -c, otherwise null if not SBSv2
-	 */
-	private static String getSBSv2AliasFromConfigName(String displayName) {
-		int indexBegin = displayName.indexOf("(");  //$NON-NLS-1$
-		int indexEnd = displayName.indexOf(")");  //$NON-NLS-1$
-		if (indexBegin > 0 && indexEnd > 0){
-			String configPart =  displayName.substring(indexBegin+1, indexEnd);
-			if (configPart.split("_").length > 1){
-				return configPart;
-			}
-		} 
-		
-		return null;
-	}
-
 	@Override
 	public String getSBSv2Alias() {
 		return sbsv2Alias;
@@ -359,87 +313,10 @@
 		}
 	}
 	
-	
-	private void parseQueryConfigResults(String queryResult) {
+	private void setPlatformAndTargetFromOutputPath() {
+		if (configQueryData.getOutputPathString() == null) return;
 		
-		try {
-    		Element root = null;
-    		DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
-    		parser.setErrorHandler(new DefaultHandler());
-    		
-    		StringReader reader = new StringReader( queryResult );
-    		InputSource inputSource = new InputSource( reader );
-    		root = parser.parse(inputSource).getDocumentElement();
-    		
-    		NodeList children = root.getChildNodes();
-    		for (int i=0; i< children.getLength(); i++) {
-    			Node configNode = children.item(i);
-    			if (configNode.getNodeName().equals("config")){
-    				NamedNodeMap aliasAttribs = configNode.getAttributes();
-    				String dottedName = aliasAttribs.getNamedItem("meaning").getNodeValue();
-    				if (!dottedName.equalsIgnoreCase(meaning)){
-    					continue;
-    				}
-    				if (configNode.getTextContent() != null&& configNode.getTextContent().length() > 0){
-    					// The config failed, likely due to envrionment set up issue.
-    					// Save the error message
-    					configParseErrorMessage = configNode.getTextContent();
-    					break;
-    				}
-    				
-    				String outputpath = aliasAttribs.getNamedItem("outputpath").getNodeValue();
-    				if (outputpath != null){
-    					outputPathString = outputpath;
-    				}
-    				
-    				// get <metadata>
-    				NodeList configChillens = configNode.getChildNodes();
-    				for (int ii = 0; ii < configChillens.getLength(); ii++){
-    					Node metaDataNode = configChillens.item(ii);
-    					if (metaDataNode.getNodeName().equals("metadata")){
-    						NodeList metaDataChillens = metaDataNode.getChildNodes();
-    						for (int iii = 0; iii < metaDataChillens.getLength(); iii++){
-    							Node metaChild = metaDataChillens.item(iii);
-    							NamedNodeMap attribs = metaChild.getAttributes();
-    							try {
-									if (metaChild.getNodeName().equals("macro")){
-										String name = attribs.getNamedItem("name").getNodeValue();
-										metaDataMacros.add(name);
-									} else if (metaChild.getNodeName().equals("include")){
-										String path = attribs.getNamedItem("path").getNodeValue();
-										metaDataIncludes.add(path);
-									} else if (metaChild.getNodeName().equals("preinclude")){
-										metaDataVariantHRH = attribs.getNamedItem("file").getNodeValue();
-									}
-								} catch (Exception e) {
-									// skip it
-									e.printStackTrace();
-								}
-    						}
-    						
-    					} else if (metaDataNode.getNodeName().equals("compilerinfo")){
-    						// TODO: Placeholder for future cpp preprocessor macros and compiler prefix
-    						// Not sure what it will be called yet.
-    					}
-    				}
-    				
-    				break;
-    			}
-    		}
-    		
-    	} catch (Exception e) {
-    		e.printStackTrace();
-    		Logging.log(SDKCorePlugin.getDefault(), Logging.newStatus(SDKCorePlugin.getDefault(), e));
-    	}
-    	
-    	setPlatformAndTargetFromOutputPath();
-		
-	}
-
-	private void setPlatformAndTargetFromOutputPath() {
-		if (outputPathString == null) return;
-		
-		IPath releasePath = new Path(outputPathString);
+		IPath releasePath = new Path(configQueryData.getOutputPathString());
 		int epoc32SegmentIndex = 0;
 		for (String segment : releasePath.segments()){
 			if (segment.toLowerCase().equals("epoc32"))
@@ -451,23 +328,8 @@
 		target = releasePath.segment(epoc32SegmentIndex+3);
 	}
 
-	/**
-	 * Error message, if any.
-	 * @return An error message if a problem occurred while trying to get config info from Raptor. Null if no error.
-	 */
-	@Override
-	public String getConfigurationErrorMessage(){
-		return configParseErrorMessage;
-	}
-
-	@Override
-	public List<String> getMetaDataMacros() {
-		return metaDataMacros;
-	}
-
-	@Override
-	public String getmetaDataVariantHRH() {
-		return metaDataVariantHRH;
+	public ISBSv2ConfigQueryData getConfigQueryData() {
+		return configQueryData;
 	}
 
 }
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/ISBSv2BuildInfo.java	Mon Jun 28 10:14:24 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/ISBSv2BuildInfo.java	Thu Jul 01 16:36:11 2010 -0500
@@ -14,6 +14,7 @@
 package com.nokia.carbide.cpp.internal.api.sdk;
 
 import java.util.List;
+import java.util.Map;
 
 import org.eclipse.core.runtime.IPath;
 
@@ -34,9 +35,9 @@
 	 * These are the macros that can be used in MMP and INF files. They are only given by name (no value)
 	 * </p>
 	 * @param platform the platform name
-	 * @return a list of macros, which may be empty.
+	 * @return a map of macros and values, which may be empty.
 	 */
-	List<String> getPlatformMacros(String platform);
+	Map<String, String> getPlatformMacros(String platform);
 
 	/**
 	 * Get the full path to the prefix file defined under \epoc32\tools\variant\variant.cfg
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/sbsv2/SBSv2ConfigQueryData.java	Thu Jul 01 16:36:11 2010 -0500
@@ -0,0 +1,164 @@
+package com.nokia.carbide.cpp.internal.api.sdk.sbsv2;
+
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.helpers.DefaultHandler;
+
+import com.nokia.carbide.cpp.sdk.core.ISBSv2ConfigQueryData;
+import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin;
+import com.nokia.cpp.internal.api.utils.core.Logging;
+
+public class SBSv2ConfigQueryData implements ISBSv2ConfigQueryData {
+
+	// Raptor config query data
+	private Map<String, String> buildMacros = new HashMap<String, String>(); // cpp preprocessor macros
+	private Map<String, String> metaDataMacros = new HashMap<String, String>();  // macros to parse the INF/MMPs files (these do not contain values)
+	private List<String> metaDataIncludes = new ArrayList<String>();
+	private String buildPrefix;
+	private String metaDataVariantHRH;
+	private String meaning;
+	private String outputPathString;
+	private String configurationErrorMessage = null;
+
+	public SBSv2ConfigQueryData(String meaning, String queryResult) {
+		this.meaning = meaning;
+		parseQueryConfigResults(queryResult);
+	}
+
+	public String getBuildPrefix() {
+		return buildPrefix;
+	}
+
+	public Map<String, String> getBuildMacros() {
+		return buildMacros;
+	}
+
+	public String getConfigurationErrorMessage() {
+		return configurationErrorMessage;
+	}
+
+	public Map<String, String> getMetaDataMacros() {
+		return metaDataMacros;
+	}
+
+	public List<String> getMetaDataIncludes() {
+		return metaDataIncludes;
+	}
+
+	public String getMetaDataVariantHRH() {
+		return metaDataVariantHRH;
+	}
+
+	public String getOutputPathString() {
+		return outputPathString;
+	}
+
+	private void parseQueryConfigResults(String queryResult) {
+		try {
+    		Element root = null;
+    		DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+    		parser.setErrorHandler(new DefaultHandler());
+    		
+    		StringReader reader = new StringReader( queryResult );
+    		InputSource inputSource = new InputSource( reader );
+    		root = parser.parse(inputSource).getDocumentElement();
+    		
+    		NodeList children = root.getChildNodes();
+    		for (int i=0; i< children.getLength(); i++) {
+    			Node configNode = children.item(i);
+    			if (configNode.getNodeName().equals("config")){
+    				NamedNodeMap aliasAttribs = configNode.getAttributes();
+    				String dottedName = aliasAttribs.getNamedItem("meaning").getNodeValue();
+    				if (!dottedName.equalsIgnoreCase(meaning)){
+    					continue;
+    				}
+    				if (configNode.getTextContent() != null&& configNode.getTextContent().length() > 0){
+    					// The config failed, likely due to envrionment set up issue.
+    					// Save the error message
+    					configurationErrorMessage = configNode.getTextContent();
+    					break;
+    				}
+    				
+    				String outputpath = aliasAttribs.getNamedItem("outputpath").getNodeValue();
+    				if (outputpath != null){
+    					outputPathString = outputpath;
+    				}
+    				
+    				NodeList configChillens = configNode.getChildNodes();
+    				for (int ii = 0; ii < configChillens.getLength(); ii++){
+    					Node dataNode = configChillens.item(ii);
+    					if (dataNode.getNodeName().equals("metadata")){
+    	    				// get <metadata>
+    						NodeList metaDataChillens = dataNode.getChildNodes();
+    						for (int iii = 0; iii < metaDataChillens.getLength(); iii++){
+    							Node metaChild = metaDataChillens.item(iii);
+    							NamedNodeMap attribs = metaChild.getAttributes();
+    							try {
+									if (metaChild.getNodeName().equals("macro")){
+										String name = attribs.getNamedItem("name").getNodeValue();
+										String value = "";
+										Node valueNode = attribs.getNamedItem("value");
+										if (valueNode != null) {
+											value = valueNode.getNodeValue();
+										}
+										metaDataMacros.put(name, value);
+									} else if (metaChild.getNodeName().equals("include")){
+										String path = attribs.getNamedItem("path").getNodeValue();
+										metaDataIncludes.add(path);
+									} else if (metaChild.getNodeName().equals("preinclude")){
+										metaDataVariantHRH = attribs.getNamedItem("file").getNodeValue();
+									}
+								} catch (Exception e) {
+									// skip it
+									e.printStackTrace();
+								}
+    						}
+    					} else if (dataNode.getNodeName().equals("build")){
+    	    				// get <build>
+    						NodeList buildChillens = dataNode.getChildNodes();
+    						for (int iii = 0; iii < buildChillens.getLength(); iii++){
+    							Node buildChild = buildChillens.item(iii);
+    							NamedNodeMap attribs = buildChild.getAttributes();
+    							try {
+									if (buildChild.getNodeName().equals("macro")){
+										String name = attribs.getNamedItem("name").getNodeValue();
+										String value = "";
+										Node valueNode = attribs.getNamedItem("value");
+										if (valueNode != null) {
+											value = valueNode.getNodeValue();
+										}
+										buildMacros.put(name, value);
+									} else if (buildChild.getNodeName().equals("preinclude")){
+										buildPrefix = attribs.getNamedItem("file").getNodeValue();
+									}
+								} catch (Exception e) {
+									// skip it
+									e.printStackTrace();
+								}
+    						}
+    					}
+    				}
+    				
+    				break;
+    			}
+    		}
+    		
+    	} catch (Exception e) {
+    		e.printStackTrace();
+    		Logging.log(SDKCorePlugin.getDefault(), Logging.newStatus(SDKCorePlugin.getDefault(), e));
+    	}
+	}
+
+}
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/sbsv2/SBSv2QueryUtils.java	Mon Jun 28 10:14:24 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/sbsv2/SBSv2QueryUtils.java	Thu Jul 01 16:36:11 2010 -0500
@@ -21,12 +21,14 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.io.Serializable;
 import java.io.StringReader;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Properties;
 
 import javax.xml.parsers.DocumentBuilder;
@@ -51,69 +53,82 @@
 
 public class SBSv2QueryUtils {
 
+	public static final String QUERY_ALIASES_COMMAND = "--query=aliases";
 	public static final String QUERY_PRODUCTS_COMMAND = "--query=products";
 	public static final String QUERY_CONFIG_COMMAND = "--query=config";
-	public static final String QUERY_COMMAND = "--query=aliases";
-	
-	public static HashMap<String, String> getAliasesForSDK(ISymbianSDK sdk) throws SBSv2MinimumVersionException{
-		
-		checkForMinimumRaptorVersion();
-		
-		List<String> argListAliasQuery = new ArrayList<String>();
-		argListAliasQuery.add(QUERY_COMMAND);
-		
-		Properties envVars = EnvironmentReader.getEnvVars();
-		if (sdk != null){
-			envVars.setProperty("EPOCROOT", sdk.getEPOCROOT());
-		} else {
-			envVars.setProperty("EPOCROOT", "FOOBAR");
+
+	public static final String ALIAS_CACHE_KEY = "alias_cache";
+	public static final String CONFIG_CACHE_KEY = "config_cache";
+	public static final String PRODUCT_CACHE_KEY = "product_cache";
+
+	public static final String BAD_EPOCROOT = "BADEPOCROOT";
+
+	@SuppressWarnings("unchecked")
+	public static HashMap<String, String> getAliasesForSDK(ISymbianSDK sdk) throws SBSv2MinimumVersionException {
+		HashMap<String, String> aliases;
+		Map<String, HashMap<String, String>> aliasesMap = SDKCorePlugin.getCache().getCachedData(ALIAS_CACHE_KEY, Map.class, 0);
+		SBSv2SDKKey key = new SBSv2SDKKey(sdk);
+
+		if (aliasesMap == null) {
+			aliasesMap = new HashMap<String, HashMap<String, String>>();
 		}
-		
-		String queryResult = getSBSQueryOutput(argListAliasQuery, createEnvStringList(envVars));
-		
-		return parseQueryAliasResult(queryResult);
-	}
-	
-	public static List<String> getProductVariantsForSDK(ISymbianSDK sdk) throws SBSv2MinimumVersionException{
-		
-		checkForMinimumRaptorVersion();
-		
-		List<String> argListProductQuery = new ArrayList<String>();
-		
-		Properties envVars = EnvironmentReader.getEnvVars();
-		if (sdk != null){
-			envVars.setProperty("EPOCROOT", sdk.getEPOCROOT());
-		} else {
-			envVars.setProperty("EPOCROOT", "FOOBAR");
-		}
-		
-		argListProductQuery.add(QUERY_PRODUCTS_COMMAND);
-		String queryResult = getSBSQueryOutput(argListProductQuery, createEnvStringList(envVars));
-		return parseQueryProductsResults(queryResult);
-	}
-	
-	public static String getConfigQueryXML(ISymbianSDK sdk, List<String> aliasOrMeaningArray) throws SBSv2MinimumVersionException{
-		
-		checkForMinimumRaptorVersion();
-		
-		List<String> argListConfigQuery = new ArrayList<String>();
-		
-		for (String alias : aliasOrMeaningArray){
-			argListConfigQuery.add(QUERY_CONFIG_COMMAND + "[" + alias + "]");
-		}
-		
-		Properties envVars = null;
-		if (sdk != null){
-			File epocRoot = new File(sdk.getEPOCROOT());
-			if (epocRoot.exists()){
-				envVars = EnvironmentReader.getEnvVars();
-				envVars.setProperty("EPOCROOT", sdk.getEPOCROOT());
+		else {
+			aliases = aliasesMap.get(key.toString());
+			if (aliases != null && !aliases.containsKey(BAD_EPOCROOT)) {
+				return aliases;
 			}
 		}
-		return getSBSQueryOutput(argListConfigQuery, createEnvStringList(envVars));
+
+		aliases = getAliasesQuery(sdk);
+		aliasesMap.put(key.toString(), aliases);
+		SDKCorePlugin.getCache().putCachedData(ALIAS_CACHE_KEY, (Serializable)aliasesMap, 0);
+		return aliases;
 	}
-	
-	
+
+	@SuppressWarnings("unchecked")
+	public static List<String> getProductVariantsForSDK(ISymbianSDK sdk) throws SBSv2MinimumVersionException {
+		List<String> products;
+		Map<String, List<String>> productsMap = SDKCorePlugin.getCache().getCachedData(PRODUCT_CACHE_KEY, Map.class, 0);
+		SBSv2SDKKey key = new SBSv2SDKKey(sdk);
+		
+		if (productsMap == null) {
+			productsMap = new HashMap<String, List<String>>();
+		}
+		else {
+			products = productsMap.get(key.toString());
+			if (products != null && !products.contains(BAD_EPOCROOT)) {
+				return products;
+			}
+		}
+
+		products = getProductsQuery(sdk);
+		productsMap.put(key.toString(), products);
+		SDKCorePlugin.getCache().putCachedData(PRODUCT_CACHE_KEY, (Serializable)productsMap, 0);
+		return products;
+	}
+
+	@SuppressWarnings("unchecked")
+	public static String getConfigQueryXMLforSDK(ISymbianSDK sdk, List<String> aliasOrMeaningArray) throws SBSv2MinimumVersionException {
+		String configs;
+		Map<String, String> configsMap = SDKCorePlugin.getCache().getCachedData(CONFIG_CACHE_KEY, Map.class, 0);
+		SBSv2SDKKey key = new SBSv2SDKKey(sdk);
+
+		if (configsMap == null) {
+			configsMap = new HashMap<String, String>();
+		}
+		else {
+			configs = configsMap.get(key.toString());
+			if (configs != null) {
+				return configs;
+			}
+		}
+
+		configs = getConfigurations(sdk, aliasOrMeaningArray);
+		configsMap.put(key.toString(), configs);
+		SDKCorePlugin.getCache().putCachedData(CONFIG_CACHE_KEY, (Serializable)configsMap, 0);
+		return configs;
+	}
+
 	public static HashMap<String, String> queryConfigTargetInfo(ISymbianSDK sdk, List<String> aliasOrMeaningArray) throws SBSv2MinimumVersionException{
 		
 		checkForMinimumRaptorVersion();
@@ -136,7 +151,7 @@
 		
 		return parseQueryConfigResults(queryResult);
 	}
-	
+
 	private static String[] createEnvStringList(Properties envProps) {
 		
 		if (envProps == null){
@@ -154,7 +169,75 @@
 		}
 		return env;
 	}
-	
+
+	private static HashMap<String, String> getAliasesQuery(ISymbianSDK sdk) throws SBSv2MinimumVersionException {
+		
+		checkForMinimumRaptorVersion();
+		if (!isEpocRootValid(sdk)) {
+			HashMap<String, String> result = new HashMap<String, String>();
+			result.put(BAD_EPOCROOT, "");
+			return result;
+		}
+		
+		List<String> argListAliasQuery = new ArrayList<String>();
+		argListAliasQuery.add(QUERY_ALIASES_COMMAND);
+		
+		Properties envVars = EnvironmentReader.getEnvVars();
+		if (sdk != null){
+			envVars.setProperty("EPOCROOT", sdk.getEPOCROOT());
+		} else {
+			envVars.setProperty("EPOCROOT", "FOOBAR");
+		}
+		
+		String queryResult = getSBSQueryOutput(argListAliasQuery, createEnvStringList(envVars));
+		
+		return parseQueryAliasResult(queryResult);
+	}
+
+	private static List<String> getProductsQuery(ISymbianSDK sdk) throws SBSv2MinimumVersionException {
+		
+		checkForMinimumRaptorVersion();
+		if (!isEpocRootValid(sdk)) {
+			List<String> result = new ArrayList<String>();
+			result.add(BAD_EPOCROOT);
+			return result;
+		}
+
+		List<String> argListProductQuery = new ArrayList<String>();
+		argListProductQuery.add(QUERY_PRODUCTS_COMMAND);
+		
+		Properties envVars = EnvironmentReader.getEnvVars();
+		if (sdk != null){
+			envVars.setProperty("EPOCROOT", sdk.getEPOCROOT());
+		} else {
+			envVars.setProperty("EPOCROOT", "FOOBAR");
+		}
+		
+		String queryResult = getSBSQueryOutput(argListProductQuery, createEnvStringList(envVars));
+		return parseQueryProductsResults(queryResult);
+	}
+
+	private static String getConfigurations(ISymbianSDK sdk, List<String> aliasOrMeaningArray) throws SBSv2MinimumVersionException {
+		
+		checkForMinimumRaptorVersion();
+		
+		List<String> argListConfigQuery = new ArrayList<String>();
+		for (String alias : aliasOrMeaningArray){
+			argListConfigQuery.add(QUERY_CONFIG_COMMAND + "[" + alias + "]");
+		}
+		
+		Properties envVars = null;
+		if (sdk != null){
+			File epocRoot = new File(sdk.getEPOCROOT());
+			if (epocRoot.exists()){
+				envVars = EnvironmentReader.getEnvVars();
+				envVars.setProperty("EPOCROOT", sdk.getEPOCROOT());
+			}
+		}
+
+		return getSBSQueryOutput(argListConfigQuery, createEnvStringList(envVars));
+	}
+
 	private static String getSBSQueryOutput(List<String> queryCommandList, String[] env) {
 		String overallOutput = "";
 		
@@ -210,7 +293,18 @@
 
 		return overallOutput;
 	}
-	
+
+	private static Boolean isEpocRootValid(ISymbianSDK sdk) {
+		IPath epocRoot = new Path(sdk.getEPOCROOT());
+		epocRoot = epocRoot.append("epoc32");
+		File epocRootFile = epocRoot.toFile();
+		if (epocRootFile.exists()) {
+			return true;
+		} else {
+			return false;
+		}
+	}
+
 	private static HashMap<String, String> parseQueryAliasResult(String queryResult) {
 		/* Alias to dotted name config */
 		HashMap<String, String> sbsAliasMap = new HashMap<String, String>();
@@ -278,7 +372,7 @@
 		
 		return sbsAliasMap;
 	}
-	
+
 	private static List<String> parseQueryProductsResults(String queryResult) {
 		List<String> productList = new ArrayList<String>();
 		
@@ -323,11 +417,14 @@
 		HashMap<String, String> resultMap = new HashMap<String, String>();
 		
 		// iterate all SDKs and build the map up
-		for (ISymbianSDK sdk : SDKCorePlugin.getSDKManager().getSDKList()){
-			if (sdk.isEnabled() && (new File(sdk.getEPOCROOT()).exists())){
+		for (ISymbianSDK sdk : SDKCorePlugin.getSDKManager().getSDKList()) {
+			if (sdk.isEnabled() && isEpocRootValid(sdk)) {
 				HashMap<String, String> aliasMap = getAliasesForSDK(sdk);
-				for (String alias : aliasMap.keySet()){
-					if (resultMap.get(alias) == null){
+				for (String alias : aliasMap.keySet()) {
+					if (alias.equals(BAD_EPOCROOT)) {
+						continue;
+					}
+					if (resultMap.get(alias) == null) {
 						resultMap.put(alias, aliasMap.get(alias));
 					}
 				}
@@ -336,16 +433,19 @@
 		
 		return resultMap;
 	}
-	
+
 	public static List<String> getCompleteProductVariantList() throws SBSv2MinimumVersionException {
 		List<String> resultList = new ArrayList<String>();
 		
 		// iterate all SDKs and build the map up
-		for (ISymbianSDK sdk : SDKCorePlugin.getSDKManager().getSDKList()){
-			if (sdk.isEnabled() && (new File(sdk.getEPOCROOT()).exists())){
+		for (ISymbianSDK sdk : SDKCorePlugin.getSDKManager().getSDKList()) {
+			if (sdk.isEnabled() && isEpocRootValid(sdk)) {
 				List<String> productList = getProductVariantsForSDK(sdk);
-				for (String variant : productList){
-					if (!resultList.contains(variant)){
+				for (String variant : productList) {
+					if (variant.equals(BAD_EPOCROOT)) {
+						continue;
+					}
+					if (!resultList.contains(variant)) {
 						resultList.add(variant);
 					}
 				}
@@ -354,5 +454,23 @@
 		
 		return resultList;
 	}
-	
+
+	public static void removeAllCachedQueries() {
+		removeCachedAliases();
+		removeCachedProducts();
+		removeCachedConfigurations();
+	}
+
+	public static void removeCachedAliases() {
+		SDKCorePlugin.getCache().removeCache(ALIAS_CACHE_KEY);
+	}
+
+	public static void removeCachedProducts() {
+		SDKCorePlugin.getCache().removeCache(PRODUCT_CACHE_KEY);		
+	}
+
+	public static void removeCachedConfigurations() {
+		SDKCorePlugin.getCache().removeCache(CONFIG_CACHE_KEY);
+	}
+
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/sbsv2/SBSv2SDKKey.java	Thu Jul 01 16:36:11 2010 -0500
@@ -0,0 +1,95 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+* Test the BldInfViewPathHelper class.
+*
+*/
+
+package com.nokia.carbide.cpp.internal.api.sdk.sbsv2;
+
+import java.io.Serializable;
+
+import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
+
+public class SBSv2SDKKey implements Serializable {
+
+	private static final long serialVersionUID = -5672527971643437442L;
+
+	private String uniqueId;
+	private String epocRoot;
+
+	public SBSv2SDKKey() {
+		uniqueId = "";
+		epocRoot = "";
+	}
+
+	public SBSv2SDKKey(ISymbianSDK sdk) {
+		uniqueId = sdk.getUniqueId();
+		epocRoot = sdk.getEPOCROOT();
+	}
+
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (obj == null)
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		SBSv2SDKKey other = (SBSv2SDKKey) obj;
+		if (epocRoot == null) {
+			if (other.epocRoot != null)
+				return false;
+		} else if (!epocRoot.equals(other.epocRoot))
+			return false;
+		if (uniqueId == null) {
+			if (other.uniqueId != null)
+				return false;
+		} else if (!uniqueId.equals(other.uniqueId))
+			return false;
+		return true;
+	}
+
+	public String getUniqueId() {
+		return uniqueId;
+	}
+
+	public String getEpocRoot() {
+		return epocRoot;
+	}
+
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result
+				+ ((epocRoot == null) ? 0 : epocRoot.hashCode());
+		result = prime * result
+				+ ((uniqueId == null) ? 0 : uniqueId.hashCode());
+		return result;
+	}
+
+	public void setUniqueId(String id) {
+		uniqueId = id;
+	}
+
+	public void setEpocRoot(String root) {
+		epocRoot = root;
+	}
+
+	@Override
+	public String toString() {
+		return "SBSv2SDKKey [uniqueId=" + uniqueId + ", epocRoot=" + epocRoot
+				+ "]";
+	}
+
+}
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/AbstractSDKManager.java	Mon Jun 28 10:14:24 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/AbstractSDKManager.java	Thu Jul 01 16:36:11 2010 -0500
@@ -64,6 +64,7 @@
 import com.nokia.carbide.cpp.internal.api.sdk.SDKManagerInternalAPI;
 import com.nokia.carbide.cpp.internal.api.sdk.SymbianBuildContextDataCache;
 import com.nokia.carbide.cpp.internal.api.sdk.SymbianMacroStore;
+import com.nokia.carbide.cpp.internal.api.sdk.sbsv2.SBSv2QueryUtils;
 import com.nokia.carbide.cpp.sdk.core.ICarbideInstalledSDKChangeListener;
 import com.nokia.carbide.cpp.sdk.core.ICarbideInstalledSDKChangeListener.SDKChangeEventType;
 import com.nokia.carbide.cpp.sdk.core.IRVCTToolChainInfo;
@@ -160,6 +161,7 @@
 	}
 	
 	public void scanSDKs() {
+		SBSv2QueryUtils.removeAllCachedQueries();
 		// do the real sdk scanning in a job.
 		if (scanJob.getState() == Job.NONE) {
 			scanJob.schedule();
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBSv2BuildInfo.java	Mon Jun 28 10:14:24 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBSv2BuildInfo.java	Thu Jul 01 16:36:11 2010 -0500
@@ -28,9 +28,11 @@
 import com.nokia.carbide.cpp.internal.api.sdk.BuildContextSBSv2;
 import com.nokia.carbide.cpp.internal.api.sdk.ISBSv2BuildInfo;
 import com.nokia.carbide.cpp.internal.api.sdk.SBSv2Utils;
+import com.nokia.carbide.cpp.internal.api.sdk.sbsv2.SBSv2ConfigQueryData;
 import com.nokia.carbide.cpp.internal.api.sdk.sbsv2.SBSv2MinimumVersionException;
 import com.nokia.carbide.cpp.internal.api.sdk.sbsv2.SBSv2QueryUtils;
 import com.nokia.carbide.cpp.sdk.core.ISBSv2BuildContext;
+import com.nokia.carbide.cpp.sdk.core.ISBSv2ConfigQueryData;
 import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext;
 import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
 import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin;
@@ -46,7 +48,7 @@
 	private ISymbianSDK sdk;
 	private List<ISymbianBuildContext> sbsv2FilteredConetxts = new ArrayList<ISymbianBuildContext>();
 	private boolean wasScanned = false;
-	private Map<String, List<String>> cachedPlatformMacros = new HashMap<String, List<String>>();
+	private Map<String, Map<String, String>> cachedPlatformMacros = new HashMap<String, Map<String, String>>();
 
 	private Map<String, String> aliasToMeaningMap = new HashMap<String, String>();
 	private List<String> productList = null;
@@ -145,7 +147,7 @@
 		
 		String configQueryXML = "";
 		try {
-			configQueryXML = SBSv2QueryUtils.getConfigQueryXML(sdk, newContextsToQuery);
+			configQueryXML = SBSv2QueryUtils.getConfigQueryXMLforSDK(sdk, newContextsToQuery);
 		} catch (SBSv2MinimumVersionException e) {
 			// ignore, previous exception would have caught the error
 		}
@@ -154,7 +156,8 @@
 			if (aliasToMeaningMap.get(alias) == null){
 				continue; // This alias is not valid with this SDK, ignore
 			}
-			ISBSv2BuildContext sbsv2Context = new BuildContextSBSv2(sdk, alias, aliasToMeaningMap.get(alias), configQueryXML);
+			ISBSv2ConfigQueryData configQueryData = new SBSv2ConfigQueryData(aliasToMeaningMap.get(alias), configQueryXML);
+			ISBSv2BuildContext sbsv2Context = new BuildContextSBSv2(sdk, alias, configQueryData);
 			sbsv2FilteredConetxts.add(sbsv2Context);
 		}
 		
@@ -186,21 +189,20 @@
 			}
 		}
 		
-		String configQueryXML = SBSv2QueryUtils.getConfigQueryXML(sdk,
-				filteredAliasList);
+		String configQueryXML = SBSv2QueryUtils.getConfigQueryXMLforSDK(sdk, filteredAliasList);
 
 		for (String alias : filteredAliasList) {
 			String meaning = "";
 			if (alias.contains(".")){
 				meaning = getMeaningForVariant(alias);
-				if (meaning == null){
-					continue; // TODO: How to handle this scenaio
-				}
 			} else {
 				meaning = aliasToMeaningMap.get(alias);
 			}
-			ISBSv2BuildContext sbsv2Context = new BuildContextSBSv2(sdk, alias,
-					meaning, configQueryXML);
+			if (meaning == null){
+				continue; // TODO: How to handle this scenario
+			}
+			ISBSv2ConfigQueryData configQueryData = new SBSv2ConfigQueryData(meaning, configQueryXML);
+			ISBSv2BuildContext sbsv2Context = new BuildContextSBSv2(sdk, alias, configQueryData);
 			sbsv2FilteredConetxts.add(sbsv2Context);
 		}
 	}
@@ -220,10 +222,10 @@
 		return meaning;
 	}
 
-	public List<String> getPlatformMacros(String platform) {
-		List<String> platformMacros = cachedPlatformMacros.get(platform.toUpperCase());
+	public Map<String, String> getPlatformMacros(String platform) {
+		Map<String, String> platformMacros = cachedPlatformMacros.get(platform.toUpperCase());
 		if (platformMacros == null) {
-			platformMacros = new ArrayList<String>();
+			platformMacros = new HashMap<String, String>();
 			synchronized (cachedPlatformMacros) {
 				if (sbsv2FilteredConetxts == null || sbsv2FilteredConetxts.size() == 0) {
 					getFilteredBuildConfigurations();
@@ -231,12 +233,8 @@
 				if (sbsv2FilteredConetxts.size() > 0) {
 					for (ISymbianBuildContext context : sbsv2FilteredConetxts) {
 						if (context.getPlatformString().equalsIgnoreCase(platform)) {
-							List<String> macros = ((ISBSv2BuildContext)context).getMetaDataMacros();
-							for (String macro : macros) {
-								if (!platformMacros.contains(macro)) {
-									platformMacros.add(macro);
-								}
-							}
+							platformMacros.putAll(((ISBSv2BuildContext)context).getConfigQueryData().getBuildMacros());
+							platformMacros.putAll(((ISBSv2BuildContext)context).getConfigQueryData().getMetaDataMacros());
 						}
 					}
 					cachedPlatformMacros.put(platform.toUpperCase(), platformMacros);
@@ -257,7 +255,7 @@
 			}
 			if (sbsv2FilteredConetxts.size() > 0) {
 				for (ISymbianBuildContext context : sbsv2FilteredConetxts) {
-					String vStr = ((ISBSv2BuildContext)context).getmetaDataVariantHRH();
+					String vStr = ((ISBSv2BuildContext)context).getConfigQueryData().getMetaDataVariantHRH();
 					if (vStr != null) {
 						cachedVariantHRHFile = new Path(vStr);
 						break;
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SDKManager.java	Mon Jun 28 10:14:24 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SDKManager.java	Thu Jul 01 16:36:11 2010 -0500
@@ -356,27 +356,23 @@
 					e.printStackTrace();
 				}
 				
-				if (localSDKList.size() != sdkList.size()){
-					needsRescan = true;
-				} else {
-					for (ISymbianSDK sdk : localSDKList){
-						ISymbianSDK currSDK = getSDK(sdk.getUniqueId(), false);
-						if (currSDK == null){
-							// sdk id has been changed
-							needsRescan = true;
-							break;
-						}
-						// check that the data are the same.
-						// Other than the 'id' attrib, all we really care is whether or not
-						// the EPOCROOT or vendor 'name' has changed.
-						if (!sdk.getEPOCROOT().equalsIgnoreCase(currSDK.getEPOCROOT())){
-							needsRescan = true;
-							break;
-						}
-						if (!sdk.getName().equalsIgnoreCase(currSDK.getName())){
-							needsRescan = true;
-							break;
-						}
+				for (ISymbianSDK sdk : localSDKList){
+					ISymbianSDK currSDK = getSDK(sdk.getUniqueId(), false);
+					if (currSDK == null){
+						// sdk id has been changed
+						needsRescan = true;
+						break;
+					}
+					// check that the data are the same.
+					// Other than the 'id' attrib, all we really care is whether or not
+					// the EPOCROOT or vendor 'name' has changed.
+					if (!sdk.getEPOCROOT().equalsIgnoreCase(currSDK.getEPOCROOT())){
+						needsRescan = true;
+						break;
+					}
+					if (!sdk.getName().equalsIgnoreCase(currSDK.getName())){
+						needsRescan = true;
+						break;
 					}
 				}
 				
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISBSv2BuildContext.java	Mon Jun 28 10:14:24 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISBSv2BuildContext.java	Thu Jul 01 16:36:11 2010 -0500
@@ -1,6 +1,5 @@
 package com.nokia.carbide.cpp.sdk.core;
 
-import java.util.List;
 
 public interface ISBSv2BuildContext extends ISymbianBuildContext {
 	
@@ -29,9 +28,5 @@
 	 */
 	public String getDefaultDefFileDirectoryName();
 	
-	public String getConfigurationErrorMessage();
-	
-	public List<String> getMetaDataMacros();
-	
-	public String getmetaDataVariantHRH();
+	public ISBSv2ConfigQueryData getConfigQueryData();
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISBSv2ConfigQueryData.java	Thu Jul 01 16:36:11 2010 -0500
@@ -0,0 +1,14 @@
+package com.nokia.carbide.cpp.sdk.core;
+
+import java.util.List;
+import java.util.Map;
+
+public interface ISBSv2ConfigQueryData {
+	public String getBuildPrefix();
+	public Map<String, String> getBuildMacros();
+	public String getConfigurationErrorMessage();
+	public Map<String, String> getMetaDataMacros();
+	public List<String> getMetaDataIncludes();
+	public String getMetaDataVariantHRH();
+	public String getOutputPathString();
+}
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/SDKCorePlugin.java	Mon Jun 28 10:14:24 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/SDKCorePlugin.java	Thu Jul 01 16:36:11 2010 -0500
@@ -12,12 +12,15 @@
 */
 package com.nokia.carbide.cpp.sdk.core;
 
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Plugin;
 import org.osgi.framework.BundleContext;
 
 import com.nokia.carbide.cpp.internal.sdk.core.model.SDKManager;
 import com.nokia.carbide.cpp.internal.sdk.core.model.SDKManagerRaptorOnly;
 import com.nokia.cpp.internal.api.utils.core.HostOS;
+import com.nokia.cpp.internal.api.utils.core.CacheUtils;
 
 
 /**
@@ -31,11 +34,15 @@
 	// The plug-in ID
 	public static final String PLUGIN_ID = "com.nokia.carbide.cpp.sdk.core"; //$NON-NLS-1$
 
+	public static final String CACHE_FOLDER_NAME = "CarbideSDKCache"; //$NON-NLS-1$
+
 	// The shared instance
 	private static SDKCorePlugin plugin;
 	
 	private static ISDKManager sdkManager;
 	
+	private static CacheUtils cache;
+	
 	/**
 	 * The constructor
 	 */
@@ -56,6 +63,12 @@
 	 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
 	 */
 	public void stop(BundleContext context) throws Exception {
+		try {
+			if (cache != null)
+				cache.flushAll();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
 		plugin = null;
 		super.stop(context);
 	}
@@ -89,4 +102,17 @@
 		return sdkManager;
 	}
 	
+	/**
+	 * Get the persistent cache this plugin.
+	 * @return PersistentCache instance
+	 */
+	public static CacheUtils getCache() {
+		if (cache == null)
+		{
+			IPath path = new Path(System.getProperty("user.home"));
+			cache = new CacheUtils(path.append(CACHE_FOLDER_NAME));
+		}
+		return cache;
+	}
+
 }
--- a/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/sdk/ui/shared/BuildTargetTreeNode.java	Mon Jun 28 10:14:24 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/sdk/ui/shared/BuildTargetTreeNode.java	Thu Jul 01 16:36:11 2010 -0500
@@ -75,8 +75,9 @@
 					String newDisplayString = context.getDisplayString().replace("[" + sdkId + "]", "");
 					if (context instanceof ISBSv2BuildContext){
 						ISBSv2BuildContext v2Context = (ISBSv2BuildContext)context;
-						if (v2Context.getConfigurationErrorMessage() != null && v2Context.getConfigurationErrorMessage().length() > 0){
-							newDisplayString += " ERROR: " + v2Context.getConfigurationErrorMessage();
+						if (v2Context.getConfigQueryData().getConfigurationErrorMessage() != null && 
+							v2Context.getConfigQueryData().getConfigurationErrorMessage().length() > 0){
+							newDisplayString += " ERROR: " + v2Context.getConfigQueryData().getConfigurationErrorMessage();
 						}
 					} 
 					return newDisplayString;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.cpp.utils.core/src/com/nokia/cpp/internal/api/utils/core/CacheUtils.java	Thu Jul 01 16:36:11 2010 -0500
@@ -0,0 +1,179 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Nokia and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nokia - Initial API and implementation
+ *******************************************************************************/
+
+package com.nokia.cpp.internal.api.utils.core;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IPath;
+
+import com.nokia.cpp.utils.core.noexport.UtilsCorePlugin;
+
+public class CacheUtils {
+
+	private class CacheEntry {
+
+		private String identifier;
+		private long freshness;
+		private Serializable data;
+		private IPath location;
+
+		public CacheEntry(String identifier, Serializable data, long freshness) {
+			this.identifier = identifier;
+			this.freshness = freshness;
+			this.data = data;
+			this.location = getDefaultLocation().append(Integer.toString(identifier.hashCode())).addFileExtension("txt");;
+		}
+
+		public CacheEntry(ObjectInputStream ois) throws Exception {		
+			this.identifier = (String) ois.readObject();
+			this.freshness = (Long) ois.readObject();
+			this.data = (Serializable) ois.readObject();		
+			this.location = getDefaultLocation().append(Integer.toString(identifier.hashCode())).addFileExtension("txt");;
+		}
+		
+		public IPath getLocation() {
+			return location;
+		}
+
+		@SuppressWarnings("unchecked")
+		private <T> T getData(Class<T> expectedClass) {
+			if (expectedClass.isInstance(data))
+				return (T) data;
+			else
+				return null;
+		}
+
+		private long getFreshness() {
+			return freshness;
+		}
+
+		private void flush() throws Exception {
+			File cacheFile = getLocation().toFile();
+			if (!cacheFile.exists()) {
+				cacheFile.getParentFile().mkdirs();
+				cacheFile.createNewFile();
+			}
+			FileOutputStream fos = new FileOutputStream(cacheFile);
+			ObjectOutputStream oos = new ObjectOutputStream(fos);
+			oos.writeObject(identifier);
+			oos.writeObject(freshness);
+			oos.writeObject(data);
+			fos.close();
+		}
+
+		public void delete() {
+			File cacheFile = getLocation().toFile();
+			if (cacheFile.exists()) {
+				cacheFile.delete();
+			}
+		}
+		
+	}
+	
+	private Map<String, CacheEntry> caches = Collections.synchronizedMap(new HashMap<String, CacheEntry>());
+	private IPath defaultLocation;
+
+	public CacheUtils(IPath defaultLocation) {
+		this.defaultLocation = defaultLocation;
+	}
+
+	public CacheEntry getCache(String identifier) {
+		CacheEntry result = caches.get(identifier);
+		return result;		
+	}
+
+	public void removeCache(String identifier) {
+		caches.remove(identifier);
+	}
+
+	public <T> T getCachedData(String cacheIdentifier, Class<T> expectedClass, long freshness) {
+	// 	freshness  = 0;
+		CacheEntry cache = caches.get(cacheIdentifier);
+		
+		if (cache == null)
+			cache = loadCachedData(getDefaultLocation(), cacheIdentifier);
+		
+		if (cache != null) {
+			long cachedFreshness = cache.getFreshness();
+			T result = cache.getData(expectedClass);
+			if (cachedFreshness == freshness && result != null)
+			{
+				return result;
+			}
+			else
+			{
+				caches.remove(cache);
+				cache.delete();
+			}
+		}		
+		return null;
+	}
+
+	private CacheEntry loadCachedData(IPath location, String cacheIdentifier) {
+		IPath flushPath = location.append(Integer.toString(cacheIdentifier.hashCode())).addFileExtension("txt");
+
+		if (flushPath.toFile().exists()) {
+			try {
+				final ClassLoader classLoader = UtilsCorePlugin.getDefault().getClass().getClassLoader();
+				FileInputStream fis = new FileInputStream(flushPath.toFile());
+				ObjectInputStream ois = new ObjectInputStream(fis) {
+
+					@Override
+					protected Class<?> resolveClass(ObjectStreamClass desc)
+					throws IOException, ClassNotFoundException {
+						String name = desc.getName();
+						try {
+							return classLoader.loadClass(name);
+						} catch (ClassNotFoundException e) {
+							return super.resolveClass(desc);
+						}
+					}};
+					return new CacheEntry(ois);
+			} catch (Exception e) {}
+		}
+
+		return null;
+	}
+
+	public void putCachedData(String cacheIdentifier, Serializable data, long freshness) {
+		CacheEntry cache = new CacheEntry(cacheIdentifier, data, freshness);
+		caches.put(cacheIdentifier, cache);
+	}
+
+	public void flushAll() throws Exception {
+		Collection<CacheEntry> allCaches = caches.values();
+		for (CacheEntry entry : allCaches) {
+			entry.flush();
+		}
+		caches.clear();
+	}
+
+	public IPath getDefaultLocation() {
+		return defaultLocation;
+	}
+
+	public void setDefaultLocation(IPath defaultLocation) {
+		this.defaultLocation = defaultLocation;
+	}
+
+}