net.sf.antcontrib.cpptasks.compiler

Class CommandLineLinker

Implemented Interfaces:
Cloneable, Linker, Processor
Known Direct Subclasses:
AbstractArLibrarian, AbstractLdLinker, ADSLibrarian, ADSLinker, BorlandLibrarian, BorlandLinker, C89Linker, ClxxLibrarian, ClxxLinker, CompaqVisualFortranLibrarian, DevStudioCompatibleLibrarian, DevStudioCompatibleLinker, IccLinker, OpenWatcomLibrarian, OpenWatcomLinker, OS390Linker

public abstract class CommandLineLinker
extends AbstractLinker

An abstract Linker implementation that performs the link via an external command.
Author:
Adam Murdoch

Field Summary

Fields inherited from class net.sf.antcontrib.cpptasks.compiler.AbstractProcessor

DEFAULT_DISCARD_BID, DEFAULT_PROCESS_BID

Constructor Summary

CommandLineLinker(String command, String identifierArg, String[] extensions, String[] ignoredExtensions, String outputSuffix, boolean isLibtool, CommandLineLinker libtoolLinker)
Creates a comand line linker invocation

Method Summary

protected abstract void
addBase(long base, Vector args)
protected abstract void
addEntry(String entry, Vector args)
protected abstract void
addFixed(Boolean fixed, Vector args)
protected abstract void
addImpliedArgs(boolean debug, LinkType linkType, Vector args)
protected abstract void
addIncremental(boolean incremental, Vector args)
protected String[]
addLibrarySets(CCTask task, LibrarySet[] libsets, Vector preargs, Vector midargs, Vector endargs)
protected abstract void
addMap(boolean map, Vector args)
protected abstract void
addStack(int stack, Vector args)
protected LinkerConfiguration
createConfiguration(CCTask task, LinkType linkType, ProcessorDef[] baseDefs, LinkerDef specificDef, TargetDef targetPlatform, VersionInfo versionInfo)
protected String
decorateLinkerOption(StringBuffer buf, String arg)
Allows drived linker to decorate linker option.
protected String
getCommand()
protected abstract String
getCommandFileSwitch(String commandFile)
String
getIdentifier()
Retrieve an identifier that identifies the specific version of the compiler.
CommandLineLinker
getLibtoolLinker()
protected abstract int
getMaximumCommandLength()
String[]
getOutputFileNames(String baseName, VersionInfo versionInfo)
Output file name (no path components) corresponding to source file
protected abstract String[]
getOutputFileSwitch(String outputFile)
protected String[]
getOutputFileSwitch(CCTask task, String outputFile)
protected String
getStartupObject(LinkType linkType)
void
link(CCTask task, File outputFile, String[] sourceFiles, CommandLineLinkerConfiguration config)
Performs a link using a command line linker
protected String[]
prepareArguments(CCTask task, String outputDir, String outputFile, String[] sourceFiles, CommandLineLinkerConfiguration config)
Prepares argument list for exec command.
protected String
prepareFilename(StringBuffer buf, String outputDir, String sourceFile)
Processes filename into argument form
protected String[]
prepareResponseFile(File outputFile, String[] args)
Prepares argument list to execute the linker using a response file.
protected String
quoteFilename(StringBuffer buf, String filename)
protected int
runCommand(CCTask task, File workingDir, String[] cmdline)
This method is exposed so test classes can overload and test the arguments without actually spawning the compiler
protected void
setCommand(String command)

Methods inherited from class net.sf.antcontrib.cpptasks.compiler.AbstractLinker

addVersionFiles, bid, changeEnvironment, createConfiguration, createConfiguration, getLibraryKey, getOutputFileNames

Methods inherited from class net.sf.antcontrib.cpptasks.compiler.AbstractProcessor

bid, changeEnvironment, clone, getHeaderExtensions, getIdentifier, getIdentifier, getOSArch, getOSName, getSourceExtensions, isDarwin, toString

Constructor Details

CommandLineLinker

public CommandLineLinker(String command,
                         String identifierArg,
                         String[] extensions,
                         String[] ignoredExtensions,
                         String outputSuffix,
                         boolean isLibtool,
                         CommandLineLinker libtoolLinker)
Creates a comand line linker invocation

Method Details

addBase

protected abstract void addBase(long base,
                                Vector args)

addEntry

protected abstract void addEntry(String entry,
                                 Vector args)

addFixed

protected abstract void addFixed(Boolean fixed,
                                 Vector args)

addImpliedArgs

protected abstract void addImpliedArgs(boolean debug,
                                       LinkType linkType,
                                       Vector args)

addIncremental

protected abstract void addIncremental(boolean incremental,
                                       Vector args)

addLibrarySets

protected String[] addLibrarySets(CCTask task,
                                  LibrarySet[] libsets,
                                  Vector preargs,
                                  Vector midargs,
                                  Vector endargs)

addMap

protected abstract void addMap(boolean map,
                               Vector args)

addStack

protected abstract void addStack(int stack,
                                 Vector args)

createConfiguration

protected LinkerConfiguration createConfiguration(CCTask task,
                                                  LinkType linkType,
                                                  ProcessorDef[] baseDefs,
                                                  LinkerDef specificDef,
                                                  TargetDef targetPlatform,
                                                  VersionInfo versionInfo)
Overrides:
createConfiguration in interface AbstractLinker

decorateLinkerOption

protected String decorateLinkerOption(StringBuffer buf,
                                      String arg)
Allows drived linker to decorate linker option. Override by GccLinker to prepend a "-Wl," to pass option to through gcc to linker.
Parameters:
buf - buffer that may be used and abused in the decoration process, must not be null.
arg - linker argument

getCommand

protected final String getCommand()

getCommandFileSwitch

protected abstract String getCommandFileSwitch(String commandFile)

getIdentifier

public String getIdentifier()
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
Overrides:
getIdentifier in interface AbstractProcessor

getLibtoolLinker

public final CommandLineLinker getLibtoolLinker()

getMaximumCommandLength

protected abstract int getMaximumCommandLength()

getOutputFileNames

public String[] getOutputFileNames(String baseName,
                                   VersionInfo versionInfo)
Output file name (no path components) corresponding to source file
Specified by:
getOutputFileNames in interface Processor
Overrides:
getOutputFileNames in interface AbstractLinker
Parameters:
Returns:
output file name or null if no output file or name not determined by input file

getOutputFileSwitch

protected abstract String[] getOutputFileSwitch(String outputFile)

getOutputFileSwitch

protected String[] getOutputFileSwitch(CCTask task,
                                       String outputFile)

getStartupObject

protected String getStartupObject(LinkType linkType)

link

public void link(CCTask task,
                 File outputFile,
                 String[] sourceFiles,
                 CommandLineLinkerConfiguration config)
            throws BuildException
Performs a link using a command line linker

prepareArguments

protected String[] prepareArguments(CCTask task,
                                    String outputDir,
                                    String outputFile,
                                    String[] sourceFiles,
                                    CommandLineLinkerConfiguration config)
Prepares argument list for exec command. Will return null if command line would exceed allowable command line buffer.
Parameters:
outputFile - linker output file
sourceFiles - linker input files (.obj, .o, .res)
Returns:
arguments for runTask

prepareFilename

protected String prepareFilename(StringBuffer buf,
                                 String outputDir,
                                 String sourceFile)
Processes filename into argument form

prepareResponseFile

protected String[] prepareResponseFile(File outputFile,
                                       String[] args)
            throws IOException
Prepares argument list to execute the linker using a response file.
Parameters:
outputFile - linker output file
args - output of prepareArguments
Returns:
arguments for runTask

quoteFilename

protected String quoteFilename(StringBuffer buf,
                               String filename)

runCommand

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

setCommand

protected final void setCommand(String command)

Copyright B) 2001-2006 Ant-Contrib project. All Rights Reserved.