Package org.eclipse.cdt.core.build
Class CBuildConfiguration
java.lang.Object
org.eclipse.core.runtime.PlatformObject
org.eclipse.cdt.core.build.CBuildConfiguration
- All Implemented Interfaces:
ICBuildConfiguration,ICBuildConfiguration2,IConsoleParser,IConsoleParser2,IMarkerGenerator,IElementChangedListener,IScannerInfoProvider,org.eclipse.core.runtime.IAdaptable
- Direct Known Subclasses:
StandardBuildConfiguration
public abstract class CBuildConfiguration
extends org.eclipse.core.runtime.PlatformObject
implements ICBuildConfiguration, ICBuildConfiguration2, IMarkerGenerator, IConsoleParser2, IElementChangedListener
Root class for CDT build configurations. Provides access to the build
settings for subclasses.
Each Eclipse project has one or more build configurations (
. The initial configuration for Debug will only be
created if the user selects the Debug launch mode. Restoration of Core Build configurations,
after an Eclipse restart or close and open of the project, uses the settings which are
persistently stored in the backing store. @see org.osgi.service.prefs.Preferences
IBuildConfiguration).
A CDT Core Build project pairs each build configuration with a Core Build configuration
(ICBuildConfiguration). A Core Build configuration has variable config pointing to
the IBuildConfiguration. The link from IBuildConfiguration to ICBuildConfiguration
goes via getAdapter(ICBuildConfiguration.class) which gets the ICBuildConfiguration
from Map configs in the CBuildConfigurationManager.
In a new project the initial Core Build configurations creation is triggered by the
invalid reference
CoreBuildLaunchBarTracker
- Since:
- 6.0
-
Field Summary
Fields inherited from interface org.eclipse.cdt.core.build.ICBuildConfiguration
TOOLCHAIN_ID, TOOLCHAIN_TYPEFields inherited from interface org.eclipse.cdt.core.IMarkerGenerator
SEVERITY_ERROR_BUILD, SEVERITY_ERROR_RESOURCE, SEVERITY_INFO, SEVERITY_WARNING -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCBuildConfiguration(org.eclipse.core.resources.IBuildConfiguration buildConfig, String cBuildConfigName) Use when a Core Build configuration already exists (eg was created usingCBuildConfiguration(IBuildConfiguration, String, IToolChain, String, ILaunchTarget).protectedCBuildConfiguration(org.eclipse.core.resources.IBuildConfiguration buildConfig, String cBuildConfigName, IToolChain toolChain, String launchMode, ILaunchTarget launchTarget) Use when a Core Build configuration is created for the first time. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMarker(ProblemMarkerInfo problemMarkerInfo) voidaddMarker(org.eclipse.core.resources.IResource file, int lineNumber, String errorDesc, int severity, String errorVar) voidNotifies that one or more attributes of one or more C elements have changed.protected PathfindCommand(String command) Ids for the Binary Parsers to use when checking whether a file is a binary that can be launched.org.eclipse.core.resources.IBuildConfigurationReturns the resources build configuration that this CDT build configuration is associated with.org.eclipse.core.resources.IContainerConvenience method to convert getBuildDirectoryURI() to a PathThe URI for the directory in which the build is executed.IBinary[]The binaries produced by the build.static PathgetCommandFromPath(Path command) Takes a command path and returns either the command path itself if it is absolute or the path to the command as it appears in the PATH environment variable.Returns the default values for the properties.Return the launch mode associated with this build configuration.getName()org.eclipse.core.resources.IProjectReturn the properties for this build configuration.getProperty(String name) Return the named property.protected ScannerInfoCacheDeprecated, for removal: This API element is subject to removal in a future version.This method was never used in CDT.getScannerInformation(org.eclipse.core.resources.IResource resource) The receiver will answer the current state of the build information for the resource specified in the argument.protected org.osgi.service.prefs.PreferencesBuild Configurations are configurations for a given toolchain.protected IToolChaingetToolChain(List<String> command) Get the toolchain based on the compiler found in the command line.getVariable(String name) Return a build environment variable with a given name.Return all of the build environment variables for this configuration.protected voidbooleanprocessLine(String line) Parse one line of output.booleanprocessLine(String line, List<org.eclipse.core.runtime.jobs.Job> jobsArray) Process a compile line for Scanner info in a separate jobprotected voidvoidremoveProperty(String name) Remove the named property.protected voidvoidMark the Build Configuration as activevoidsetActive(org.eclipse.core.runtime.IProgressMonitor monitor) voidsetBuildEnvironment(Map<String, String> env) Set the environment for the builds.voidsetLauncher(ICommandLauncher launcher) booleansetProperties(Map<String, String> properties) Set the properties for this build configuration.voidsetProperty(String name, String value) Set a property to the given value.voidshutdown()Called to let the parser know that the end of the error stream has been reached.startBuildProcess(List<String> commands, IEnvironmentVariable[] envVars, org.eclipse.core.runtime.IPath buildDirectory, IConsole console, org.eclipse.core.runtime.IProgressMonitor monitor) voidsubscribe(org.eclipse.core.resources.IResource resource, IScannerInfoChangeListener listener) The receiver will register the listener specified in the argument to receive change notifications when the information for theIResourceit is responsible for changes.voidunsubscribe(org.eclipse.core.resources.IResource resource, IScannerInfoChangeListener listener) The receiver will no longer notify the listener specified in the argument when information about the reource it is responsible for changes.protected intwatchProcess(IConsoleParser[] consoleParsers, org.eclipse.core.runtime.IProgressMonitor monitor) protected intwatchProcess(IConsole console, org.eclipse.core.runtime.IProgressMonitor monitor) Methods inherited from class org.eclipse.core.runtime.PlatformObject
getAdapterMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapterMethods inherited from interface org.eclipse.cdt.core.build.ICBuildConfiguration
build, clean, supportsProperties
-
Constructor Details
-
CBuildConfiguration
protected CBuildConfiguration(org.eclipse.core.resources.IBuildConfiguration buildConfig, String cBuildConfigName) throws org.eclipse.core.runtime.CoreException Use when a Core Build configuration already exists (eg was created usingCBuildConfiguration(IBuildConfiguration, String, IToolChain, String, ILaunchTarget). The toolchain, launch mode and launch target are loaded from preferences.- Parameters:
buildConfig- Platform Build Configuration. Must not be null.cBuildConfigName- Name to give the CMakeBuildConfiguration. Must not be null.- Throws:
org.eclipse.core.runtime.CoreException- if this method fails. Reasons include:- Toolchain is missing,
- Launch mode missing,
- Launch Target is missing.
-
CBuildConfiguration
protected CBuildConfiguration(org.eclipse.core.resources.IBuildConfiguration buildConfig, String cBuildConfigName, IToolChain toolChain, String launchMode, ILaunchTarget launchTarget) Use when a Core Build configuration is created for the first time. The toolchain, launch mode and launch target are saved to preferences. This allows the Core Build configuration to retrieved later (maybe another workbench session), usingCBuildConfiguration(IBuildConfiguration, String)- Parameters:
buildConfig- Platform Build Configuration. Must not be null.cBuildConfigName- Name to give the CMakeBuildConfiguration. Must not be null.toolChain- Toolchain to associate with this CMakeBuildConfiguration. Must not be null.launchMode- Launch mode (eg "debug") to associate with this CMakeBuildConfiguration. Must not be null.launchTarget- Launch target to associate with this CMakeBuildConfiguration. Must not be null.- Since:
- 9.0
-
-
Method Details
-
getBuildConfiguration
public org.eclipse.core.resources.IBuildConfiguration getBuildConfiguration()Description copied from interface:ICBuildConfigurationReturns the resources build configuration that this CDT build configuration is associated with.- Specified by:
getBuildConfigurationin interfaceICBuildConfiguration- Returns:
- resources build configuration
-
getName
-
getLaunchMode
Description copied from interface:ICBuildConfigurationReturn the launch mode associated with this build configuration.- Specified by:
getLaunchModein interfaceICBuildConfiguration- Since:
- 6.2
-
getLaunchTarget
- Specified by:
getLaunchTargetin interfaceICBuildConfiguration
-
getProject
public org.eclipse.core.resources.IProject getProject() -
getBinaryParserIds
Description copied from interface:ICBuildConfigurationIds for the Binary Parsers to use when checking whether a file is a binary that can be launched.- Specified by:
getBinaryParserIdsin interfaceICBuildConfiguration- Returns:
- binary parser ids
- Throws:
org.eclipse.core.runtime.CoreException
-
getBuildContainer
public org.eclipse.core.resources.IContainer getBuildContainer() throws org.eclipse.core.runtime.CoreException- Throws:
org.eclipse.core.runtime.CoreException
-
getBuildDirectoryURI
Description copied from interface:ICBuildConfiguration2The URI for the directory in which the build is executed.- Specified by:
getBuildDirectoryURIin interfaceICBuildConfiguration2- Throws:
org.eclipse.core.runtime.CoreException
-
getBuildDirectory
Convenience method to convert getBuildDirectoryURI() to a Path- Throws:
org.eclipse.core.runtime.CoreException- Restriction:
- This method is not intended to be re-implemented or extended by clients.
-
setBuildEnvironment
Description copied from interface:ICBuildConfigurationSet the environment for the builds. Generally the environment from a ProcessBuilder would be passed here.- Specified by:
setBuildEnvironmentin interfaceICBuildConfiguration- Parameters:
env- build environment
-
getBuildOutput
Description copied from interface:ICBuildConfigurationThe binaries produced by the build.- Specified by:
getBuildOutputin interfaceICBuildConfiguration- Returns:
- binaries produced by the build.
- Throws:
org.eclipse.core.runtime.CoreException- Since:
- 6.1
-
setActive
public void setActive(org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException - Throws:
org.eclipse.core.runtime.CoreException
-
getSettings
protected org.osgi.service.prefs.Preferences getSettings() -
getToolChain
Description copied from interface:ICBuildConfigurationBuild Configurations are configurations for a given toolchain.- Specified by:
getToolChainin interfaceICBuildConfiguration- Returns:
- the toolchain for this build configuration
- Throws:
org.eclipse.core.runtime.CoreException
-
getToolChain
protected IToolChain getToolChain(List<String> command) throws org.eclipse.core.runtime.CoreException Get the toolchain based on the compiler found in the command line. Sub-classes can override this method to set their own method for getting the toolchain.- Throws:
org.eclipse.core.runtime.CoreException- Since:
- 8.0
-
getVariable
Description copied from interface:ICBuildConfigurationReturn a build environment variable with a given name.- Specified by:
getVariablein interfaceICBuildConfiguration- Parameters:
name- build environment variable name- Returns:
- value of the build environment variable.
-
getVariables
Description copied from interface:ICBuildConfigurationReturn all of the build environment variables for this configuration.- Specified by:
getVariablesin interfaceICBuildConfiguration- Returns:
- environment variables
-
addMarker
public void addMarker(org.eclipse.core.resources.IResource file, int lineNumber, String errorDesc, int severity, String errorVar) - Specified by:
addMarkerin interfaceIMarkerGenerator
-
addMarker
- Specified by:
addMarkerin interfaceIMarkerGenerator
-
findCommand
-
startBuildProcess
public Process startBuildProcess(List<String> commands, IEnvironmentVariable[] envVars, org.eclipse.core.runtime.IPath buildDirectory, IConsole console, org.eclipse.core.runtime.IProgressMonitor monitor) throws IOException, org.eclipse.core.runtime.CoreException - Throws:
IOExceptionorg.eclipse.core.runtime.CoreException- Since:
- 6.5
-
watchProcess
protected int watchProcess(IConsole console, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException - Returns:
- The exit code of the build process.
- Throws:
org.eclipse.core.runtime.CoreException- Since:
- 8.0
-
watchProcess
protected int watchProcess(IConsoleParser[] consoleParsers, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException - Returns:
- The exit code of the build process.
- Throws:
org.eclipse.core.runtime.CoreException- Since:
- 8.0
-
loadScannerInfoCache
protected void loadScannerInfoCache()- Since:
- 6.1
-
saveScannerInfoCache
protected void saveScannerInfoCache()- Since:
- 6.1
-
getScannerInfoCache
Deprecated, for removal: This API element is subject to removal in a future version.This method was never used in CDT.- Since:
- 6.1
-
getScannerInformation
Description copied from interface:IScannerInfoProviderThe receiver will answer the current state of the build information for the resource specified in the argument.- Specified by:
getScannerInformationin interfaceIScannerInfoProvider
-
elementChanged
Description copied from interface:IElementChangedListenerNotifies that one or more attributes of one or more C elements have changed. The specific details of the change are described by the given event.- Specified by:
elementChangedin interfaceIElementChangedListener- Parameters:
event- the change event
-
processLine
Description copied from interface:IConsoleParserParse one line of output.- Specified by:
processLinein interfaceIConsoleParser- Parameters:
line-- Returns:
- true if line was successfully processed; skip other console parsers
false - try other console parsers
-
processLine
Process a compile line for Scanner info in a separate job- Specified by:
processLinein interfaceIConsoleParser2- Parameters:
line- - line to processjobsArray- - array of Jobs to keep track of open scanner info jobs- Returns:
- - true if line processed, false otherwise
- Since:
- 6.5
-
setActive
public void setActive()Description copied from interface:ICBuildConfiguration2Mark the Build Configuration as active- Specified by:
setActivein interfaceICBuildConfiguration2- Since:
- 6.5
-
setLauncher
- Parameters:
launcher- - launcher to set- Since:
- 8.3
-
refreshScannerInfo
protected void refreshScannerInfo() throws org.eclipse.core.runtime.CoreException- Throws:
org.eclipse.core.runtime.CoreException- Since:
- 6.5
-
shutdown
public void shutdown()Description copied from interface:IConsoleParserCalled to let the parser know that the end of the error stream has been reached. Can be used by the parser to flush its internal buffers.- Specified by:
shutdownin interfaceIConsoleParser
-
subscribe
public void subscribe(org.eclipse.core.resources.IResource resource, IScannerInfoChangeListener listener) Description copied from interface:IScannerInfoProviderThe receiver will register the listener specified in the argument to receive change notifications when the information for theIResourceit is responsible for changes.- Specified by:
subscribein interfaceIScannerInfoProvider- Parameters:
listener-
-
unsubscribe
public void unsubscribe(org.eclipse.core.resources.IResource resource, IScannerInfoChangeListener listener) Description copied from interface:IScannerInfoProviderThe receiver will no longer notify the listener specified in the argument when information about the reource it is responsible for changes.- Specified by:
unsubscribein interfaceIScannerInfoProvider- Parameters:
listener-
-
getCommandFromPath
Takes a command path and returns either the command path itself if it is absolute or the path to the command as it appears in the PATH environment variable. Also adjusts the command for Windows's .exe extension.- Since:
- 6.1
-
setProperties
Description copied from interface:ICBuildConfigurationSet the properties for this build configuration. These will often come from launch configurations which have build settings as attributes.- Specified by:
setPropertiesin interfaceICBuildConfiguration- Parameters:
properties- build properties- Returns:
- whether the properties have changed
- Since:
- 6.2
-
getProperties
Description copied from interface:ICBuildConfigurationReturn the properties for this build configuration.- Specified by:
getPropertiesin interfaceICBuildConfiguration- Returns:
- default properties
- Since:
- 6.2
-
getProperty
Description copied from interface:ICBuildConfigurationReturn the named property.- Specified by:
getPropertyin interfaceICBuildConfiguration- Parameters:
name- the name of the property- Since:
- 6.4
-
setProperty
Description copied from interface:ICBuildConfigurationSet a property to the given value.- Specified by:
setPropertyin interfaceICBuildConfiguration- Parameters:
name- the name of the propertyvalue- the new value for the property- Since:
- 6.4
-
removeProperty
Description copied from interface:ICBuildConfigurationRemove the named property.- Specified by:
removePropertyin interfaceICBuildConfiguration- Parameters:
name- name of the property
-
getDefaultProperties
Description copied from interface:ICBuildConfigurationReturns the default values for the properties.- Specified by:
getDefaultPropertiesin interfaceICBuildConfiguration- Since:
- 6.2
-