Add STDCPP keyword and targettype support. Bug 10460.
authortimkelly
Mon, 01 Feb 2010 10:28:41 -0600
changeset 853 6c8527cdaa2e
parent 852 fdbb711fea6d
child 854 a7d9320cd85e
Add STDCPP keyword and targettype support. Bug 10460.
builder/com.nokia.carbide.cdt.builder.test/src/com/nokia/carbide/cdt/builder/test/TestEpocEngineHelper.java
builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/EpocEngineHelper.java
builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/project/ICarbideBuildConfiguration.java
builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideBuildConfiguration.java
builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java
project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/model/mmp/EMMPStatement.java
--- a/builder/com.nokia.carbide.cdt.builder.test/src/com/nokia/carbide/cdt/builder/test/TestEpocEngineHelper.java	Fri Jan 29 17:13:00 2010 -0600
+++ b/builder/com.nokia.carbide.cdt.builder.test/src/com/nokia/carbide/cdt/builder/test/TestEpocEngineHelper.java	Mon Feb 01 10:28:41 2010 -0600
@@ -183,4 +183,14 @@
 			}
 		}
 	}
+	
+	public void testSTDCPPSupport() throws Exception {
+		ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(carbideProject);
+		for (final IPath mmpPath : EpocEngineHelper.getMMPFilesForBuildConfiguration(cpi.getDefaultConfiguration())) {
+			if (EpocEngineHelper.hasSTDCPPSupport(cpi, mmpPath)){
+				fail("Project does not have STDCPP Support");
+			}
+		}
+	}
+	
 }
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/EpocEngineHelper.java	Fri Jan 29 17:13:00 2010 -0600
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/EpocEngineHelper.java	Mon Feb 01 10:28:41 2010 -0600
@@ -2080,6 +2080,45 @@
 		return result != null ? result.booleanValue() : false;
 	}
 	
+
+	/**
+	 * Check whether or not the project and build for standard C++.
+	 * The following rules apply:
+	 * 
+	 * 1) If an MMP contains NOSTDCPP then it does not have std C++ support
+	 * 2) Else If the STDCPP keyword is set it does have std C++ support
+	 * 3) Else if TARGETTYPE is one of STDEXE|STDDLL|STDLIB it does have std C++ support
+	 * 4) Else not std C++ support
+	 * 
+	 * @return true if the MMP has standard C++ support
+	 */
+	public static boolean hasSTDCPPSupport(ICarbideProjectInfo projectInfo, final IPath relativeMMPPath) {
+		Boolean result = (Boolean) EpocEnginePlugin.runWithMMPData(
+				relativeMMPPath, 
+			new DefaultMMPViewConfiguration(
+					projectInfo,
+					new AllNodesViewFilter()),
+			new MMPDataRunnableAdapter() {
+				public Object run(IMMPData data) {
+					if (data.getFlags().contains(EMMPStatement.NOSTDCPP)){
+						return false;
+					} else if (data.getFlags().contains(EMMPStatement.STDCPP)){
+						return true;
+					} 
+					
+					String targetType = data.getSingleArgumentSettings().get(EMMPStatement.TARGETTYPE);
+					if (targetType != null) {
+						if (targetType.toUpperCase().matches("STDEXE|STDLIB|STDDLL")) { //$NON-NLS-1$
+							return true;
+						}
+					}
+					
+					return false;
+				}
+		});
+		return result != null ? result.booleanValue() : false;
+	}
+	
 	/**
 	 * A particular MMP file is considered to be a Symbian Binary Variation iff the MMP file
 	 * has the keyword "FEATUREVARIANT" flag defined and the build configuration has a valid
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/project/ICarbideBuildConfiguration.java	Fri Jan 29 17:13:00 2010 -0600
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/project/ICarbideBuildConfiguration.java	Mon Feb 01 10:28:41 2010 -0600
@@ -18,7 +18,10 @@
 
 import java.util.List;
 
+import org.eclipse.core.runtime.IPath;
+
 import com.nokia.carbide.cdt.builder.BuildArgumentsInfo;
+import com.nokia.carbide.cdt.builder.EpocEngineHelper;
 import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext;
 
 /**
@@ -128,5 +131,12 @@
 	 * Compares two configurations to see if their display names are equivalent.
 	 */
 	boolean equals(Object obj);
+
+	/**
+	 * Check whether or not the build configuration has an MMP that supports standard C++
+	 * @return true if the project has one MMP with standard C++ support
+	 * @see EpocEngineHelper#hasSTDCPPSupport(ICarbideProjectInfo, IPath)
+	 */
+	boolean hasSTDCPPSupport();
 	
 }
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideBuildConfiguration.java	Fri Jan 29 17:13:00 2010 -0600
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideBuildConfiguration.java	Mon Feb 01 10:28:41 2010 -0600
@@ -28,12 +28,14 @@
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Status;
 
 import com.nokia.carbide.cdt.builder.BuildArgumentsInfo;
 import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin;
+import com.nokia.carbide.cdt.builder.EpocEngineHelper;
 import com.nokia.carbide.cdt.builder.builder.CarbideCPPBuilder;
 import com.nokia.carbide.cdt.builder.project.IBuildArgumentsInfo;
 import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration;
@@ -374,4 +376,24 @@
 	public IROMBuilderInfo getROMBuildInfo() {
 		return romBuilderInfo;
 	}
+
+
+	public boolean hasSTDCPPSupport() {
+		
+		ICarbideProjectInfo cpi = getCarbideProject();
+		
+		List<ISymbianBuildContext> buildConfig = new ArrayList<ISymbianBuildContext>();
+		List<IPath> normalMakMakePaths = new ArrayList<IPath>();
+		List<IPath> testMakMakePaths = new ArrayList<IPath>();
+		buildConfig.add(cpi.getDefaultConfiguration());
+		EpocEngineHelper.getMakMakeFiles(cpi.getAbsoluteBldInfPath(), buildConfig, normalMakMakePaths, testMakMakePaths, new NullProgressMonitor());
+		
+		for (IPath mmpPath : normalMakMakePaths){
+			if (EpocEngineHelper.hasSTDCPPSupport(cpi, mmpPath)){
+				return true;
+			}
+		}
+		
+		return false;
+	}
 }
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java	Fri Jan 29 17:13:00 2010 -0600
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java	Mon Feb 01 10:28:41 2010 -0600
@@ -139,7 +139,11 @@
 			for (IDefine define : carbideBuildConfig.getCompilerMacros()) {
 				macros.add(new CMacroEntry(define.getNameAndArguments(), define.getExpansion(), 0));
 			}
-
+			
+			if (carbideBuildConfig.hasSTDCPPSupport()){
+				macros.add(new CMacroEntry("__SYMBIAN_STDCPP_SUPPORT__", "", 0));
+			}
+			
 			return macros.toArray(new ICLanguageSettingEntry[macros.size()]);
 		}
 		
--- a/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/model/mmp/EMMPStatement.java	Fri Jan 29 17:13:00 2010 -0600
+++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/model/mmp/EMMPStatement.java	Mon Feb 01 10:28:41 2010 -0600
@@ -76,6 +76,12 @@
 	 */
 	FEATUREVARIANT("FEATUREVARIANT", IMMPParserConfiguration.FLAG_STATEMENT), //$NON-NLS-1$
 	
+	/**
+	 * @since 2.5 - Added with Symbian^3
+	 */
+	STDCPP("STDCPP", IMMPParserConfiguration.FLAG_STATEMENT), //$NON-NLS-1$
+	NOSTDCPP("NOSTDCPP", IMMPParserConfiguration.FLAG_STATEMENT), //$NON-NLS-1$
+	
 	HEADER("HEADER", IMMPParserConfiguration.FLAG_STATEMENT, "RESOURCE|BITMAP"), //$NON-NLS-1$ //$NON-NLS-2$
 	HEADERONLY("HEADERONLY", IMMPParserConfiguration.FLAG_STATEMENT, "RESOURCE|BITMAP"), //$NON-NLS-1$ //$NON-NLS-2$