|
terp - the ANT Tasks v1.3.304 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
com.codemesh.terp.ant.compiler.cpp.CppCompilerImpl
public class CppCompilerImpl
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 |
|---|
public static final ToInteger TO_INT
public static final ToFile TO_FILE
public static final java.lang.String COMPILER_OPTIONS
public static final java.lang.String LINKER_OPTIONS
protected TerpAware.Delegate aware
protected TerpContext ctx
protected CompilerOptionSet<CppCompiler> options
protected java.util.Vector<TerpSequential> preBuilds
protected java.util.Vector<TerpSequential> postBuilds
protected java.lang.String bom
protected java.lang.String batchSize
protected java.lang.String cleanup
protected java.lang.String depends
protected Cpp.CppExecutor compiler
protected java.lang.String compilerString
protected java.lang.String createDirs
protected java.lang.String cppExtensions
protected java.lang.String defExtensions
protected java.lang.String iconExtensions
protected java.lang.String objExtensions
protected java.lang.String failOnError
protected java.lang.String forcecompile
protected java.lang.String libExtensions
protected java.lang.String maxParallel
protected java.lang.String parallel
protected java.lang.String rcExtensions
protected java.lang.String resExtensions
protected java.lang.String showOnly
protected java.lang.String tempDir
protected java.lang.String targetDir
protected java.lang.String targetNameProperty
protected java.util.Set<java.io.File> createdFiles
| Constructor Detail |
|---|
public CppCompilerImpl()
public CppCompilerImpl(org.apache.tools.ant.Project p)
| Method Detail |
|---|
public void setProject(org.apache.tools.ant.Project p)
setProject in class org.apache.tools.ant.ProjectComponentpublic void setContext(TerpContext ctx)
setContext in interface TerpContextHolderctx - the execution context.public TerpContext getContext()
getContext in interface Compiler<CppCompiler>getContext in interface TerpContextHolderpublic void setCompiler(java.lang.String compiler)
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.
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:"13.10"}"
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.
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
setCompiler in interface CppCompilercompiler - the compiler specifier.public Cpp.CppExecutor getCompiler()
getCompiler in interface CppCompilerpublic java.util.Map<java.lang.String,java.lang.Object> getTraits()
getTraits in interface CppCompilerpublic java.io.File getBaseDir()
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.
getBaseDir in interface CppCompilerpublic ProcArch getProcArch()
public void setBOM(java.lang.String bom)
setBOM in interface CppCompilerbom - the filename.public java.lang.String getBOM()
public void setBatchSize(java.lang.String batchSize)
setBatchSize in interface CppCompilerbatchSize - the number of sources in one compiler invocation.public void setCleanup(java.lang.String cleanup)
setCleanup in interface CppCompilercleanup - true for cleanup, false for regular compilation.public void setDepends(java.lang.String depends)
setDepends in interface CppCompilerdepends - true if dependency files should be generated, false if not.public void setCppExtensions(java.lang.String cppExts)
setCppExtensions in interface CppCompilercppExts - a comma- or semicolon-separated list of extensions.public void setDefinitionFileExtensions(java.lang.String defExts)
public void setIconFileExtensions(java.lang.String iconExts)
public void setCreateDirs(java.lang.String create)
setCreateDirs in interface CppCompilercreate - true if directories should be created, false otherwise.public boolean getCreateDirs()
getCreateDirs in interface CppCompilerpublic void setFailOnError(java.lang.String foe)
setFailOnError in interface CppCompilerfoe - true when compilation should be terminated in case of error.public void setForceBuild(java.lang.String fb)
setForceBuild in interface CppCompilerfb - true when buildsteps should be performed unconditionally.public void setMaxParallel(java.lang.String maxParallel)
setMaxParallel in interface CppCompilermaxParallel - the maximum number of parallel invocations.public void setParallel(java.lang.String parallel)
setParallel in interface CppCompilerparallel - parallel mode.public void setShowOnly(java.lang.String so)
setShowOnly in interface CppCompilerso - true when tool invocations should be suppressed.public boolean getShowOnly()
public void setResourceSourceFileExtensions(java.lang.String rcExts)
public void setResourceFileExtensions(java.lang.String resExts)
public void setTargetDir(java.lang.String targetDir)
setTargetDir in interface CppCompilertargetDir - the output directory.public java.lang.String getTargetDir()
getTargetDir in interface CppCompilerpublic java.lang.String getTargetNameProperty()
getTargetNameProperty in interface CppCompilerpublic void setTargetNameProperty(java.lang.String propertyName)
setTargetNameProperty in interface CppCompilerpropertyName - a property name.public void setTempDir(java.lang.String tempDir)
setTempDir in interface CppCompilertempDir - the intermediate file directory.public java.lang.String getTempDir()
protected java.lang.String expand(java.lang.String str)
str - the terp template string.
protected java.lang.String expand(java.lang.String str,
java.lang.String propName)
public java.lang.String getCode()
getCode in interface Compiler<CppCompiler>public Version getVersion()
getVersion in interface Compiler<CppCompiler>
public void execute()
throws org.apache.tools.ant.BuildException
execute in class org.apache.tools.ant.Taskorg.apache.tools.ant.BuildExceptionprotected void doCleanup(boolean bCompileOnly)
protected com.codemesh.terp.ant.compiler.cpp.CppCompilerImpl.CompilerPhaseResult doDepends(boolean bMadeChanges)
protected void populateDependencies(CppCompiler.SourceToTargets sourceToTargets)
protected void clearDependencies()
protected com.codemesh.terp.ant.compiler.cpp.CppCompilerImpl.CompilerPhaseResult doPreCompile()
protected com.codemesh.terp.ant.compiler.cpp.CppCompilerImpl.CompilerPhaseResult doCompile(boolean bCompileOnly)
protected com.codemesh.terp.ant.compiler.cpp.CppCompilerImpl.CompilerPhaseResult doLink(boolean bMadeChanges)
protected void doPostLink()
protected void createLinksIfNecessary(TargetOption optTarget)
protected java.io.File createArchive(java.util.List<CppCompiler.SourceToTargets> s2ts,
TargetOption optTarget,
ProcArchOption optPa)
protected java.io.File createResponseFile(java.lang.String commandLine,
java.util.List<CppCompiler.SourceToTargets> s2ts)
throws java.io.IOException
java.io.IOExceptionpublic java.util.List<CppCompiler.SourceToTargets> getCompilationSources(boolean bIncludeDynamics)
getCompilationSources in interface CppCompilerbIncludeDynamics - true if dynamically generated sources should be included.
protected java.util.List<CppCompiler.SourceToTargets> getLinkSources(boolean bIncludeDynamics)
protected java.util.regex.Pattern getPattern(java.lang.String patSrc,
java.lang.String description)
protected void createDirsIfNecessary(boolean bCreateDirs,
java.io.File fTargetDir,
java.io.File fTempDir)
public void addOption(CompilerOption<CppCompiler> option)
addOption in interface Compiler<CppCompiler>option - the option to add.public CompilerOptionSet<CppCompiler> getOptions()
getOptions in interface Compiler<CppCompiler>getOptions in interface CppCompilerOptionspublic java.lang.String getIf()
getIf in interface TerpAwarepublic void setIf(java.lang.String condition)
setIf in interface TerpAwarecondition - a terp expression that must evaluate to a boolean value.public java.lang.String getUnless()
getUnless in interface TerpAwarepublic void setUnless(java.lang.String condition)
setUnless in interface TerpAwarecondition - a terp expression that must evaluate to a boolean value.public boolean satisfiesConditions()
satisfiesConditions in interface TerpAwarepublic BoundsCheckOption createBoundsCheck()
createBoundsCheck in interface CppCompilerOptionspublic CompileOnlyOption createCompileOnly()
createCompileOnly in interface CppCompilerOptionspublic DebugOption createDebug()
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).
createDebug in interface CppCompilerOptionspublic DefineOption createDefine()
createDefine in interface CppCompilerOptionspublic DynamicSourcesOption createDynamicSources()
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.
createDynamicSources in interface CppCompilerpublic ExceptionsOption createExceptions()
createExceptions in interface CppCompilerOptionspublic VsProjectOption createGenerateVsProject()
createGenerateVsProject in interface CppCompilerpublic IncludeOption createInclude()
createInclude in interface CppCompilerOptionspublic LibpathOption createLibpath()
createLibpath in interface CppCompilerOptionspublic LibraryOption createLibrary()
createLibrary in interface CppCompilerOptionspublic ManifestOption createManifest()
createManifest in interface CppCompilerOptionspublic MultithreadedOption createMultithreaded()
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.
createMultithreaded in interface CppCompilerOptionspublic ObjectsOption createObjects()
createObjects in interface CppCompilerpublic OptimizeOption createOptimize()
createOptimize in interface CppCompilerOptionspublic GenericOption createOption()
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.
createOption in interface CppCompilerOptionspublic OptionsOption createOptions()
createOptions in interface CppCompilerpublic TerpSequential createPostBuild()
createPostBuild in interface CppCompilerpublic TerpSequential createPreBuild()
createPreBuild in interface CppCompilerpublic ProcArchOption createProcArch()
createProcArch in interface CppCompilerpublic ProfileOption createProfile()
createProfile in interface CppCompilerpublic QuietOption createQuiet()
createQuiet in interface CppCompilerOptionspublic RelocatableOption createRelocatable()
createRelocatable in interface CppCompilerOptionspublic ResourceOption createResource()
createResource in interface CppCompilerpublic RttiOption createRtti()
createRtti in interface CppCompilerOptionspublic RunpathOption createRunpath()
createRunpath in interface CppCompilerOptionspublic RuntimeOption createRuntime()
createRuntime in interface CppCompilerOptionspublic SourcesOption createSources()
createSources in interface CppCompilerpublic TargetOption createTarget()
createTarget in interface CppCompilerpublic UndefineOption createUndefine()
createUndefine in interface CppCompilerOptionspublic WarningsOption createWarning()
createWarning in interface CppCompilerOptions
|
terp - the ANT Tasks v1.3.304 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||