net.sf.antcontrib.cpptasks.compiler
Class CommandLineCompiler

java.lang.Object
  |
  +--net.sf.antcontrib.cpptasks.compiler.AbstractProcessor
        |
        +--net.sf.antcontrib.cpptasks.compiler.AbstractCompiler
              |
              +--net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler
Direct Known Subclasses:
BorlandResourceCompiler, CommandLineCCompiler, CommandLineFortranCompiler, DevStudioMIDLCompiler, DevStudioResourceCompiler, PrecompilingCommandLineCompiler

public abstract class CommandLineCompiler
extends AbstractCompiler

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

Author:
Adam Murdoch

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)
           
 
Method Summary
protected abstract  void addImpliedArgs(java.util.Vector args, boolean debug, boolean multithreaded, boolean exceptions, LinkType linkType)
           
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, ProgressMonitor monitor)
          Compiles a source file.
protected  CompilerConfiguration createConfiguration(CCTask task, LinkType linkType, ProcessorDef[] baseDefs, CompilerDef specificDef)
           
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
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
 
Methods inherited from class net.sf.antcontrib.cpptasks.compiler.AbstractCompiler
canParse, createConfiguration, createParser, getBaseOutputName, getOutputFileName, parseIncludes, resolveInclude
 
Methods inherited from class net.sf.antcontrib.cpptasks.compiler.AbstractProcessor
bid, getIdentifier, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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)
Method Detail

getCommand

protected final java.lang.String getCommand()

getIncludeDirSwitch

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

addImpliedArgs

protected abstract void addImpliedArgs(java.util.Vector args,
                                       boolean debug,
                                       boolean multithreaded,
                                       boolean exceptions,
                                       LinkType linkType)

addWarningSwitch

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

getDefineSwitch

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

getUndefineSwitch

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

getLibtoolCompiler

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

getMaximumInputFilesPerCommand

protected int getMaximumInputFilesPerCommand()

getArgumentCountPerInputFile

protected int getArgumentCountPerInputFile()

getLibtool

protected final boolean getLibtool()

getTotalArgumentLengthForInputFile

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

getInputFileArgument

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

compile

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

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

getEnvironmentIncludePath

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

createConfiguration

protected CompilerConfiguration createConfiguration(CCTask task,
                                                    LinkType linkType,
                                                    ProcessorDef[] baseDefs,
                                                    CompilerDef specificDef)
Overrides:
createConfiguration in class AbstractCompiler

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:
baseDirPaths - A vector containing the parts of the working directory, produced by CUtil.DecomposeFile.
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

buildDefineArguments

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

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.
Overrides:
getIdentifier in class AbstractProcessor


Copyright © 2001-2002 Ant-Contrib project. All Rights Reserved.