net.sf.antcontrib.cpptasks.compiler
Class CommandLineCompiler

java.lang.Object
  extended by net.sf.antcontrib.cpptasks.compiler.AbstractProcessor
      extended by net.sf.antcontrib.cpptasks.compiler.AbstractCompiler
          extended by net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler
All Implemented Interfaces:
java.lang.Cloneable, Compiler, Processor
Direct Known Subclasses:
BorlandResourceCompiler, CommandLineCCompiler, CommandLineFortranCompiler, DevStudioMIDLCompiler, DevStudioResourceCompiler, MetaObjectCompiler, OpenWatcomCompiler, PrecompilingCommandLineCompiler, UserInterfaceCompiler, WindresResourceCompiler, XpidlCompiler

public abstract class CommandLineCompiler
extends AbstractCompiler

An abstract Compiler implementation which uses an external program to perform the compile.

Author:
Adam Murdoch

Field Summary
 
Fields inherited from class net.sf.antcontrib.cpptasks.compiler.AbstractProcessor
DEFAULT_DISCARD_BID, DEFAULT_PROCESS_BID
 
Constructor Summary
protected CommandLineCompiler(java.lang.String command, java.lang.String identifierArg, java.lang.String[] sourceExtensions, java.lang.String[] headerExtensions, java.lang.String outputSuffix, boolean libtool, CommandLineCompiler libtoolCompiler, boolean newEnvironment, org.apache.tools.ant.types.Environment env)
           
 
Method Summary
protected abstract  void addImpliedArgs(java.util.Vector args, boolean debug, boolean multithreaded, boolean exceptions, LinkType linkType, java.lang.Boolean rtti, OptimizationEnum optimization)
           
protected  void addIncludes(java.lang.String baseDirPath, java.io.File[] includeDirs, java.util.Vector args, java.util.Vector relativeArgs, java.lang.StringBuffer includePathId)
          Adds command-line arguments for include directories.
protected abstract  void addWarningSwitch(java.util.Vector args, int warnings)
           
protected  void buildDefineArguments(CompilerDef[] defs, java.util.Vector args)
           
 void compile(CCTask task, java.io.File outputDir, java.lang.String[] sourceFiles, java.lang.String[] args, java.lang.String[] endArgs, boolean relentless, CommandLineCompilerConfiguration config, ProgressMonitor monitor)
          Compiles a source file.
protected  CompilerConfiguration createConfiguration(CCTask task, LinkType linkType, ProcessorDef[] baseDefs, CompilerDef specificDef, TargetDef targetPlatform, VersionInfo versionInfo)
           
protected  int getArgumentCountPerInputFile()
           
protected  java.lang.String getCommand()
           
protected abstract  void getDefineSwitch(java.lang.StringBuffer buffer, java.lang.String define, java.lang.String value)
           
protected abstract  java.io.File[] getEnvironmentIncludePath()
           
 java.lang.String getIdentifier()
          Retrieve an identifier that identifies the specific version of the compiler.
protected abstract  java.lang.String getIncludeDirSwitch(java.lang.String source)
           
protected  java.lang.String getInputFileArgument(java.io.File outputDir, java.lang.String filename, int index)
           
protected  boolean getLibtool()
           
 CommandLineCompiler getLibtoolCompiler()
          Obtains the same compiler, but with libtool set Default behavior is to ignore libtool
abstract  int getMaximumCommandLength()
           
protected  int getMaximumInputFilesPerCommand()
           
protected  int getTotalArgumentLengthForInputFile(java.io.File outputDir, java.lang.String inputFile)
           
protected abstract  void getUndefineSwitch(java.lang.StringBuffer buffer, java.lang.String define)
           
protected  int runCommand(CCTask task, java.io.File workingDir, java.lang.String[] cmdline)
          This method is exposed so test classes can overload and test the arguments without actually spawning the compiler
protected  void setCommand(java.lang.String command)
           
 
Methods inherited from class net.sf.antcontrib.cpptasks.compiler.AbstractCompiler
canParse, createConfiguration, createParser, getBaseOutputName, getOutputFileNames, parseIncludes, resolveInclude
 
Methods inherited from class net.sf.antcontrib.cpptasks.compiler.AbstractProcessor
bid, changeEnvironment, clone, getHeaderExtensions, getIdentifier, getOSArch, getOSName, getSourceExtensions, isDarwin, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.antcontrib.cpptasks.compiler.Processor
bid, changeEnvironment, getLinker
 

Constructor Detail

CommandLineCompiler

protected CommandLineCompiler(java.lang.String command,
                              java.lang.String identifierArg,
                              java.lang.String[] sourceExtensions,
                              java.lang.String[] headerExtensions,
                              java.lang.String outputSuffix,
                              boolean libtool,
                              CommandLineCompiler libtoolCompiler,
                              boolean newEnvironment,
                              org.apache.tools.ant.types.Environment env)
Method Detail

addImpliedArgs

protected abstract void addImpliedArgs(java.util.Vector args,
                                       boolean debug,
                                       boolean multithreaded,
                                       boolean exceptions,
                                       LinkType linkType,
                                       java.lang.Boolean rtti,
                                       OptimizationEnum optimization)

addIncludes

protected void addIncludes(java.lang.String baseDirPath,
                           java.io.File[] includeDirs,
                           java.util.Vector args,
                           java.util.Vector relativeArgs,
                           java.lang.StringBuffer includePathId)
Adds command-line arguments for include directories. If relativeArgs is not null will add corresponding relative paths include switches to that vector (for use in building a configuration identifier that is consistent between machines).

Parameters:
baseDirPath - Base directory path.
includeDirs - Array of include directory paths
args - Vector of command line arguments used to execute the task
relativeArgs - Vector of command line arguments used to build the configuration identifier

addWarningSwitch

protected abstract void addWarningSwitch(java.util.Vector args,
                                         int warnings)

buildDefineArguments

protected void buildDefineArguments(CompilerDef[] defs,
                                    java.util.Vector args)

compile

public void compile(CCTask task,
                    java.io.File outputDir,
                    java.lang.String[] sourceFiles,
                    java.lang.String[] args,
                    java.lang.String[] endArgs,
                    boolean relentless,
                    CommandLineCompilerConfiguration config,
                    ProgressMonitor monitor)
             throws org.apache.tools.ant.BuildException
Compiles a source file.

Throws:
org.apache.tools.ant.BuildException

createConfiguration

protected CompilerConfiguration createConfiguration(CCTask task,
                                                    LinkType linkType,
                                                    ProcessorDef[] baseDefs,
                                                    CompilerDef specificDef,
                                                    TargetDef targetPlatform,
                                                    VersionInfo versionInfo)
Specified by:
createConfiguration in class AbstractCompiler

getArgumentCountPerInputFile

protected int getArgumentCountPerInputFile()

getCommand

protected final java.lang.String getCommand()

getDefineSwitch

protected abstract void getDefineSwitch(java.lang.StringBuffer buffer,
                                        java.lang.String define,
                                        java.lang.String value)

getEnvironmentIncludePath

protected abstract java.io.File[] getEnvironmentIncludePath()

getIdentifier

public java.lang.String getIdentifier()
Description copied from interface: Processor
Retrieve an identifier that identifies the specific version of the compiler. Compilers with the same identifier should produce the same output files for the same input files and command line switches.

Specified by:
getIdentifier in interface Processor
Specified by:
getIdentifier in class AbstractProcessor

getIncludeDirSwitch

protected abstract java.lang.String getIncludeDirSwitch(java.lang.String source)

getInputFileArgument

protected java.lang.String getInputFileArgument(java.io.File outputDir,
                                                java.lang.String filename,
                                                int index)

getLibtool

protected final boolean getLibtool()

getLibtoolCompiler

public final CommandLineCompiler getLibtoolCompiler()
Obtains the same compiler, but with libtool set Default behavior is to ignore libtool


getMaximumCommandLength

public abstract int getMaximumCommandLength()

getMaximumInputFilesPerCommand

protected int getMaximumInputFilesPerCommand()

getTotalArgumentLengthForInputFile

protected int getTotalArgumentLengthForInputFile(java.io.File outputDir,
                                                 java.lang.String inputFile)

getUndefineSwitch

protected abstract void getUndefineSwitch(java.lang.StringBuffer buffer,
                                          java.lang.String define)

runCommand

protected int runCommand(CCTask task,
                         java.io.File workingDir,
                         java.lang.String[] cmdline)
                  throws org.apache.tools.ant.BuildException
This method is exposed so test classes can overload and test the arguments without actually spawning the compiler

Throws:
org.apache.tools.ant.BuildException

setCommand

protected final void setCommand(java.lang.String command)


Copyright © 2001-2008 Ant-Contrib Project. All Rights Reserved.