Added ICarbideBuildConfigutation#getCompileTimeMacros() and EpocEngineHelper#getGlobalDefinesForConfiguration()
as convenience wrappers for getting macros contributing to a carbide project. Removed ICarbideBuildConfiguration#hasSTDCPPSupport().
Refactored CarbideLanguageData to use simplified macro retrieval
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/EpocEngineHelper.java Thu Aug 12 15:56:37 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/EpocEngineHelper.java Thu Aug 12 17:32:31 2010 -0500
@@ -45,6 +45,7 @@
import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration;
import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo;
import com.nokia.carbide.cdt.builder.project.ISISBuilderInfo;
+import com.nokia.carbide.cdt.internal.builder.CarbideProjectInfo;
import com.nokia.carbide.cpp.epoc.engine.BldInfDataRunnableAdapter;
import com.nokia.carbide.cpp.epoc.engine.BldInfViewRunnableAdapter;
import com.nokia.carbide.cpp.epoc.engine.EpocEnginePlugin;
@@ -73,13 +74,14 @@
import com.nokia.carbide.cpp.epoc.engine.model.mmp.IMMPViewConfiguration;
import com.nokia.carbide.cpp.epoc.engine.preprocessor.AcceptedNodesViewFilter;
import com.nokia.carbide.cpp.epoc.engine.preprocessor.AllNodesViewFilter;
+import com.nokia.carbide.cpp.epoc.engine.preprocessor.DefineFactory;
+import com.nokia.carbide.cpp.epoc.engine.preprocessor.IDefine;
import com.nokia.carbide.cpp.internal.api.sdk.BuildContextSBSv1;
import com.nokia.carbide.cpp.internal.api.sdk.ISBSv1BuildContext;
import com.nokia.carbide.cpp.internal.api.sdk.ISBSv1BuildInfo;
import com.nokia.carbide.cpp.internal.api.sdk.ISBSv2BuildConfigInfo;
import com.nokia.carbide.cpp.internal.api.sdk.ISBSv2BuildContext;
import com.nokia.carbide.cpp.internal.api.sdk.SymbianBuildContextDataCache;
-import com.nokia.carbide.cpp.sdk.core.ISDKBuildInfo;
import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext;
import com.nokia.carbide.cpp.sdk.core.ISymbianBuilderID;
import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
@@ -2763,4 +2765,60 @@
return paths;
}
+
+ /**
+ * Retrieves all macros used for indexing a given ICarbideBuildConfiguration.
+ * @param config - The CarbideBuildConfiguration
+ * @param mmpFiles - null if for all MMPs in the project
+ * @return list of IDefine
+ * @since 3.0
+ */
+ public static List<IDefine> getGlobalDefinesForConfiguration(ICarbideBuildConfiguration config, List<IPath> mmpFiles){
+
+ List<IDefine> projectDefines = config.getCompileTimeMacros();
+
+ boolean indexAllMMPs = false;
+ if (mmpFiles == null){
+ // get all macros from all mmps
+ indexAllMMPs = true;
+ mmpFiles = getMMPFilesForProject(config.getCarbideProject());
+ }
+
+ boolean foundStdCPPSupport = false;
+ for (IPath mmpPath : mmpFiles){
+ if (!foundStdCPPSupport && hasSTDCPPSupport(config.getCarbideProject(), mmpPath)){
+ projectDefines.add(DefineFactory.createDefine("__SYMBIAN_STDCPP_SUPPORT__"));
+ foundStdCPPSupport = true;
+ }
+ }
+
+ // get the list of all mmp files selected for the build configuration
+ // a null buildComponents list means all MMPs are included - so leave it null when indexing all files
+ List<String> buildComponents = null;
+ if (!EpocEngineHelper.getIndexAllPreference() || !indexAllMMPs)
+ buildComponents = config.getCarbideProject().isBuildingFromInf() ? null : config.getCarbideProject().getInfBuildComponents();
+
+ if (((CarbideProjectInfo)config.getCarbideProject()).shouldUseMMPMacros()){
+ for (IPath mmpPath : mmpFiles) {
+
+ if (buildComponents != null && !TextUtils.listContainsIgnoreCase(buildComponents, mmpPath.lastSegment()))
+ continue;
+
+ List<String> mmpMacros = getMMPMacrosForBuildConfiguration(
+ mmpPath, config);
+ for (String macro : mmpMacros) {
+ // Symbian docs say they are converted to upper case always
+ projectDefines.add(DefineFactory.createDefine(macro.toUpperCase()));
+ }
+ }
+ }
+
+ List<String> targetTypes = getTargetTypesForBuildConfiguration(config);
+ if (targetTypes.size() > 0){
+ projectDefines.add(config.getBuildContext().getTargetTypeMacro(targetTypes.get(0)));
+ }
+
+ return projectDefines;
+ }
+
}
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/project/ICarbideBuildConfiguration.java Thu Aug 12 15:56:37 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/project/ICarbideBuildConfiguration.java Thu Aug 12 17:32:31 2010 -0500
@@ -21,6 +21,7 @@
import org.eclipse.core.runtime.IPath;
import com.nokia.carbide.cdt.builder.builder.CarbideCPPBuilder;
+import com.nokia.carbide.cpp.epoc.engine.preprocessor.IDefine;
import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext;
import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
@@ -113,10 +114,14 @@
String getTargetString();
/**
- * Check that at least one MMP in the project configuration has stdcpp support keyword
- * @return
+ * Provides a list of macros suitable for preprocessing a CPP source file. This includes
+ * macros from the compiler prefix, Symbian HRH, buit-in build macros, and metadata macros.
+ * Note: If you don't want the macro values from the preincludes, you should use the methods
+ * directly under ISymbianBuildContext for more specificity.
+ * @return a list of macro defines
* @since 3.0
*/
- boolean hasSTDCPPSupport();
+ List<IDefine> getCompileTimeMacros();
+
}
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideBuildConfiguration.java Thu Aug 12 15:56:37 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideBuildConfiguration.java Thu Aug 12 17:32:31 2010 -0500
@@ -42,6 +42,8 @@
import com.nokia.carbide.cdt.builder.project.IEnvironmentVarsInfo;
import com.nokia.carbide.cdt.builder.project.ISISBuilderInfo;
import com.nokia.carbide.cdt.internal.api.builder.SISBuilderInfo2;
+import com.nokia.carbide.cpp.epoc.engine.preprocessor.DefineFactory;
+import com.nokia.carbide.cpp.epoc.engine.preprocessor.IDefine;
import com.nokia.carbide.cpp.internal.api.sdk.BuildContextSBSv1;
import com.nokia.carbide.cpp.internal.api.sdk.ISBSv1BuildContext;
import com.nokia.carbide.cpp.internal.api.sdk.ISBSv1BuildInfo;
@@ -284,6 +286,11 @@
return context;
}
+ /**
+ * Check that at least one MMP in the project configuration has stdcpp support keyword
+ * @return
+ * @since 3.0
+ */
public boolean hasSTDCPPSupport() {
ICarbideProjectInfo cpi = this.getCarbideProject();
@@ -302,5 +309,18 @@
return false;
}
+
+ public List<IDefine> getCompileTimeMacros() {
+
+ List<IDefine> defines = new ArrayList<IDefine>();
+
+ defines.addAll(context.getBuildMacros());
+ defines.addAll(context.getCompilerPreincludeDefines());
+ defines.addAll(context.getVariantHRHDefines());
+ defines.addAll(context.getMetadataMacros());
+
+ return defines;
+
+ }
}
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java Thu Aug 12 15:56:37 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java Thu Aug 12 17:32:31 2010 -0500
@@ -291,53 +291,24 @@
macroEntries = new ArrayList<ICLanguageSettingEntry>(0);
lastUseMMPMacrosValue = cpi.shouldUseMMPMacros();
-
- Map<String, String> macros = new HashMap<String, String>();
-
- // platform macros
- for (IDefine metaDataDefine : context.getMetadataMacros()){
- macros.put(metaDataDefine.getName(), metaDataDefine.getExpansion());
- }
-
- if ((carbideBuildConfig).hasSTDCPPSupport()){
- macros.put("__SYMBIAN_STDCPP_SUPPORT__", "");
- }
-
- // target type macros (e.g. __DLL__)
- List<String> targetTypes = EpocEngineHelper.getTargetTypesForBuildConfiguration(carbideBuildConfig);
- // only add these if there is one target type. this is the case when there is only one mmp file, or
- // more than one but all have the same target type macro. it wouldn't make sense to add different
- // target type macros like __EXE__ and __DLL__.
- if (targetTypes.size() == 1) {
- // Just get the macro for the first MMP found
- IDefine ttMacro = context.getTargetTypeMacro(targetTypes.get(0));
- macros.put(ttMacro.getName(), ttMacro.getExpansion());
- }
// get the list of all mmp files selected for the build configuration
// a null buildComponents list means all MMPs are included - so leave it null when indexing all files
List<String> buildComponents = null;
if (!EpocEngineHelper.getIndexAllPreference())
buildComponents = carbideBuildConfig.getCarbideProject().isBuildingFromInf() ? null : carbideBuildConfig.getCarbideProject().getInfBuildComponents();
-
- // if the pref option is enabled, then check the mmp's for MACRO's.
- if (cpi.shouldUseMMPMacros()) {
- List<IPath> mmps = EpocEngineHelper.getMMPFilesForBuildConfiguration(carbideBuildConfig);
- for (IPath mmp : mmps) {
- if (buildComponents != null && !TextUtils.listContainsIgnoreCase(buildComponents, mmp.lastSegment()))
- continue;
-
- List<String> mmpMacros = EpocEngineHelper.getMMPMacrosForBuildConfiguration(mmp, carbideBuildConfig);
- for (String mmpMacro : mmpMacros) {
- // Symbian docs say they are converted to upper case always
- macros.put(mmpMacro.toUpperCase(), ""); //$NON-NLS-1$
- }
- }
- }
-
+
+ List<IPath> mmpFiles = null;
+ List<IDefine> projectDefines = new ArrayList<IDefine>();
+ if (buildComponents != null){
+ mmpFiles = EpocEngineHelper.getMMPFilesForBuildConfiguration(carbideBuildConfig);
+ }
+
+ projectDefines = EpocEngineHelper.getGlobalDefinesForConfiguration(carbideBuildConfig, mmpFiles);
+
// now create the path entries for the macros
- for (String macro : macros.keySet()) {
- macroEntries.add(new CMacroEntry(macro, macros.get(macro), 0));
+ for (IDefine define : projectDefines) {
+ macroEntries.add(new CMacroEntry(define.getName(), define.getExpansion(), 0));
}
// get the list of files the engine references when parsing the bld.inf and mmp files
--- a/builder/com.nokia.carbide.cpp.builder.utils/src/com/nokia/carbide/cpp/internal/builder/utils/handlers/PreprocessHandler.java Thu Aug 12 15:56:37 2010 -0500
+++ b/builder/com.nokia.carbide.cpp.builder.utils/src/com/nokia/carbide/cpp/internal/builder/utils/handlers/PreprocessHandler.java Thu Aug 12 17:32:31 2010 -0500
@@ -20,7 +20,6 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.core.model.CModelException;
@@ -74,6 +73,7 @@
import com.nokia.carbide.cdt.builder.builder.CarbideCommandLauncher;
import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration;
import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo;
+import com.nokia.carbide.cdt.internal.builder.CarbideBuildConfiguration;
import com.nokia.carbide.cpp.epoc.engine.EpocEnginePlugin;
import com.nokia.carbide.cpp.epoc.engine.MMPDataRunnableAdapter;
import com.nokia.carbide.cpp.epoc.engine.model.mmp.EMMPLanguage;
@@ -82,14 +82,9 @@
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.IDefine;
-import com.nokia.carbide.cpp.internal.api.sdk.ISBSv1BuildContext;
-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;
import com.nokia.carbide.cpp.internal.builder.utils.ui.LanguageSelectionDialog;
import com.nokia.carbide.cpp.internal.builder.utils.ui.PreprocessPreferencePage;
-import com.nokia.carbide.cpp.sdk.core.ISymbianBuilderID;
-import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
import com.nokia.cpp.internal.api.utils.core.FileUtils;
import com.nokia.cpp.internal.api.utils.core.HostOS;
import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils;
@@ -422,7 +417,7 @@
macros.add(define.getName());
}
- if (buildConfig.hasSTDCPPSupport()){
+ if (((CarbideBuildConfiguration)buildConfig).hasSTDCPPSupport()){
macros.add("__SYMBIAN_STDCPP_SUPPORT__");
}