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 (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 CoreBuildLaunchBarTracker. 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
Since:
6.0
  • Constructor Details

    • CBuildConfiguration

      protected CBuildConfiguration(org.eclipse.core.resources.IBuildConfiguration config, String name) throws org.eclipse.core.runtime.CoreException
      Throws:
      org.eclipse.core.runtime.CoreException
    • CBuildConfiguration

      protected CBuildConfiguration(org.eclipse.core.resources.IBuildConfiguration config, String name, IToolChain toolChain)
    • CBuildConfiguration

      protected CBuildConfiguration(org.eclipse.core.resources.IBuildConfiguration config, String name, IToolChain toolChain, String launchMode)
      Since:
      6.2
    • CBuildConfiguration

      protected CBuildConfiguration(org.eclipse.core.resources.IBuildConfiguration config, IToolChain toolChain)
  • Method Details

    • getBuildConfiguration

      public org.eclipse.core.resources.IBuildConfiguration getBuildConfiguration()
      Description copied from interface: ICBuildConfiguration
      Returns the resources build configuration that this CDT build configuration is associated with.
      Specified by:
      getBuildConfiguration in interface ICBuildConfiguration
      Returns:
      resources build configuration
    • getName

      public String getName()
    • getLaunchMode

      public String getLaunchMode()
      Description copied from interface: ICBuildConfiguration
      Return the launch mode associated with this build configuration.
      Specified by:
      getLaunchMode in interface ICBuildConfiguration
      Since:
      6.2
    • setLaunchMode

      protected void setLaunchMode(String launchMode)
      Since:
      6.2
    • getProject

      public org.eclipse.core.resources.IProject getProject()
    • getBinaryParserIds

      public List<String> getBinaryParserIds() throws org.eclipse.core.runtime.CoreException
      Description copied from interface: ICBuildConfiguration
      Ids for the Binary Parsers to use when checking whether a file is a binary that can be launched.
      Specified by:
      getBinaryParserIds in interface ICBuildConfiguration
      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

      public URI getBuildDirectoryURI() throws org.eclipse.core.runtime.CoreException
      Description copied from interface: ICBuildConfiguration2
      The URI for the directory in which the build is executed.
      Specified by:
      getBuildDirectoryURI in interface ICBuildConfiguration2
      Throws:
      org.eclipse.core.runtime.CoreException
    • getBuildDirectory

      public Path getBuildDirectory() throws org.eclipse.core.runtime.CoreException
      Throws:
      org.eclipse.core.runtime.CoreException
    • setBuildEnvironment

      public void setBuildEnvironment(Map<String,String> env)
      Description copied from interface: ICBuildConfiguration
      Set the environment for the builds. Generally the environment from a ProcessBuilder would be passed here.
      Specified by:
      setBuildEnvironment in interface ICBuildConfiguration
      Parameters:
      env - build environment
    • getBuildOutput

      public IBinary[] getBuildOutput() throws org.eclipse.core.runtime.CoreException
      Description copied from interface: ICBuildConfiguration
      The binaries produced by the build.
      Specified by:
      getBuildOutput in interface ICBuildConfiguration
      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

      public IToolChain getToolChain() throws org.eclipse.core.runtime.CoreException
      Description copied from interface: ICBuildConfiguration
      Build Configurations are configurations for a given toolchain.
      Specified by:
      getToolChain in interface ICBuildConfiguration
      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

      public IEnvironmentVariable getVariable(String name)
      Description copied from interface: ICBuildConfiguration
      Return a build environment variable with a given name.
      Specified by:
      getVariable in interface ICBuildConfiguration
      Parameters:
      name - build environment variable name
      Returns:
      value of the build environment variable.
    • getVariables

      public IEnvironmentVariable[] getVariables()
      Description copied from interface: ICBuildConfiguration
      Return all of the build environment variables for this configuration.
      Specified by:
      getVariables in interface ICBuildConfiguration
      Returns:
      environment variables
    • addMarker

      public void addMarker(org.eclipse.core.resources.IResource file, int lineNumber, String errorDesc, int severity, String errorVar)
      Specified by:
      addMarker in interface IMarkerGenerator
    • addMarker

      public void addMarker(ProblemMarkerInfo problemMarkerInfo)
      Specified by:
      addMarker in interface IMarkerGenerator
    • findCommand

      protected Path findCommand(String command)
    • 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:
      IOException
      org.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(forRemoval=true) protected ScannerInfoCache 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

      public IScannerInfo getScannerInformation(org.eclipse.core.resources.IResource resource)
      Description copied from interface: IScannerInfoProvider
      The receiver will answer the current state of the build information for the resource specified in the argument.
      Specified by:
      getScannerInformation in interface IScannerInfoProvider
    • elementChanged

      public void elementChanged(ElementChangedEvent event)
      Description copied from interface: IElementChangedListener
      Notifies 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:
      elementChanged in interface IElementChangedListener
      Parameters:
      event - the change event
    • processLine

      public boolean processLine(String line)
      Description copied from interface: IConsoleParser
      Parse one line of output.
      Specified by:
      processLine in interface IConsoleParser
      Returns:
      true if line was successfully processed; skip other console parsers

      false - try other console parsers

    • processLine

      public boolean processLine(String line, List<org.eclipse.core.runtime.jobs.Job> jobsArray)
      Process a compile line for Scanner info in a separate job
      Specified by:
      processLine in interface IConsoleParser2
      Parameters:
      line - - line to process
      jobsArray - - 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: ICBuildConfiguration2
      Mark the Build Configuration as active
      Specified by:
      setActive in interface ICBuildConfiguration2
      Since:
      6.5
    • setLauncher

      public void setLauncher(ICommandLauncher launcher)
      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: IConsoleParser
      Called 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:
      shutdown in interface IConsoleParser
    • subscribe

      public void subscribe(org.eclipse.core.resources.IResource resource, IScannerInfoChangeListener listener)
      Description copied from interface: IScannerInfoProvider
      The receiver will register the listener specified in the argument to receive change notifications when the information for the IResource it is responsible for changes.
      Specified by:
      subscribe in interface IScannerInfoProvider
    • unsubscribe

      public void unsubscribe(org.eclipse.core.resources.IResource resource, IScannerInfoChangeListener listener)
      Description copied from interface: IScannerInfoProvider
      The receiver will no longer notify the listener specified in the argument when information about the reource it is responsible for changes.
      Specified by:
      unsubscribe in interface IScannerInfoProvider
    • getCommandFromPath

      public static Path getCommandFromPath(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. Also adjusts the command for Windows's .exe extension.
      Since:
      6.1
    • setProperties

      public boolean setProperties(Map<String,String> properties)
      Description copied from interface: ICBuildConfiguration
      Set the properties for this build configuration. These will often come from launch configurations which have build settings as attributes.
      Specified by:
      setProperties in interface ICBuildConfiguration
      Parameters:
      properties - build properties
      Returns:
      whether the properties have changed
      Since:
      6.2
    • getProperties

      public Map<String,String> getProperties()
      Description copied from interface: ICBuildConfiguration
      Return the properties for this build configuration.
      Specified by:
      getProperties in interface ICBuildConfiguration
      Returns:
      default properties
      Since:
      6.2
    • getProperty

      public String getProperty(String name)
      Description copied from interface: ICBuildConfiguration
      Return the named property.
      Specified by:
      getProperty in interface ICBuildConfiguration
      Parameters:
      name - the name of the property
      Since:
      6.4
    • setProperty

      public void setProperty(String name, String value)
      Description copied from interface: ICBuildConfiguration
      Set a property to the given value.
      Specified by:
      setProperty in interface ICBuildConfiguration
      Parameters:
      name - the name of the property
      value - the new value for the property
      Since:
      6.4
    • removeProperty

      public void removeProperty(String name)
      Description copied from interface: ICBuildConfiguration
      Remove the named property.
      Specified by:
      removeProperty in interface ICBuildConfiguration
      Parameters:
      name - name of the property
    • getDefaultProperties

      public Map<String,String> getDefaultProperties()
      Description copied from interface: ICBuildConfiguration
      Returns the default values for the properties.
      Specified by:
      getDefaultProperties in interface ICBuildConfiguration
      Since:
      6.2