Carbide.c++

com.nokia.carbide.cdt.builder.builder
Class CarbideCPPBuilder

java.lang.Object
  extended by IncrementalProjectBuilder
      extended by com.nokia.carbide.cdt.builder.builder.CarbideCPPBuilder

public class CarbideCPPBuilder
extends IncrementalProjectBuilder

Main interface for invoking different build stages.


Field Summary
static int BUILD_COMPONENT_ACTION
           
static java.lang.String BUILDER_ID
           
static int CLEAN_COMPONENT_ACTION
           
static int FREEZE_COMPONENT_ACTION
           
static java.lang.String RESOLVED_PKG_PREFIX
           
 
Constructor Summary
CarbideCPPBuilder()
           
 
Method Summary
protected  IProject[] build(int kind, java.util.Map args, IProgressMonitor monitor)
           
protected static boolean buildAllComponents(ICarbideBuildConfiguration buildConfig, CarbideCommandLauncher launcher, IProgressMonitor monitor)
           
protected static boolean buildComponentSubset(ICarbideBuildConfiguration buildConfig, CarbideCommandLauncher launcher, IProgressMonitor monitor)
           
protected static void calculateComponentLists(ICarbideBuildConfiguration buildConfig, CarbideCommandLauncher launcher)
           
static void callAbldBuildForConfiguration(ICarbideBuildConfiguration config, IProgressMonitor monitor, IConsole console, int buildKind, boolean clearMarkers)
          Deprecated. use #invokeBuild(ICarbideBuildConfiguration, IConsole, IProgressMonitor) instead
protected  void clean(IProgressMonitor monitor)
           
protected static void cleanAllComponents(ICarbideBuildConfiguration buildConfig, CarbideCommandLauncher launcher, IProgressMonitor monitor)
           
protected static void cleanComponentSubset(ICarbideBuildConfiguration buildConfig, CarbideCommandLauncher launcher, IProgressMonitor monitor)
           
static void compileFile(IPath file, ICarbideBuildConfiguration buildConfig, IConsole console, CarbideCommandLauncher launcher, IProgressMonitor monitor, boolean clearMarkers)
          Invokes a compile of the the given file for the given build configuration.
protected static void freezeAllComponents(ICarbideBuildConfiguration buildConfig, CarbideCommandLauncher launcher, IProgressMonitor monitor)
           
protected static void freezeComponentSubset(ICarbideBuildConfiguration buildConfig, CarbideCommandLauncher launcher, IProgressMonitor monitor)
           
protected static boolean generateAbldMakefileIfNecessary(ICarbideBuildConfiguration config, CarbideCommandLauncher launcher, IPath componentPath, boolean isTest)
          Generates the abld makefile if necessary.
static boolean generateAbldMakefilesIfNecessary(ICarbideBuildConfiguration config, CarbideCommandLauncher launcher)
          Generates the abld makefiles if necessary.
static boolean generateAbldMakefilesIfNecessary(ICarbideBuildConfiguration config, CarbideCommandLauncher launcher, boolean calculateComponentLists)
          Generates the abld makefiles if necessary.
static boolean generateBldmakeMakefilesIfNecessary(ICarbideBuildConfiguration config, CarbideCommandLauncher launcher)
          Generates the bldmake makefiles if necessary.
protected static java.util.List<IPath> getMakeRulesForResource(ICarbideBuildConfiguration buildConfig, IPath workspaceRelativeMMPPath, IPath projectRelativeResourcePath)
           
static java.lang.String[] getModifiedEnvVars(ICarbideBuildConfiguration config)
          Get the array of environment variables that are modified from their default values.
static java.lang.String[] getParserIdArray(int id)
          Get the array of parser ID's (extension ID from plugin.xml) that will be used to parse the output of a given process invoked by the CarbideCommandLauncher.
static IPath getPartialUpgradeSisPath(ICarbideBuildConfiguration config, IPath sisPath)
          Given a sis/sisx path, returns the absolute file system path of the associated partial upgrade sis/sisx file if any, otherwise null.
static java.lang.String[] getRawEnvVars()
          Get the environement variables exactly as they come from the system.
static java.lang.String[] getResolvedEnvVars(ICarbideBuildConfiguration config)
          Get the array of resolved environment variables.
static boolean invokeAbldCommand(ICarbideBuildConfiguration buildConfig, CarbideCommandLauncher launcher, java.lang.String[] abldArgs, boolean removeMarkers)
          Call abld with the given arguments
static boolean invokeBldmakeBldFiles(ICarbideBuildConfiguration config, CarbideCommandLauncher cmdLauncher, IProgressMonitor monitor, IConsole console, java.lang.String[] env, IPath workingDir)
          Deprecated. use #generateBldmakeMakefilesIfNecessary(ICarbideBuildConfiguration, CarbideCommandLauncher, IConsole, IProgressMonitor, boolean) instead
static boolean invokeBldmakeCommand(ICarbideBuildConfiguration buildConfig, CarbideCommandLauncher launcher, java.lang.String[] bldmakeArgs, boolean removeMarkers)
          Call bldmake with the given arguments
static void invokeBuild(ICarbideBuildConfiguration buildConfig, CarbideCommandLauncher launcher, IProgressMonitor monitor, boolean clearMarkers)
          Invokes a build for the given build configuration.
static void invokeClean(ICarbideBuildConfiguration buildConfig, IProgressMonitor monitor, boolean clearMarkers)
          Invokes a clean for the given build configuration.
static void invokeFreeze(ICarbideBuildConfiguration buildConfig, IProgressMonitor monitor, boolean clearMarkers)
          Invokes a freeze for the given build configuration.
static void invokeROMBuilder(ICarbideBuildConfiguration config, CarbideCommandLauncher cmdLauncher, IProgressMonitor monitor)
          Invoke the ROM builder for the given build configuration
static void invokeSISBuilder(ICarbideBuildConfiguration config, CarbideCommandLauncher cmdLauncher, IProgressMonitor monitor)
          Invoke the SIS builder for all pkg files for the given build configuration
static void invokeSISBuilder(IPath pkgPath, ICarbideBuildConfiguration config, CarbideCommandLauncher cmdLauncher, IProgressMonitor monitor, boolean createOutputFromPKGFileName)
          Invoke the SIS builder for either EKA1 or EKA2 projects.
static boolean invokeSymbianComponenetAction(ICarbideBuildConfiguration buildConfig, int action, IPath componentPath, CarbideCommandLauncher launcher, IProgressMonitor monitor, boolean clearMarkers)
          Invoke the given action on the given Symbian mmp/make file for the given build configuration.
protected static boolean needsBldmakeMakefileGeneration(ICarbideBuildConfiguration config)
          Check to see if abld.bat and the bldmake makefiles exists, or if they are stale.
static boolean projectHasBuildErrors(IProject project)
          Checks the Problems view for any error markers.
static boolean projectNeedsMakefileGeneration(IPath bldInfDir, ICarbideBuildConfiguration defaultConfig)
          Deprecated. use needsBldmakeMakefileGeneration(ICarbideBuildConfiguration)
static void removeAllMarkers(IProject currProject)
          Remove all the C/C++ markers for the current project.
static IPath resolvePKGFile(IPath pkgFile, ISymbianBuildContext context, IPath tempPKGFileName)
          Given PKG file to be built, check to see if it has supported macros and if so replace them so the PKG file will contain current build context values.
protected static void runPreBuildChecks(ICarbideBuildConfiguration buildConfig, CarbideCommandLauncher launcher)
           
protected  boolean shouldRebuild(IResourceDelta delta)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUILDER_ID

public static final java.lang.String BUILDER_ID
See Also:
Constant Field Values

BUILD_COMPONENT_ACTION

public static final int BUILD_COMPONENT_ACTION
See Also:
Constant Field Values

CLEAN_COMPONENT_ACTION

public static final int CLEAN_COMPONENT_ACTION
See Also:
Constant Field Values

FREEZE_COMPONENT_ACTION

public static final int FREEZE_COMPONENT_ACTION
See Also:
Constant Field Values

RESOLVED_PKG_PREFIX

public static final java.lang.String RESOLVED_PKG_PREFIX
See Also:
Constant Field Values
Constructor Detail

CarbideCPPBuilder

public CarbideCPPBuilder()
Method Detail

build

protected IProject[] build(int kind,
                           java.util.Map args,
                           IProgressMonitor monitor)
                    throws CoreException
Throws:
CoreException

shouldRebuild

protected boolean shouldRebuild(IResourceDelta delta)

clean

protected void clean(IProgressMonitor monitor)
              throws CoreException
Throws:
CoreException

invokeBuild

public static void invokeBuild(ICarbideBuildConfiguration buildConfig,
                               CarbideCommandLauncher launcher,
                               IProgressMonitor monitor,
                               boolean clearMarkers)
Invokes a build for the given build configuration. Output is piped to the given console and progress is reported using the given monitor. Make files are created/updated if necessary.

Parameters:
buildConfig - the build configuration to build
launcher - the Carbide launcher
monitor - the progress monitor to use to report progress
clearMarkers - true if project markers should be cleared before action is taken

invokeClean

public static void invokeClean(ICarbideBuildConfiguration buildConfig,
                               IProgressMonitor monitor,
                               boolean clearMarkers)
Invokes a clean for the given build configuration. Output is piped to the given console and progress is reported using the given monitor. Make files are created/updated if necessary.

Parameters:
buildConfig - the build configuration to clean
monitor - the progress monitor to use to report progress
clearMarkers - true if project markers should be cleared before action is taken

invokeFreeze

public static void invokeFreeze(ICarbideBuildConfiguration buildConfig,
                                IProgressMonitor monitor,
                                boolean clearMarkers)
Invokes a freeze for the given build configuration. Output is piped to the given console and progress is reported using the given monitor. Make files are created/updated if necessary.

Parameters:
buildConfig - the build configuration to freeze
monitor - the progress monitor to use to report progress
clearMarkers - true if project markers should be cleared before action is taken

invokeSymbianComponenetAction

public static boolean invokeSymbianComponenetAction(ICarbideBuildConfiguration buildConfig,
                                                    int action,
                                                    IPath componentPath,
                                                    CarbideCommandLauncher launcher,
                                                    IProgressMonitor monitor,
                                                    boolean clearMarkers)
                                             throws CoreException
Invoke the given action on the given Symbian mmp/make file for the given build configuration.

Parameters:
buildConfig - the build configuration to act upon
action - the action to perform, see BUILD_COMPONENT_ACTION, CLEAN_COMPONENT_ACTION, FREEZE_COMPONENT_ACTION
componentPath - the full path of the mmp or make file
launcher - - The object to use for the process execution
monitor - the progress monitor to report progress to
clearMarkers - true if project markers should be cleared before action is taken
Returns:
true if successful, false otherwise
Throws:
CoreException

compileFile

public static void compileFile(IPath file,
                               ICarbideBuildConfiguration buildConfig,
                               IConsole console,
                               CarbideCommandLauncher launcher,
                               IProgressMonitor monitor,
                               boolean clearMarkers)
                        throws CoreException
Invokes a compile of the the given file for the given build configuration. Output is piped to the given console and progress is reported using the given monitor. Make files are created/updated if necessary.

Parameters:
file - the absolute file system path to the file to be compiled (source, resource)
buildConfig - the build configuration to build
console - the console to pipe build output to
launcher - - The object to use for the process execution
monitor - the progress monitor to use to report progress
clearMarkers - whether or not to clear project markers before compiling
Throws:
CoreException

getMakeRulesForResource

protected static java.util.List<IPath> getMakeRulesForResource(ICarbideBuildConfiguration buildConfig,
                                                               IPath workspaceRelativeMMPPath,
                                                               IPath projectRelativeResourcePath)

runPreBuildChecks

protected static void runPreBuildChecks(ICarbideBuildConfiguration buildConfig,
                                        CarbideCommandLauncher launcher)

calculateComponentLists

protected static void calculateComponentLists(ICarbideBuildConfiguration buildConfig,
                                              CarbideCommandLauncher launcher)

buildAllComponents

protected static boolean buildAllComponents(ICarbideBuildConfiguration buildConfig,
                                            CarbideCommandLauncher launcher,
                                            IProgressMonitor monitor)

buildComponentSubset

protected static boolean buildComponentSubset(ICarbideBuildConfiguration buildConfig,
                                              CarbideCommandLauncher launcher,
                                              IProgressMonitor monitor)

cleanAllComponents

protected static void cleanAllComponents(ICarbideBuildConfiguration buildConfig,
                                         CarbideCommandLauncher launcher,
                                         IProgressMonitor monitor)

cleanComponentSubset

protected static void cleanComponentSubset(ICarbideBuildConfiguration buildConfig,
                                           CarbideCommandLauncher launcher,
                                           IProgressMonitor monitor)

freezeAllComponents

protected static void freezeAllComponents(ICarbideBuildConfiguration buildConfig,
                                          CarbideCommandLauncher launcher,
                                          IProgressMonitor monitor)

freezeComponentSubset

protected static void freezeComponentSubset(ICarbideBuildConfiguration buildConfig,
                                            CarbideCommandLauncher launcher,
                                            IProgressMonitor monitor)

invokeBldmakeCommand

public static boolean invokeBldmakeCommand(ICarbideBuildConfiguration buildConfig,
                                           CarbideCommandLauncher launcher,
                                           java.lang.String[] bldmakeArgs,
                                           boolean removeMarkers)
Call bldmake with the given arguments

Parameters:
buildConfig - the build configuration context
launcher - the command launcher
bldmakeArgs - array of String arguments to be passed to bldmake
removeMarkers - project markers will be removed when true
Returns:
true if operation was successful, false otherwise

invokeAbldCommand

public static boolean invokeAbldCommand(ICarbideBuildConfiguration buildConfig,
                                        CarbideCommandLauncher launcher,
                                        java.lang.String[] abldArgs,
                                        boolean removeMarkers)
Call abld with the given arguments

Parameters:
buildConfig - the build configuration context
launcher - the command launcher
abldArgs - array of String arguments to be passed to abld
removeMarkers - project markers will be removed when true
Returns:
true if operation was successful, false otherwise

getResolvedEnvVars

public static java.lang.String[] getResolvedEnvVars(ICarbideBuildConfiguration config)
Get the array of resolved environment variables. This the entire list of variables that should be used during a build for the given configuration

Parameters:
config - - The config whose environment variables you want.
Returns:
An array of environment variables of format <var>=<value>

getModifiedEnvVars

public static java.lang.String[] getModifiedEnvVars(ICarbideBuildConfiguration config)
Get the array of environment variables that are modified from their default values.

Parameters:
config - - Config you are building for.
Returns:
An array of environment variables of format <var>=<value>

getRawEnvVars

public static java.lang.String[] getRawEnvVars()
Get the environement variables exactly as they come from the system.

Returns:
An array of environment variables of format <var>=<value>

generateBldmakeMakefilesIfNecessary

public static boolean generateBldmakeMakefilesIfNecessary(ICarbideBuildConfiguration config,
                                                          CarbideCommandLauncher launcher)
Generates the bldmake makefiles if necessary. If abld.bat or any makefiles don't exist, or if the bld.inf or any of its includes is newer than any of the makefiles, then generates the makefiles by running 'bldmake bldfiles platform'.

Parameters:
config - the build configuration context
launcher - the Carbide launcher
Returns:
false if makefile generation was necessary but failed, true otherwise

needsBldmakeMakefileGeneration

protected static boolean needsBldmakeMakefileGeneration(ICarbideBuildConfiguration config)
Check to see if abld.bat and the bldmake makefiles exists, or if they are stale. If abld.bat or any makefiles don't exist, or if the bld.inf or any of its includes is newer than any of the makefiles, then returns true.

Parameters:
config - - The build configuration to check the makefiles for
Returns:
true if makefiles need to be regenerated (bldmake bldfiles platform)

generateAbldMakefilesIfNecessary

public static boolean generateAbldMakefilesIfNecessary(ICarbideBuildConfiguration config,
                                                       CarbideCommandLauncher launcher)
Generates the abld makefiles if necessary. Loops through the mmp files to be built for the given build configuration and generates the makefile for the mmp if: 1) the makefile for the mmp does not exist 2) if the mmp or any of its includes is newer than the makefile 3) the makefile does not have the necessary Carbide changes The command used will be 'abld [test] makefile platform mmpname'

Parameters:
config - the build configuration context
launcher - the Carbide launcher
Returns:
false if any makefile generation was necessary but failed, true otherwise

generateAbldMakefilesIfNecessary

public static boolean generateAbldMakefilesIfNecessary(ICarbideBuildConfiguration config,
                                                       CarbideCommandLauncher launcher,
                                                       boolean calculateComponentLists)
Generates the abld makefiles if necessary. Loops through the mmp files to be built for the given build configuration and generates the makefile for the mmp if: 1) the makefile for the mmp does not exist 2) if the mmp or any of its includes is newer than the makefile 3) the makefile does not have the necessary Carbide changes The command used will be 'abld [test] makefile platform mmpname'

Parameters:
config - the build configuration context
launcher - the Carbide launcher
calculateComponentLists - whether or not to calculate the list of makmake components
Returns:
false if any makefile generation was necessary but failed, true otherwise
Since:
2.0

generateAbldMakefileIfNecessary

protected static boolean generateAbldMakefileIfNecessary(ICarbideBuildConfiguration config,
                                                         CarbideCommandLauncher launcher,
                                                         IPath componentPath,
                                                         boolean isTest)
Generates the abld makefile if necessary. Generates the makefile for the given mmp file if: 1) the makefile for the mmp does not exist 2) if the mmp or any of its includes is newer than the makefile 3) the makefile does not have the necessary Carbide changes The command used will be 'abld [test] makefile platform mmpname'

Parameters:
config - the build configuration context
launcher - the Carbide launcher
componentPath - the absolute file system path of the component
isTest - true for test components, false otherwise
Returns:
false if any makefile generation was necessary but failed, true otherwise

getParserIdArray

public static java.lang.String[] getParserIdArray(int id)
Get the array of parser ID's (extension ID from plugin.xml) that will be used to parse the output of a given process invoked by the CarbideCommandLauncher. If you don't know which parser to use you can use them all by passed ICarbideBuildeConfiguration.ERROR_PARSERS_ALL

Parameters:
id - - The id to use to get the parsers.
Returns:
An array of parser id's to iterate through to find matches in the stdout and stderrr
See Also:
CarbideCommandLauncher, ICarbideBuildConfiguration.ERROR_PARSERS*

removeAllMarkers

public static void removeAllMarkers(IProject currProject)
                             throws CoreException
Remove all the C/C++ markers for the current project.

Parameters:
currProject - - Project to remove markers for.
Throws:
CoreException

invokeSISBuilder

public static void invokeSISBuilder(ICarbideBuildConfiguration config,
                                    CarbideCommandLauncher cmdLauncher,
                                    IProgressMonitor monitor)
Invoke the SIS builder for all pkg files for the given build configuration

Parameters:
config - - The current configuration from where to get the settings from
cmdLauncher - - The object to use for the process execution
monitor - - An IProgressMonitor

invokeSISBuilder

public static void invokeSISBuilder(IPath pkgPath,
                                    ICarbideBuildConfiguration config,
                                    CarbideCommandLauncher cmdLauncher,
                                    IProgressMonitor monitor,
                                    boolean createOutputFromPKGFileName)
Invoke the SIS builder for either EKA1 or EKA2 projects. Depending on the os version will determine if makesis or makeis/signsis will get called

Parameters:
pkgPath - - Full path to the PKG file to be used to generate the SIS file
config - - The current configuration from where to get the settings for
cmdLauncher - - The object to use for the process execution
monitor - - An IProgressMonitor
createOutputFromPKGFileName - - When true, only create output file name based on PKG file name, otherwise check the SIS build settings.

resolvePKGFile

public static IPath resolvePKGFile(IPath pkgFile,
                                   ISymbianBuildContext context,
                                   IPath tempPKGFileName)
Given PKG file to be built, check to see if it has supported macros and if so replace them so the PKG file will contain current build context values.

Parameters:
pkgFile - - The PKG file input
context - - The sdk/plat/target currently building for
tempPKGFileName - - The name of the PKG file to generate. If null or empty string one will be generated for you
Returns:
IPath - If macros don't exist, the input path is returned others the new file that is created, fully resolved is returned.

getPartialUpgradeSisPath

public static IPath getPartialUpgradeSisPath(ICarbideBuildConfiguration config,
                                             IPath sisPath)
Given a sis/sisx path, returns the absolute file system path of the associated partial upgrade sis/sisx file if any, otherwise null. note that the file may or may not exist.

Parameters:
config - the build configuration
sisPath - the absolute file system path to the normal sis/sisx file
Returns:
absolute path to PU sis/sisx file, or null
Since:
2.0

invokeROMBuilder

public static void invokeROMBuilder(ICarbideBuildConfiguration config,
                                    CarbideCommandLauncher cmdLauncher,
                                    IProgressMonitor monitor)
Invoke the ROM builder for the given build configuration

Parameters:
config - - The current configuration from where to get the settings from
cmdLauncher - - The object to use for the process execution
monitor - - An IProgressMonitor

callAbldBuildForConfiguration

public static void callAbldBuildForConfiguration(ICarbideBuildConfiguration config,
                                                 IProgressMonitor monitor,
                                                 IConsole console,
                                                 int buildKind,
                                                 boolean clearMarkers)
Deprecated. use #invokeBuild(ICarbideBuildConfiguration, IConsole, IProgressMonitor) instead

This method performs a build for a given Carbide build configuration.

Parameters:
config - - The Carbide configuration to build
monitor - - A progress monitor so user can cancel build (can be null)
console - - Where to pipe the output. If null, a new CConole will be created and existing console cleared.
buildKind - - FULL_BUILD, else incremental build assumed.

invokeBldmakeBldFiles

public static boolean invokeBldmakeBldFiles(ICarbideBuildConfiguration config,
                                            CarbideCommandLauncher cmdLauncher,
                                            IProgressMonitor monitor,
                                            IConsole console,
                                            java.lang.String[] env,
                                            IPath workingDir)
Deprecated. use #generateBldmakeMakefilesIfNecessary(ICarbideBuildConfiguration, CarbideCommandLauncher, IConsole, IProgressMonitor, boolean) instead

Invoke bldmake bldfiles on the current bld.inf and SDK.

Parameters:
config - - Config to generate makefiles for.
cmdLauncher - - The process launcher
monitor - - The progress monitor
console - - The console to write the messages to.
env - - The array of environment variables to be used for the process
workingDir - - The full path to the bld.inf file to be used as the current working directory

projectNeedsMakefileGeneration

public static boolean projectNeedsMakefileGeneration(IPath bldInfDir,
                                                     ICarbideBuildConfiguration defaultConfig)
Deprecated. use needsBldmakeMakefileGeneration(ICarbideBuildConfiguration)

Check to see if abld.bat and the SDK's platform makefile exists. If either don't exist, re-generate makefiles This also tests to make sure the makefile target is OLDER than the bld.inf file.

Parameters:
bldInfDir - - The working dir of the bld.inf file (should not contain 'bld.inf')
defaultConfig - - The ISymbianBuildConfiguration to be built.
Returns:
true if makefiles need to be regenerated

projectHasBuildErrors

public static boolean projectHasBuildErrors(IProject project)
Checks the Problems view for any error markers.

Parameters:
project - - IProject to check for problem markers
Returns:
true if at least one error marker exists on the project

Carbide.c++