terp - the ANT Tasks
v1.3.337

com.codemesh.terp.ant.compiler.cpp
Class CppCompilerImpl

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by com.codemesh.terp.ant.compiler.cpp.CppCompilerImpl
All Implemented Interfaces:
Compiler<CppCompiler>, CppCompiler, CppCompilerOptions, TerpAware, TerpContextHolder, java.lang.Cloneable
Direct Known Subclasses:
Acc.Impl, Gcc.Impl, Icc.Impl, Msvc.Impl, Qcc.Impl, Suncc.Impl, Xlc.Impl

public class CppCompilerImpl
extends org.apache.tools.ant.Task
implements CppCompiler

The generic base implementation of a C++ compiler task.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.codemesh.terp.ant.compiler.cpp.CppCompiler
CppCompiler.SourceToTargets
 
Nested classes/interfaces inherited from interface com.codemesh.terp.ant.TerpAware
TerpAware.Delegate
 
Field Summary
protected  TerpAware.Delegate aware
           
protected  java.lang.String batchSize
           
protected  java.lang.String bom
           
protected  java.lang.String cleanup
           
protected  Cpp.CppExecutor compiler
           
static java.lang.String COMPILER_OPTIONS
           
protected  java.lang.String compilerString
           
protected  java.lang.String cppExtensions
           
protected  java.util.Set<java.io.File> createdFiles
           
protected  java.lang.String createDirs
           
protected  TerpContext ctx
           
protected  java.lang.String defExtensions
           
protected  java.lang.String depends
           
protected  java.lang.String failOnError
           
protected  java.lang.String forcecompile
           
protected  java.lang.String iconExtensions
           
protected  java.lang.String libExtensions
           
static java.lang.String LINKER_OPTIONS
           
protected  java.lang.String maxParallel
           
protected  java.lang.String objExtensions
           
protected  CompilerOptionSet<CppCompiler> options
           
protected  java.lang.String parallel
           
protected  java.util.Vector<TerpSequential> postBuilds
           
protected  java.util.Vector<TerpSequential> preBuilds
           
protected  java.lang.String rcExtensions
           
protected  java.lang.String resExtensions
           
protected  java.lang.String showOnly
           
protected  java.lang.String targetDir
           
protected  java.lang.String targetNameProperty
           
protected  java.lang.String tempDir
           
static ToFile TO_FILE
           
static ToInteger TO_INT
           
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
CppCompilerImpl()
           
CppCompilerImpl(org.apache.tools.ant.Project p)
           
 
Method Summary
 void addOption(CompilerOption<CppCompiler> option)
          Adds a precreated option to the list of compiler options.
protected  void clearDependencies()
           
protected  java.io.File createArchive(java.util.List<CppCompiler.SourceToTargets> s2ts, TargetOption optTarget, ProcArchOption optPa)
           
 BoundsCheckOption createBoundsCheck()
          Creates a BoundsChecker option.
 CompileOnlyOption createCompileOnly()
          Creates a compile-only option (/c or -c).
 DebugOption createDebug()
          Creates a debug option.
 DefineOption createDefine()
          Creates a preprocessor definition.
protected  void createDirsIfNecessary(boolean bCreateDirs, java.io.File fTargetDir, java.io.File fTempDir)
           
 DynamicSourcesOption createDynamicSources()
          Creates a nested task container that groups TerpEcho tasks which are used to dynamically generate source code files that are automatically added to the compilation.
 ExceptionsOption createExceptions()
          Creates an option that can be used to en/disable exception support.
 VsProjectOption createGenerateVsProject()
          Creates an option that generates a VisualStudio project file.
 IncludeOption createInclude()
          Creates an option that adds one or more directories to the preprocessor search path.
 LibpathOption createLibpath()
          Creates an option that adds one or more directories to the library search path.
 LibraryOption createLibrary()
          Creates an option that specifies one or more libraries to link with.
protected  void createLinksIfNecessary(TargetOption optTarget)
           
 ManifestOption createManifest()
          Not used yet.
 MultithreadedOption createMultithreaded()
          Creates an option that governs whether or not multithreading is enabled.
 ObjectsOption createObjects()
          Creates an option that adds already compiled object files to the build.
 OptimizeOption createOptimize()
          Creates an option that controls compiler optimizations.
 GenericOption createOption()
          Creates a generic option.
 OptionsOption createOptions()
          Creates an option representing a reference to an external options collection.
 TerpSequential createPostBuild()
          Creates a task container that is executed after the compiler chas been invoked.
 TerpSequential createPreBuild()
          Creates a task container that is executed before any compiler commands are invoked.
 ProcArchOption createProcArch()
          Creates an option that specifies the processor architecture for which we're building.
 ProfileOption createProfile()
          Creates an option that instruments the code with profiling support.
 QuietOption createQuiet()
          Creates an option that controls compiler verbosity.
 RelocatableOption createRelocatable()
          Creates an option that controls whether or not the generated modules are relocatable in memory.
 ResourceOption createResource()
          Creates an option that dynamically generates a resource file.
protected  java.io.File createResponseFile(java.lang.String commandLine, java.util.List<CppCompiler.SourceToTargets> s2ts)
           
 RttiOption createRtti()
          Creates an option that can be used to en/disable RTTI support.
 RunpathOption createRunpath()
          Creates an option that can be used to embed a runpath in a module.
 RuntimeOption createRuntime()
          Creates an option that specifies the type of C++ runtime library to use.
 SourcesOption createSources()
          Creates an option that adds source files to the build.
 TargetOption createTarget()
          Creates an option that governs name, version, and type of build target.
 UndefineOption createUndefine()
          Creates an option that undefines a preprocessor definition.
 WarningsOption createWarning()
          Creates an option that adjusts the warning level or specific warnings.
protected  void doCleanup(boolean bCompileOnly)
           
protected  com.codemesh.terp.ant.compiler.cpp.CppCompilerImpl.CompilerPhaseResult doCompile(boolean bCompileOnly)
           
protected  com.codemesh.terp.ant.compiler.cpp.CppCompilerImpl.CompilerPhaseResult doDepends(boolean bMadeChanges)
           
protected  com.codemesh.terp.ant.compiler.cpp.CppCompilerImpl.CompilerPhaseResult doLink(boolean bMadeChanges)
           
protected  void doPostLink()
           
protected  com.codemesh.terp.ant.compiler.cpp.CppCompilerImpl.CompilerPhaseResult doPreCompile()
           
 void execute()
          Executes the C++ compiler task if all execution conditions have been met and a suitable compiler was configured.
protected  java.lang.String expand(java.lang.String str)
          A utility method that expands a terp template string property.
protected  java.lang.String expand(java.lang.String str, java.lang.String propName)
           
 java.io.File getBaseDir()
          Returns a directory treated as the base directory for the compilation operation.
 java.lang.String getBOM()
          Returns the configured BOM value.
 java.lang.String getCode()
          Returns the compiler's code.
 java.util.List<CppCompiler.SourceToTargets> getCompilationSources(boolean bIncludeDynamics)
          Returns a list of compilation sources and the targets they're tied to.
 Cpp.CppExecutor getCompiler()
          Returns the compiler executor being used.
 TerpContext getContext()
          Returns the terp context in which the conpiler is executing.
 boolean getCreateDirs()
          Returns true if the temporary and target directories should be created if necessary.
 java.lang.String getIf()
          Returns the condition that must be satidifed to execute the implementing task.
protected  java.util.List<CppCompiler.SourceToTargets> getLinkSources(boolean bIncludeDynamics)
           
 CompilerOptionSet<CppCompiler> getOptions()
          Returns an object that keeps track of all configured compiler options.
protected  java.util.regex.Pattern getPattern(java.lang.String patSrc, java.lang.String description)
           
 ProcArch getProcArch()
           
 boolean getShowOnly()
           
 java.lang.String getTargetDir()
          Return the configured target directory in which build outputs are created.
 java.lang.String getTargetNameProperty()
          Return the name of a property that will hold the name of the primary build result of the compiler invocation.
 java.lang.String getTempDir()
           
 java.util.Map<java.lang.String,java.lang.Object> getTraits()
          Returns the map of known compiler traits.
 java.lang.String getUnless()
          Returns the condition that must not be satidifed to execute the implementing task.
 Version getVersion()
          Returns the compiler version or null.
protected  void populateDependencies(CppCompiler.SourceToTargets sourceToTargets)
           
 boolean satisfiesConditions()
          Returns true if both conditions are met.
 void setBatchSize(java.lang.String batchSize)
          Sets the number of source files that will be given to the compiler in one invocation.
 void setBOM(java.lang.String bom)
          Sets the file that will contain the generated bill of materials, i.e.
 void setCleanup(java.lang.String cleanup)
          Set to true if result and intermediate files should be deleted rather than created.
 void setCompiler(java.lang.String compiler)
          Specify the compiler that is to be used.
 void setContext(TerpContext ctx)
          Sets the context maintained by this instance.
 void setCppExtensions(java.lang.String cppExts)
          Sets the extensions that are interpreted as C/C++ sources that are passed to the compiler.
 void setCreateDirs(java.lang.String create)
          Create target and intermdiate directories if they don't already exist.
 void setDefinitionFileExtensions(java.lang.String defExts)
          
 void setDepends(java.lang.String depends)
          Set to true if dependency files should be generated (if necessary).
 void setFailOnError(java.lang.String foe)
          True if compiler wrapper should abort when a compilation error is encountered.
 void setForceBuild(java.lang.String fb)
          True if compiler wrapper should always perform the buildsteps, whether required based on dependency analysis or not.
 void setIconFileExtensions(java.lang.String iconExts)
          
 void setIf(java.lang.String condition)
          Sets a condition that must be satisfied to execute the implementing task.
 void setMaxParallel(java.lang.String maxParallel)
          Specifies how many compiler invocations may run in parallel.
 void setParallel(java.lang.String parallel)
          True if parallel mode is enabled.
 void setProject(org.apache.tools.ant.Project p)
           
 void setResourceFileExtensions(java.lang.String resExts)
          
 void setResourceSourceFileExtensions(java.lang.String rcExts)
          
 void setShowOnly(java.lang.String so)
          Suppresses actual tool invocations and only shows the commands that would be executed.
 void setTargetDir(java.lang.String targetDir)
          The target directory to which output files (exe, dll, archive) are written.
 void setTargetNameProperty(java.lang.String propertyName)
          The name of a property that will hold the name of the primary build result of the compiler invocation.
 void setTempDir(java.lang.String tempDir)
          The temporary directory to which intermediary files (obj, etc.) are written.
 void setUnless(java.lang.String condition)
          Sets a condition that must not be satisfied to execute the implementing task.
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TO_INT

public static final ToInteger TO_INT

TO_FILE

public static final ToFile TO_FILE

COMPILER_OPTIONS

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

LINKER_OPTIONS

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

aware

protected TerpAware.Delegate aware

ctx

protected TerpContext ctx

options

protected CompilerOptionSet<CppCompiler> options

preBuilds

protected java.util.Vector<TerpSequential> preBuilds

postBuilds

protected java.util.Vector<TerpSequential> postBuilds

bom

protected java.lang.String bom

batchSize

protected java.lang.String batchSize

cleanup

protected java.lang.String cleanup

depends

protected java.lang.String depends

compiler

protected Cpp.CppExecutor compiler

compilerString

protected java.lang.String compilerString

createDirs

protected java.lang.String createDirs

cppExtensions

protected java.lang.String cppExtensions

defExtensions

protected java.lang.String defExtensions

iconExtensions

protected java.lang.String iconExtensions

objExtensions

protected java.lang.String objExtensions

failOnError

protected java.lang.String failOnError

forcecompile

protected java.lang.String forcecompile

libExtensions

protected java.lang.String libExtensions

maxParallel

protected java.lang.String maxParallel

parallel

protected java.lang.String parallel

rcExtensions

protected java.lang.String rcExtensions

resExtensions

protected java.lang.String resExtensions

showOnly

protected java.lang.String showOnly

tempDir

protected java.lang.String tempDir

targetDir

protected java.lang.String targetDir

targetNameProperty

protected java.lang.String targetNameProperty

createdFiles

protected java.util.Set<java.io.File> createdFiles
Constructor Detail

CppCompilerImpl

public CppCompilerImpl()

CppCompilerImpl

public CppCompilerImpl(org.apache.tools.ant.Project p)
Method Detail

setProject

public void setProject(org.apache.tools.ant.Project p)
Overrides:
setProject in class org.apache.tools.ant.ProjectComponent

setContext

public void setContext(TerpContext ctx)
Sets the context maintained by this instance.

Specified by:
setContext in interface TerpContextHolder
Parameters:
ctx - the execution context.

getContext

public TerpContext getContext()
Returns the terp context in which the conpiler is executing.

Specified by:
getContext in interface Compiler<CppCompiler>
Specified by:
getContext in interface TerpContextHolder
Returns:
the terp context.

setCompiler

public void setCompiler(java.lang.String compiler)
Specify the compiler that is to be used. The compiler specifier works in conjunction with the task type. The compiler specifier should consist of a terp expression that can be converted to a C++ compiler executor. Here are some examples:

Example 1

The simplest and most generic compiler specifier is probably

 compiler="{}"
 
It specifies an empty list, i.e. no configuration arguments. That leaves the terp framework with complete freedom to pick a compiler.

Example 2

In this example, we specify a compiler by version number.

 compiler="{version:3.4}"
 
This would for example successfully pick a g++ 3.4.6 compiler if one had been identified by the framework. This is also synonymous with the simplified form of
 compiler="3.4"
 
A numeric string is always interpreted as a version number. Just be careful with version numbers like "13.10" because they degenerate to the number 13.1 which does not match 13.10. In this case you will have to use a string version number as in:
 compiler="{version:&quot;13.10&quot;}"
 

Example 3

You can also create a compiler specifier from a compiler executable:
 compiler="{compiler:"C:/Program Files/Microsoft Visual Studio 8/VC/bin/cl.exe"}"
 
In this case, the terp framework will figure out version numbers and other compiler attributes via compiler reflection.

Example 4

The terp C++ compiler abstraction is most powerful when you have to build your software with multiple compiler versions, in multiple configurations. consider the following example:

 <terp.foreach name="pa" expression="{x86,amd64}">
   <terp.foreach name="vers" expression="{13,14,15}">
     <terp.foreach name="debug" expression="{true,false}">
       <terp.cpp compiler="^msvc({procarch:pa, version:vers})"
                 targetDir="${basedir}/out/${pa}/v${vers}/${if(debug)}debug${else}release$end}"
                 tempDir="${basedir}/temp/${pa}/v${vers}/${if(debug)}debug${else}release$end}"
       >
         <debug value="${debug}"/>
         ...
       </terp.foreach>
     </terp.foreach>
   </terp.foreach>
 </terp.foreach>
 
In this example we have a triple-nested loop over processor architectures, compiler versions, and release vs. debug build mode. The compiler invoked inside the nested loops and always picks the correct compiler executable

Specified by:
setCompiler in interface CppCompiler
Parameters:
compiler - the compiler specifier.

getCompiler

public Cpp.CppExecutor getCompiler()
Returns the compiler executor being used.

Specified by:
getCompiler in interface CppCompiler
Returns:
a compiler executor.

getTraits

public java.util.Map<java.lang.String,java.lang.Object> getTraits()
Returns the map of known compiler traits. Compiler traits are properties that are determined either via compiler reflection or via the built-in expert system that comes with terp.

Specified by:
getTraits in interface CppCompiler
Returns:
the map of traits.

getBaseDir

public java.io.File getBaseDir()
Returns a directory treated as the base directory for the compilation operation. This directory will typically be the ANT project's basedir, but if the CppCompiler interface were implemented by a type that does not extend ANT Task, it could be derived from another build variable.

The purpose of this function is to provide a reference location for the creation of relative paths, for example when generating VisualStudio projects.

In this case, the ANT project's base directory is returned.

Specified by:
getBaseDir in interface CppCompiler
Returns:
the compilation's reference directory.

getProcArch

public ProcArch getProcArch()

setBOM

public void setBOM(java.lang.String bom)
Sets the file that will contain the generated bill of materials, i.e. the source files, the build options, etc. This value can be expanded by terp.

Specified by:
setBOM in interface CppCompiler
Parameters:
bom - the filename.

getBOM

public java.lang.String getBOM()
Returns the configured BOM value.

Returns:
the BOM.

setBatchSize

public void setBatchSize(java.lang.String batchSize)
Sets the number of source files that will be given to the compiler in one invocation. If the total set of sources is larger, the compiler will be invoked multiple times.

Specified by:
setBatchSize in interface CppCompiler
Parameters:
batchSize - the number of sources in one compiler invocation.

setCleanup

public void setCleanup(java.lang.String cleanup)
Set to true if result and intermediate files should be deleted rather than created.

Specified by:
setCleanup in interface CppCompiler
Parameters:
cleanup - true for cleanup, false for regular compilation.

setDepends

public void setDepends(java.lang.String depends)
Set to true if dependency files should be generated (if necessary).

Specified by:
setDepends in interface CppCompiler
Parameters:
depends - true if dependency files should be generated, false if not.

setCppExtensions

public void setCppExtensions(java.lang.String cppExts)
Sets the extensions that are interpreted as C/C++ sources that are passed to the compiler.

Specified by:
setCppExtensions in interface CppCompiler
Parameters:
cppExts - a comma- or semicolon-separated list of extensions.

setDefinitionFileExtensions

public void setDefinitionFileExtensions(java.lang.String defExts)


setIconFileExtensions

public void setIconFileExtensions(java.lang.String iconExts)


setCreateDirs

public void setCreateDirs(java.lang.String create)
Create target and intermdiate directories if they don't already exist.

Specified by:
setCreateDirs in interface CppCompiler
Parameters:
create - true if directories should be created, false otherwise.

getCreateDirs

public boolean getCreateDirs()
Returns true if the temporary and target directories should be created if necessary.

Specified by:
getCreateDirs in interface CppCompiler
Returns:
true if output directories should be created.

setFailOnError

public void setFailOnError(java.lang.String foe)
True if compiler wrapper should abort when a compilation error is encountered. The default value is true.

Specified by:
setFailOnError in interface CppCompiler
Parameters:
foe - true when compilation should be terminated in case of error.

setForceBuild

public void setForceBuild(java.lang.String fb)
True if compiler wrapper should always perform the buildsteps, whether required based on dependency analysis or not.

Specified by:
setForceBuild in interface CppCompiler
Parameters:
fb - true when buildsteps should be performed unconditionally.

setMaxParallel

public void setMaxParallel(java.lang.String maxParallel)
Specifies how many compiler invocations may run in parallel.

Specified by:
setMaxParallel in interface CppCompiler
Parameters:
maxParallel - the maximum number of parallel invocations.

setParallel

public void setParallel(java.lang.String parallel)
True if parallel mode is enabled.

Specified by:
setParallel in interface CppCompiler
Parameters:
parallel - parallel mode.

setShowOnly

public void setShowOnly(java.lang.String so)
Suppresses actual tool invocations and only shows the commands that would be executed. Similar to the -dryrun option provided by some compilers, but implemented in the compiler wrapper.

Specified by:
setShowOnly in interface CppCompiler
Parameters:
so - true when tool invocations should be suppressed.

getShowOnly

public boolean getShowOnly()

setResourceSourceFileExtensions

public void setResourceSourceFileExtensions(java.lang.String rcExts)


setResourceFileExtensions

public void setResourceFileExtensions(java.lang.String resExts)


setTargetDir

public void setTargetDir(java.lang.String targetDir)
The target directory to which output files (exe, dll, archive) are written. This directory is terp expanded.

Specified by:
setTargetDir in interface CppCompiler
Parameters:
targetDir - the output directory.

getTargetDir

public java.lang.String getTargetDir()
Return the configured target directory in which build outputs are created.

Specified by:
getTargetDir in interface CppCompiler
Returns:
the target directory.

getTargetNameProperty

public java.lang.String getTargetNameProperty()
Return the name of a property that will hold the name of the primary build result of the compiler invocation. By default, this method returns null, i.e. the compiler invocation does not create a property holding the name of a file.

Specified by:
getTargetNameProperty in interface CppCompiler
Returns:
a property name or null.

setTargetNameProperty

public void setTargetNameProperty(java.lang.String propertyName)
The name of a property that will hold the name of the primary build result of the compiler invocation. This property can subsequently be used to test whether the file was created or not.

Specified by:
setTargetNameProperty in interface CppCompiler
Parameters:
propertyName - a property name.

setTempDir

public void setTempDir(java.lang.String tempDir)
The temporary directory to which intermediary files (obj, etc.) are written.

Specified by:
setTempDir in interface CppCompiler
Parameters:
tempDir - the intermediate file directory.

getTempDir

public java.lang.String getTempDir()

expand

protected java.lang.String expand(java.lang.String str)
A utility method that expands a terp template string property.

Parameters:
str - the terp template string.
Returns:
the expanded value.

expand

protected java.lang.String expand(java.lang.String str,
                                  java.lang.String propName)

getCode

public java.lang.String getCode()
Returns the compiler's code. The compiler code is determined using the following algorithm:
  1. if a compiler has been set, ask it for its code.
  2. otherwise inspect the compiler wrapper type for certain marker interfaces. If it implements on e of them, return the corresponding code.

Specified by:
getCode in interface Compiler<CppCompiler>
Returns:
a compiler code or null.

getVersion

public Version getVersion()
Returns the compiler version or null.

Specified by:
getVersion in interface Compiler<CppCompiler>
Returns:
the compiler version, if a compiler has been specified.

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Executes the C++ compiler task if all execution conditions have been met and a suitable compiler was configured.

Overrides:
execute in class org.apache.tools.ant.Task
Throws:
org.apache.tools.ant.BuildException

doCleanup

protected void doCleanup(boolean bCompileOnly)

doDepends

protected com.codemesh.terp.ant.compiler.cpp.CppCompilerImpl.CompilerPhaseResult doDepends(boolean bMadeChanges)

populateDependencies

protected void populateDependencies(CppCompiler.SourceToTargets sourceToTargets)

clearDependencies

protected void clearDependencies()

doPreCompile

protected com.codemesh.terp.ant.compiler.cpp.CppCompilerImpl.CompilerPhaseResult doPreCompile()

doCompile

protected com.codemesh.terp.ant.compiler.cpp.CppCompilerImpl.CompilerPhaseResult doCompile(boolean bCompileOnly)

doLink

protected com.codemesh.terp.ant.compiler.cpp.CppCompilerImpl.CompilerPhaseResult doLink(boolean bMadeChanges)

doPostLink

protected void doPostLink()

createLinksIfNecessary

protected void createLinksIfNecessary(TargetOption optTarget)

createArchive

protected java.io.File createArchive(java.util.List<CppCompiler.SourceToTargets> s2ts,
                                     TargetOption optTarget,
                                     ProcArchOption optPa)

createResponseFile

protected java.io.File createResponseFile(java.lang.String commandLine,
                                          java.util.List<CppCompiler.SourceToTargets> s2ts)
                                   throws java.io.IOException
Throws:
java.io.IOException

getCompilationSources

public java.util.List<CppCompiler.SourceToTargets> getCompilationSources(boolean bIncludeDynamics)
Returns a list of compilation sources and the targets they're tied to.

Specified by:
getCompilationSources in interface CppCompiler
Parameters:
bIncludeDynamics - true if dynamically generated sources should be included.
Returns:
a list of source-to-target instances.

getLinkSources

protected java.util.List<CppCompiler.SourceToTargets> getLinkSources(boolean bIncludeDynamics)

getPattern

protected java.util.regex.Pattern getPattern(java.lang.String patSrc,
                                             java.lang.String description)

createDirsIfNecessary

protected void createDirsIfNecessary(boolean bCreateDirs,
                                     java.io.File fTargetDir,
                                     java.io.File fTempDir)

addOption

public void addOption(CompilerOption<CppCompiler> option)
Adds a precreated option to the list of compiler options.

Specified by:
addOption in interface Compiler<CppCompiler>
Parameters:
option - the option to add.

getOptions

public CompilerOptionSet<CppCompiler> getOptions()
Returns an object that keeps track of all configured compiler options.

Specified by:
getOptions in interface Compiler<CppCompiler>
Specified by:
getOptions in interface CppCompilerOptions
Returns:
an object that tracks all options.

getIf

public java.lang.String getIf()
Returns the condition that must be satidifed to execute the implementing task.

Specified by:
getIf in interface TerpAware
Returns:
the boolean expression.

setIf

public void setIf(java.lang.String condition)
Sets a condition that must be satisfied to execute the implementing task.

Specified by:
setIf in interface TerpAware
Parameters:
condition - a terp expression that must evaluate to a boolean value.

getUnless

public java.lang.String getUnless()
Returns the condition that must not be satidifed to execute the implementing task.

Specified by:
getUnless in interface TerpAware
Returns:
the boolean expression.

setUnless

public void setUnless(java.lang.String condition)
Sets a condition that must not be satisfied to execute the implementing task.

Specified by:
setUnless in interface TerpAware
Parameters:
condition - a terp expression that must evaluate to a boolean value.

satisfiesConditions

public boolean satisfiesConditions()
Returns true if both conditions are met.

Specified by:
satisfiesConditions in interface TerpAware
Returns:
true or false.

createBoundsCheck

public BoundsCheckOption createBoundsCheck()
Creates a BoundsChecker option. A BoundsChecker option is only useful for MSVC++ builds and instructs the compiler task to instrument the compiled code for use by BoundsChecker. Obviously, for this to work, BoundsChecker needs to be installed and locatable.

Specified by:
createBoundsCheck in interface CppCompilerOptions
Returns:
a newly created BoundscheckOption.

createCompileOnly

public CompileOnlyOption createCompileOnly()
Creates a compile-only option (/c or -c). You should only have one enabled instance of this type in your compiler task.

Specified by:
createCompileOnly in interface CppCompilerOptions
Returns:
a newly created CompileOnlyOption.

createDebug

public DebugOption createDebug()
Creates a debug option. The debug option allows you to specify whether you wish to include debug information in the build result or not.

You should only have one enabled instance of this type in your compiler task. The debug option interacts with a number of other options (for example the RuntimeOption).

Specified by:
createDebug in interface CppCompilerOptions
Returns:
a newly created DebugOption.

createDefine

public DefineOption createDefine()
Creates a preprocessor definition.

Specified by:
createDefine in interface CppCompilerOptions
Returns:
a newly created DefineOption.

createDynamicSources

public DynamicSourcesOption createDynamicSources()
Creates a nested task container that groups TerpEcho tasks which are used to dynamically generate source code files that are automatically added to the compilation. This option is extremely useful for the generation of source code that derives information from the context at runtime. You can for example embedd information about the version, the compiler, the compiler options, etc. in the source code to provide an info API.

Specified by:
createDynamicSources in interface CppCompiler
Returns:
a task container containing tasks that generate dynamic sources.

createExceptions

public ExceptionsOption createExceptions()
Creates an option that can be used to en/disable exception support. Not all compilers support programmatic control of exception support, so take care with this option. Don't use it unless you're sure you know what you're doing.

Specified by:
createExceptions in interface CppCompilerOptions
Returns:
a newly created ExceptionsOption.

createGenerateVsProject

public VsProjectOption createGenerateVsProject()
Creates an option that generates a VisualStudio project file. This option only applies to the MSVC++ and Intel C++ compilers on Windows but it is harmless when used with other compilers or platforms.

Specified by:
createGenerateVsProject in interface CppCompiler
Returns:
a newly created GenerateVsProject.

createInclude

public IncludeOption createInclude()
Creates an option that adds one or more directories to the preprocessor search path.

Specified by:
createInclude in interface CppCompilerOptions
Returns:
a newly created IncludeOption.

createLibpath

public LibpathOption createLibpath()
Creates an option that adds one or more directories to the library search path.

Specified by:
createLibpath in interface CppCompilerOptions
Returns:
a newly created LibpathOption.

createLibrary

public LibraryOption createLibrary()
Creates an option that specifies one or more libraries to link with. The option supports more than one library via a comma- or semicolon- separated list. Don't use directory names here. Don't use file extensions; they are automatically added.

Specified by:
createLibrary in interface CppCompilerOptions
Returns:
a newly created LibraryOption.

createManifest

public ManifestOption createManifest()
Not used yet.

Specified by:
createManifest in interface CppCompilerOptions
Returns:
a newly created ManifestOption.

createMultithreaded

public MultithreadedOption createMultithreaded()
Creates an option that governs whether or not multithreading is enabled. This is a simple boolean option that influences several other options, for example RuntimeOption. It can result in several different switches being added to the compiler invocation in multiple phases. Don't use more than one enabled option of this type.

Specified by:
createMultithreaded in interface CppCompilerOptions
Returns:
a newly created MultithreadedOption.

createObjects

public ObjectsOption createObjects()
Creates an option that adds already compiled object files to the build. Adding object files that have been compiled with a different set of compiler switches is a recipe for disaster, so be very careful when using this option.

Specified by:
createObjects in interface CppCompiler
Returns:
a newly created ObjectsOption.

createOptimize

public OptimizeOption createOptimize()
Creates an option that controls compiler optimizations.

Specified by:
createOptimize in interface CppCompilerOptions
Returns:
a newly created OptimizeOption.

createOption

public GenericOption createOption()
Creates a generic option. A generic option does not have any smarts about its interaction with other options or with the compiler. You specify to which compiler it applies, you specify to which compiler phase it applies, you're in charge of resolving conflicts with other options. GenericOptions are teh escape hatch of the C++ compiler. They allow you to pass any compiler switch you want but you're completely on your own in managing them and figuring them out.

Specified by:
createOption in interface CppCompilerOptions
Returns:
a newly created GenericOption.

createOptions

public OptionsOption createOptions()
Creates an option representing a reference to an external options collection. The external options collection is identified by an object id. If no external options collection

Specified by:
createOptions in interface CppCompiler
Returns:
a reference to the external options collection.

createPostBuild

public TerpSequential createPostBuild()
Creates a task container that is executed after the compiler chas been invoked. This could be used to clean up after a build, to stage files to different locations, to post-process build results (strip, instrument,...) or really anything you want.

Specified by:
createPostBuild in interface CppCompiler
Returns:
a task container.

createPreBuild

public TerpSequential createPreBuild()
Creates a task container that is executed before any compiler commands are invoked. This could be used to instrument source code or check additional code out of source control, or really anything you want.

Specified by:
createPreBuild in interface CppCompiler
Returns:
a task container.

createProcArch

public ProcArchOption createProcArch()
Creates an option that specifies the processor architecture for which we're building. Processor architectures are an interesting issue. With some compilers, there are different executables for different processor architectures and all you do is choose the proper compiler; you don't supply a compiler option. With other compilers, the same compiler executable can generate code for more than one processor architecture. Typically, support is limited to building a 32-bit or a 64-bit version, but on MacOS X you can build so-called universal binaries that include several architectures at once.

Specified by:
createProcArch in interface CppCompiler
Returns:
a newly created ProcArchOption.

createProfile

public ProfileOption createProfile()
Creates an option that instruments the code with profiling support.

Specified by:
createProfile in interface CppCompiler
Returns:
a newly created ProfileOption.

createQuiet

public QuietOption createQuiet()
Creates an option that controls compiler verbosity.

Specified by:
createQuiet in interface CppCompilerOptions
Returns:
a newly created QuietOption.

createRelocatable

public RelocatableOption createRelocatable()
Creates an option that controls whether or not the generated modules are relocatable in memory. For most Unix compilers, this is equivalent to the -KPIC or -fPIC option.

Specified by:
createRelocatable in interface CppCompilerOptions
Returns:
a newly created RelocatableOption.

createResource

public ResourceOption createResource()
Creates an option that dynamically generates a resource file. Resource files are only known on Windows, so this is a no-op for most compilers.

Specified by:
createResource in interface CppCompiler
Returns:
a newly created ResourceOption.

createRtti

public RttiOption createRtti()
Creates an option that can be used to en/disable RTTI support. Not all compilers support programmatic control of RTTI support, so take care with this option. Don't use it unless you're sure you know what you're doing.

Specified by:
createRtti in interface CppCompilerOptions
Returns:
a newly created RttiOption.

createRunpath

public RunpathOption createRunpath()
Creates an option that can be used to embed a runpath in a module. This is only relevant on Unix/Linux platforms where a runtime searchpath can be used to modify the default searchpaths configured in the execution environment.

Specified by:
createRunpath in interface CppCompilerOptions
Returns:
a newly created RunpathOption.

createRuntime

public RuntimeOption createRuntime()
Creates an option that specifies the type of C++ runtime library to use. This is only relevant when using the Microsoft compiler.

Specified by:
createRuntime in interface CppCompilerOptions
Returns:
a newly created RuntimeOption.

createSources

public SourcesOption createSources()
Creates an option that adds source files to the build. Source files are not limited to C++ sources, they could also include .DEF files, .RC files, or other supported input files. The compiler abstraction sorts them into the appropriate "buckets" for compilation or linking.

Specified by:
createSources in interface CppCompiler
Returns:
a newly created SourcesOption.

createTarget

public TargetOption createTarget()
Creates an option that governs name, version, and type of build target.

Specified by:
createTarget in interface CppCompiler
Returns:
a newly created TargetOption.

createUndefine

public UndefineOption createUndefine()
Creates an option that undefines a preprocessor definition.

Specified by:
createUndefine in interface CppCompilerOptions
Returns:
a newly created UndefineOption.

createWarning

public WarningsOption createWarning()
Creates an option that adjusts the warning level or specific warnings.

Specified by:
createWarning in interface CppCompilerOptions
Returns:
a newly created WarningsOption.

terp - the ANT Tasks
v1.3.337

Copyright © 2008-2016 by Codemesh, Inc. All Rights Reserved.