summaryrefslogtreecommitdiffstats
path: root/src/net/sf/antcontrib/cpptasks/CCTask.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/sf/antcontrib/cpptasks/CCTask.java')
-rw-r--r--src/net/sf/antcontrib/cpptasks/CCTask.java50
1 files changed, 40 insertions, 10 deletions
diff --git a/src/net/sf/antcontrib/cpptasks/CCTask.java b/src/net/sf/antcontrib/cpptasks/CCTask.java
index beeed89..d5c9f2e 100644
--- a/src/net/sf/antcontrib/cpptasks/CCTask.java
+++ b/src/net/sf/antcontrib/cpptasks/CCTask.java
@@ -152,6 +152,7 @@ public class CCTask extends Task {
}
/** The compiler definitions. */
private Vector _compilers = new Vector();
+ private CompilerEnum compilerName;
/** The output file type. */
// private LinkType _linkType = LinkType.EXECUTABLE;
/** The library sets. */
@@ -208,6 +209,10 @@ public class CCTask extends Task {
*/
private String outputFileProperty;
/**
+ * The prefix to append to the outputFileProperty.
+ */
+ private String outputFilePrefixProperty;
+ /**
* if relentless = true, compilations should attempt to compile as many
* files as possible before throwing a BuildException
*/
@@ -424,11 +429,14 @@ public class CCTask extends Task {
FileVisitor objCollector = null;
FileVisitor sysLibraryCollector = null;
for (int i = 0; i < _linkers.size(); i++) {
- LinkerDef currentLinkerDef = (LinkerDef) _linkers.elementAt(i);
+ LinkerDef currentLinkerDef = (LinkerDef) _linkers.elementAt(i);
if (currentLinkerDef.isActive()) {
- selectedLinkerDef = currentLinkerDef;
- selectedLinker = currentLinkerDef.getProcessor().getLinker(
- linkType);
+
+ selectedLinkerDef = currentLinkerDef;
+ if(null != outputFilePrefixProperty){
+ selectedLinkerDef.getLinker().setOutputFilePrefix(outputFilePrefixProperty);
+ }
+ selectedLinker = currentLinkerDef.getProcessor().getLinker(linkType);
//
// skip the linker if it doesn't know how to
// produce the specified link type
@@ -463,8 +471,12 @@ public class CCTask extends Task {
}
if (linkerConfig == null) {
linkerConfig = linkerDef.createConfiguration(this, linkType, null, targetPlatform, versionInfo);
- selectedLinker = (Linker) linkerDef.getProcessor().getLinker(
+
+ selectedLinker = (Linker) linkerDef.getLinker().getLinker(
linkType);
+ if(null != outputFilePrefixProperty){
+ selectedLinker.setOutputFilePrefix(outputFilePrefixProperty);
+ }
objCollector = new ObjectFileCollector(selectedLinker, objectFiles);
sysLibraryCollector = new SystemLibraryCollector(selectedLinker,
sysLibraries);
@@ -539,7 +551,14 @@ public class CCTask extends Task {
* if someting goes wrong with the build
*/
public void execute() throws BuildException {
- //
+
+ compilerDef.setName(compilerName);
+ Processor compiler = compilerDef.getProcessor();
+ Linker linker = compiler.getLinker(linkType);
+ linker.setOutputFilePrefix(outputFilePrefixProperty);
+ linkerDef.setProcessor(linker);
+
+ //
// if link type allowed objdir to be defaulted
// provide it from outfile
if (_objDir == null) {
@@ -769,6 +788,7 @@ public class CCTask extends Task {
log("Starting link");
LinkerConfiguration linkConfig = (LinkerConfiguration) linkTarget
.getConfiguration();
+ linkConfig.setOutputFilePrefix(outputFilePrefixProperty);
if (failOnError) {
linkConfig.link(this, linkTarget);
} else {
@@ -841,6 +861,9 @@ public class CCTask extends Task {
File[] sysObjectFileArray = new File[sysObjectFiles.size()];
sysObjectFiles.copyInto(sysObjectFileArray);
String baseName = _outfile.getName();
+
+
+ linkerConfig.setOutputFilePrefix(outputFilePrefixProperty);
String[] fullNames = linkerConfig.getOutputFileNames(baseName, versionInfo);
File outputFile = new File(_outfile.getParent(), fullNames[0]);
return new TargetInfo(linkerConfig, objectFileArray,
@@ -1193,10 +1216,8 @@ public class CCTask extends Task {
*
*/
public void setName(CompilerEnum name) {
- compilerDef.setName(name);
- Processor compiler = compilerDef.getProcessor();
- Linker linker = compiler.getLinker(linkType);
- linkerDef.setProcessor(linker);
+ compilerName = name;
+
}
/**
* Do not propagate old environment when new environment variables are
@@ -1246,6 +1267,15 @@ public class CCTask extends Task {
this.outputFileProperty = outputFileProperty;
}
/**
+ * Sets the prefix for the output file. Default is dependent on the linker
+ * however many linkers prefix the output with lib if the output is a dynamic
+ * object. Setting this property to an empty string will remove this prefix.
+ */
+ public void setOutputFilePrefix(String outputFilePrefixProperty){
+ this.outputFilePrefixProperty = outputFilePrefixProperty;
+ }
+
+ /**
* Sets the output file type. Supported values "executable", "shared", and
* "static".
*/