# HG changeset patch # User timkelly # Date 1280348352 18000 # Node ID 94cdcd7c55508ee32546528c7a1f8a8cb7d71ef7 # Parent 6bd6640867aac85eb6042950f1029f3378b0e330 Refactor getBuiltInMacros() to be SBSv1 specific. This are the hard-coded macros misc macros we are adding for SBSv1. For SBSv2, they are retrieved from the sbs config query. Also, clean up some API and comments on public APIS diff -r 6bd6640867aa -r 94cdcd7c5550 builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/project/ICarbideBuildConfiguration.java --- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/project/ICarbideBuildConfiguration.java Wed Jul 28 11:33:05 2010 -0500 +++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/project/ICarbideBuildConfiguration.java Wed Jul 28 15:19:12 2010 -0500 @@ -112,16 +112,6 @@ int getErrorParserId(); /** - * Returns the list of all built in macros for this configuration - *

- * Macros will be just a name, e.g. "_DEBUG", "__SYMBIAN32__", etc.. - *

- * - * @return a list of macros which may be empty. - */ - List getBuiltinMacros(); - - /** * Compares two configurations to see if their display names are equivalent. */ boolean equals(Object obj); @@ -134,6 +124,10 @@ */ IPath getTargetOutputDirectory(); + /** + * Retrieve the build context specific info. + * @return + */ ISymbianBuildContext getBuildContext(); /** ISymbianBuildContext wrapper */ @@ -148,16 +142,47 @@ /** ISymbianBuildContext wrapper */ String getTargetString(); + /** + * Get the compiler prefix file. This is an ISymbianBuildContext wrapper. + * @return The path to the compiler's prefix file. May be null if none. + */ public IPath getCompilerPrefixFile(); + /** + * Get the macros associated with preprocessing CPP source files. This is an ISymbianBuildContext wrapper. + * @return the list of IDefine macros + */ public List getCompilerMacros(); + /** + * Get the macros discovered from preprocessing the SDK prefix file for the configuration. This is an ISymbianBuildContext wrapper. + * @return the list of IDefine macros + */ public List getVariantHRHDefines(); + /** + * Get the list of include files included in the variant HRH SDK preinclude file + * This is used to check dependencies on all SDK/Configuration includes. This is an ISymbianBuildContext wrapper. + * @return + */ public List getPrefixFileIncludes(); + /** + * Get the variant portion of a build configuration name. May be an empty string. This is an ISymbianBuildContext wrapper. + * @return + */ public String getBuildVariationName(); + /** + * Get the 'id' attribute for this configuration (from .cproject file). This is an ISymbianBuildContext wrapper. + * @return + */ String getConfigurationID(); + /** + * Check that at least one MMP in the project configuration has stdcpp support keyword + * @return + */ + public boolean hasSTDCPPSupport(); + } diff -r 6bd6640867aa -r 94cdcd7c5550 builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideBuildConfiguration.java --- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideBuildConfiguration.java Wed Jul 28 11:33:05 2010 -0500 +++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideBuildConfiguration.java Wed Jul 28 15:19:12 2010 -0500 @@ -79,14 +79,6 @@ protected SBSv2BuilderInfo sbsv2BuilderInfo; protected boolean rebuildNeeded; - /** - * TODO: Target constants - copied from ISymbianBuildContext - */ - - public static final String DEBUG_TARGET = "UDEB"; - - public static final String RELEASE_TARGET = "UREL"; - public CarbideBuildConfiguration(IProject project, ISymbianBuildContext context) { this.context = context; projectTracker = new TrackedResource(project); @@ -339,35 +331,6 @@ return ERROR_PARSERS_ALL; } - public List getBuiltinMacros() { - List macros = new ArrayList(); - - if (CarbideBuilderPlugin.getBuildManager().isCarbideSBSv2Project(getCarbideProject().getProject())){ - macros.add("SBSV2"); //$NON-NLS-1$ - } - - // add the macros that should always be defined - macros.add("__SYMBIAN32__"); //$NON-NLS-1$ - macros.add("_UNICODE"); //$NON-NLS-1$ - - ISymbianSDK sdk = getSDK(); - if (sdk != null && sdk.getOSVersion().getMajor() >= 9) { - macros.add("__SUPPORT_CPP_EXCEPTIONS__"); //$NON-NLS-1$ - } - - if (getTargetString().equals(DEBUG_TARGET)) { - macros.add("_DEBUG"); //$NON-NLS-1$ - } else { - macros.add("NDEBUG"); //$NON-NLS-1$ - } - - if (hasSTDCPPSupport()){ - macros.add("__SYMBIAN_STDCPP_SUPPORT__"); - } - - return macros; - } - public CConfigurationData getBuildConfigurationData() { return buildConfigData; } @@ -422,25 +385,6 @@ return sbsv2BuilderInfo; } - private boolean hasSTDCPPSupport() { - - ICarbideProjectInfo cpi = getCarbideProject(); - - List buildConfig = new ArrayList(); - List normalMakMakePaths = new ArrayList(); - List testMakMakePaths = new ArrayList(); - buildConfig.add(this.getBuildContext()); - EpocEngineHelper.getMakMakeFiles(cpi.getAbsoluteBldInfPath(), buildConfig, normalMakMakePaths, testMakMakePaths, new NullProgressMonitor()); - - for (IPath mmpPath : normalMakMakePaths){ - if (EpocEngineHelper.hasSTDCPPSupport(cpi, mmpPath)){ - return true; - } - } - - return false; - } - public ISBSv2BuildConfigInfo getSBSv2ConfigInfo() { return sbsv2BuilderInfo; } @@ -509,6 +453,23 @@ return context.getBuildVariationName(); } - + public boolean hasSTDCPPSupport() { + + ICarbideProjectInfo cpi = this.getCarbideProject(); + + List buildConfig = new ArrayList(); + List normalMakMakePaths = new ArrayList(); + List testMakMakePaths = new ArrayList(); + buildConfig.add(this.getBuildContext()); + EpocEngineHelper.getMakMakeFiles(cpi.getAbsoluteBldInfPath(), buildConfig, normalMakMakePaths, testMakMakePaths, new NullProgressMonitor()); + + for (IPath mmpPath : normalMakMakePaths){ + if (EpocEngineHelper.hasSTDCPPSupport(cpi, mmpPath)){ + return true; + } + } + + return false; + } } diff -r 6bd6640867aa -r 94cdcd7c5550 builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java --- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java Wed Jul 28 11:33:05 2010 -0500 +++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java Wed Jul 28 15:19:12 2010 -0500 @@ -40,6 +40,7 @@ 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; @@ -49,6 +50,7 @@ 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.cdt.builder.project.ICarbideProjectInfo; import com.nokia.carbide.cpp.epoc.engine.model.sbv.ISBVView; import com.nokia.carbide.cpp.epoc.engine.preprocessor.IDefine; import com.nokia.carbide.cpp.internal.api.sdk.ISBSv1BuildInfo; @@ -302,15 +304,20 @@ for (String builtinMacro : sbsv1BuildInfo.getVendorSDKMacros()) { macros.put(builtinMacro, ""); //$NON-NLS-1$ } + + // built in macros + for (String builtinMacro : sbsv1BuildInfo.getBuiltinMacros(context)) { + macros.put(builtinMacro, ""); //$NON-NLS-1$ + } + } else { ISBSv2BuildInfo sbsv2BuildInfo = (ISBSv2BuildInfo)sdk.getBuildInfo(ISymbianBuilderID.SBSV2_BUILDER); // platform macros macros.putAll(sbsv2BuildInfo.getPlatformMacros(carbideBuildConfig.getPlatformString())); } - // built in macros - for (String builtinMacro : carbideBuildConfig.getBuiltinMacros()) { - macros.put(builtinMacro, ""); //$NON-NLS-1$ + if (carbideBuildConfig.hasSTDCPPSupport()){ + macros.put("__SYMBIAN_STDCPP_SUPPORT__", ""); } // target type macros (e.g. __DLL__) @@ -376,7 +383,7 @@ // the cache. cacheTimestamp = System.currentTimeMillis(); } - + private void persistCache() { // persist the cache between IDE launches. try { diff -r 6bd6640867aa -r 94cdcd7c5550 builder/com.nokia.carbide.cpp.builder.utils/src/com/nokia/carbide/cpp/internal/builder/utils/handlers/PreprocessHandler.java --- a/builder/com.nokia.carbide.cpp.builder.utils/src/com/nokia/carbide/cpp/internal/builder/utils/handlers/PreprocessHandler.java Wed Jul 28 11:33:05 2010 -0500 +++ b/builder/com.nokia.carbide.cpp.builder.utils/src/com/nokia/carbide/cpp/internal/builder/utils/handlers/PreprocessHandler.java Wed Jul 28 15:19:12 2010 -0500 @@ -22,7 +22,6 @@ 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; @@ -82,7 +81,6 @@ 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,6 +425,12 @@ for (String builtinMacro : sbsv1BuildInfo.getVendorSDKMacros()) { macros.add(builtinMacro); } + + // built in macros + for (String builtinMacro : sbsv1BuildInfo.getBuiltinMacros(buildConfig.getBuildContext())) { + macros.add(builtinMacro); + } + } else { ISBSv2BuildInfo sbsv2BuildInfo = (ISBSv2BuildInfo)sdk.getBuildInfo(ISymbianBuilderID.SBSV2_BUILDER); // platform macros @@ -436,11 +440,11 @@ } } - // built in macros - for (String builtinMacro : buildConfig.getBuiltinMacros()) { - macros.add(builtinMacro); + if (buildConfig.hasSTDCPPSupport()){ + macros.add("__SYMBIAN_STDCPP_SUPPORT__"); } + IProject project = buildConfig.getCarbideProject().getProject(); List mmps = EpocEngineHelper.getMMPsForSource(project, filePath); diff -r 6bd6640867aa -r 94cdcd7c5550 core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/ISBSv1BuildInfo.java --- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/ISBSv1BuildInfo.java Wed Jul 28 11:33:05 2010 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/ISBSv1BuildInfo.java Wed Jul 28 15:19:12 2010 -0500 @@ -18,6 +18,7 @@ import com.nokia.carbide.cpp.sdk.core.IBSFCatalog; import com.nokia.carbide.cpp.sdk.core.ISBVCatalog; import com.nokia.carbide.cpp.sdk.core.ISDKBuildInfo; +import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext; /** * Interface for SBSv1 specific build information. @@ -77,4 +78,14 @@ void setPreviouslyScanned(boolean wasScanned); + /** + * Returns the list of all built in macros for this configuration. This is ABLD specific. SBSv2 gets these macros from the --query=config. + *

+ * Macros will be just a name, e.g. "_DEBUG", "__SYMBIAN32__", etc.. + *

+ * + * @return a list of macros which may be empty. + */ + List getBuiltinMacros(ISymbianBuildContext context); + } diff -r 6bd6640867aa -r 94cdcd7c5550 core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBSv1BuildInfo.java --- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBSv1BuildInfo.java Wed Jul 28 11:33:05 2010 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SBSv1BuildInfo.java Wed Jul 28 15:19:12 2010 -0500 @@ -307,4 +307,26 @@ return buildContexts; } + @Override + public List getBuiltinMacros(ISymbianBuildContext context) { + List macros = new ArrayList(); + + macros.add("SBSV2"); //$NON-NLS-1$ + + // add the macros that should always be defined + macros.add("__SYMBIAN32__"); //$NON-NLS-1$ + macros.add("_UNICODE"); //$NON-NLS-1$ + + macros.add("__SUPPORT_CPP_EXCEPTIONS__"); //$NON-NLS-1$ + + if (context.getTargetString().equals(ISymbianBuildContext.DEBUG_TARGET)) { + macros.add("_DEBUG"); //$NON-NLS-1$ + } else { + macros.add("NDEBUG"); //$NON-NLS-1$ + } + + return macros; + } + + } diff -r 6bd6640867aa -r 94cdcd7c5550 core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SDKManager.java --- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SDKManager.java Wed Jul 28 11:33:05 2010 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SDKManager.java Wed Jul 28 15:19:12 2010 -0500 @@ -213,7 +213,6 @@ installPath = wr.getLocalMachineValue(CSL_ARM_TOOLCHAIN_REG_PATH, CSL_ARM_TOOLCHAIN_REG_KEY); } catch (Exception e) { - //TODO: Localise String errMsg = "Could not read registry for local machine key: '" + CSL_ARM_TOOLCHAIN_REG_PATH + " (" + e.getMessage() +")."; //$NON-NLS-N$ throw new SDKEnvInfoFailureException(errMsg); diff -r 6bd6640867aa -r 94cdcd7c5550 core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SymbianSDK.java --- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SymbianSDK.java Wed Jul 28 11:33:05 2010 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SymbianSDK.java Wed Jul 28 15:19:12 2010 -0500 @@ -196,6 +196,9 @@ return sdkFeatures; } + // TODO: This needs to move under ISymianBuildContext. For abld we can use this method. + // For SBSv2, this is configuration dependent and the information is obtained from + // the sbs --query=config[] call. public List getSupportedTargetTypes() { synchronized (supportedTargetTypesList) { diff -r 6bd6640867aa -r 94cdcd7c5550 core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISymbianSDK.java --- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISymbianSDK.java Wed Jul 28 11:33:05 2010 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/ISymbianSDK.java Wed Jul 28 15:19:12 2010 -0500 @@ -36,6 +36,7 @@ * Returns build info for a particular builder. * @param builderId id string of a builder * @return build info + * @since 3.0 */ ISDKBuildInfo getBuildInfo(String builderId); @@ -79,6 +80,7 @@ * Returns a set of features supported by the SDK. * Feature IDs are defined in ISymbianSDKFeatures. * @return set of features + * @since 3.0 */ @SuppressWarnings("rawtypes") Set getSupportedFeatures();