summaryrefslogtreecommitdiffstats
path: root/src/net/sf
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/sf')
-rw-r--r--src/net/sf/antcontrib/cpptasks/CCTask.java50
-rw-r--r--src/net/sf/antcontrib/cpptasks/LinkerDef.java11
-rw-r--r--src/net/sf/antcontrib/cpptasks/arm/ADSLibrarian.java2
-rw-r--r--src/net/sf/antcontrib/cpptasks/arm/ADSLinker.java2
-rw-r--r--src/net/sf/antcontrib/cpptasks/borland/BorlandLibrarian.java42
-rw-r--r--src/net/sf/antcontrib/cpptasks/borland/BorlandLinker.java2
-rw-r--r--src/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranLibrarian.java2
-rw-r--r--src/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranLinker.java2
-rw-r--r--src/net/sf/antcontrib/cpptasks/compiler/AbstractCompiler.java5
-rw-r--r--src/net/sf/antcontrib/cpptasks/compiler/AbstractLinker.java16
-rw-r--r--src/net/sf/antcontrib/cpptasks/compiler/CommandLineCompilerConfiguration.java4
-rw-r--r--src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java10
-rw-r--r--src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinkerConfiguration.java7
-rw-r--r--src/net/sf/antcontrib/cpptasks/compiler/Linker.java2
-rw-r--r--src/net/sf/antcontrib/cpptasks/compiler/LinkerConfiguration.java1
-rw-r--r--src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLibrarian.java2
-rw-r--r--src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java4
-rw-r--r--src/net/sf/antcontrib/cpptasks/devstudio/DevStudioLinker.java2
-rw-r--r--src/net/sf/antcontrib/cpptasks/gcc/AbstractArLibrarian.java8
-rw-r--r--src/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java19
-rw-r--r--src/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java3
-rw-r--r--src/net/sf/antcontrib/cpptasks/gcc/GccLinker.java92
-rw-r--r--src/net/sf/antcontrib/cpptasks/intel/IntelWin32Linker.java2
-rw-r--r--src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomLibrarian.java2
-rw-r--r--src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomLinker.java2
-rw-r--r--src/net/sf/antcontrib/cpptasks/os390/OS390Linker.java7
-rw-r--r--src/net/sf/antcontrib/cpptasks/os400/IccLinker.java9
-rw-r--r--src/net/sf/antcontrib/cpptasks/sun/C89Linker.java6
-rw-r--r--src/net/sf/antcontrib/cpptasks/ti/ClxxLibrarian.java2
-rw-r--r--src/net/sf/antcontrib/cpptasks/ti/ClxxLinker.java2
30 files changed, 232 insertions, 88 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".
*/
diff --git a/src/net/sf/antcontrib/cpptasks/LinkerDef.java b/src/net/sf/antcontrib/cpptasks/LinkerDef.java
index af1d307..51f3165 100644
--- a/src/net/sf/antcontrib/cpptasks/LinkerDef.java
+++ b/src/net/sf/antcontrib/cpptasks/LinkerDef.java
@@ -281,6 +281,17 @@ public class LinkerDef extends ProcessorDef {
}
return linker;
}
+ public Linker getLinker() {
+ Linker linker = (Linker) super.getProcessor();
+ if (linker == null) {
+ linker = GccLinker.getInstance();
+ }
+ if (getLibtool() && linker instanceof CommandLineLinker) {
+ CommandLineLinker cmdLineLinker = (CommandLineLinker) linker;
+ linker = cmdLineLinker.getLibtoolLinker();
+ }
+ return linker;
+ }
public int getStack(LinkerDef[] defaultProviders, int index) {
if (isReference()) {
return ((LinkerDef) getCheckedRef(LinkerDef.class, "LinkerDef"))
diff --git a/src/net/sf/antcontrib/cpptasks/arm/ADSLibrarian.java b/src/net/sf/antcontrib/cpptasks/arm/ADSLibrarian.java
index 65c430f..0efc1f6 100644
--- a/src/net/sf/antcontrib/cpptasks/arm/ADSLibrarian.java
+++ b/src/net/sf/antcontrib/cpptasks/arm/ADSLibrarian.java
@@ -40,7 +40,7 @@ public class ADSLibrarian extends CommandLineLinker {
private ADSLibrarian()
{
super("armar",null,
- new String[] { ".o" }, new String[0], ".lib", false, null);
+ new String[] { ".o" }, new String[0], "", ".lib", false, null);
}
/* (non-Javadoc)
diff --git a/src/net/sf/antcontrib/cpptasks/arm/ADSLinker.java b/src/net/sf/antcontrib/cpptasks/arm/ADSLinker.java
index fda52fa..6b42b5c 100644
--- a/src/net/sf/antcontrib/cpptasks/arm/ADSLinker.java
+++ b/src/net/sf/antcontrib/cpptasks/arm/ADSLinker.java
@@ -40,7 +40,7 @@ public class ADSLinker extends CommandLineLinker {
}
private ADSLinker(String outputSuffix) {
super("armlink", "-vsn", new String[]{".o", ".lib", ".res"},
- new String[]{".map", ".pdb", ".lnk"}, outputSuffix, false, null);
+ new String[]{".map", ".pdb", ".lnk"}, "", outputSuffix, false, null);
}
/*
* (non-Javadoc)
diff --git a/src/net/sf/antcontrib/cpptasks/borland/BorlandLibrarian.java b/src/net/sf/antcontrib/cpptasks/borland/BorlandLibrarian.java
index 75846a4..bf9ee13 100644
--- a/src/net/sf/antcontrib/cpptasks/borland/BorlandLibrarian.java
+++ b/src/net/sf/antcontrib/cpptasks/borland/BorlandLibrarian.java
@@ -39,7 +39,7 @@ public class BorlandLibrarian extends CommandLineLinker {
return instance;
}
private BorlandLibrarian() {
- super("tlib", "--version", new String[]{".obj"}, new String[0], ".lib", false,
+ super("tlib", "--version", new String[]{".obj"}, new String[0], "", ".lib", false,
null);
}
protected void addBase(long base, Vector args) {
@@ -60,12 +60,12 @@ public class BorlandLibrarian extends CommandLineLinker {
protected void addEntry(String entry, Vector args) {
}
- protected String getCommandFileSwitch(String cmdFile) {
- //
- // tlib requires quotes around paths containing -
- // ilink32 doesn't like them
- StringBuffer buf = new StringBuffer("@");
- BorlandProcessor.quoteFile(buf, cmdFile);
+ protected String getCommandFileSwitch(String cmdFile) {
+ //
+ // tlib requires quotes around paths containing -
+ // ilink32 doesn't like them
+ StringBuffer buf = new StringBuffer("@");
+ BorlandProcessor.quoteFile(buf, cmdFile);
return buf.toString();
}
public File[] getLibraryPath() {
@@ -182,8 +182,8 @@ public class BorlandLibrarian extends CommandLineLinker {
protected String[] prepareResponseFile(File outputFile, String[] args)
throws IOException {
String[] cmdargs = BorlandProcessor.prepareResponseFile(outputFile, args, " & \n");
- cmdargs[cmdargs.length - 1] = getCommandFileSwitch(cmdargs[cmdargs.length -1]);
- return cmdargs;
+ cmdargs[cmdargs.length - 1] = getCommandFileSwitch(cmdargs[cmdargs.length -1]);
+ return cmdargs;
}
/**
@@ -203,17 +203,17 @@ public class BorlandLibrarian extends CommandLineLinker {
// build a new library
super.link(task, outputFile, sourceFiles, config);
}
-
- /**
- * Encloses problematic file names within quotes.
- * @param buf string buffer
- * @param filename source file name
- * @returns filename potentially enclosed in quotes.
- */
- protected String quoteFilename(StringBuffer buf,String filename) {
- buf.setLength(0);
- BorlandProcessor.quoteFile(buf, filename);
- return buf.toString();
- }
+
+ /**
+ * Encloses problematic file names within quotes.
+ * @param buf string buffer
+ * @param filename source file name
+ * @returns filename potentially enclosed in quotes.
+ */
+ protected String quoteFilename(StringBuffer buf,String filename) {
+ buf.setLength(0);
+ BorlandProcessor.quoteFile(buf, filename);
+ return buf.toString();
+ }
}
diff --git a/src/net/sf/antcontrib/cpptasks/borland/BorlandLinker.java b/src/net/sf/antcontrib/cpptasks/borland/BorlandLinker.java
index 315761f..ea1a523 100644
--- a/src/net/sf/antcontrib/cpptasks/borland/BorlandLinker.java
+++ b/src/net/sf/antcontrib/cpptasks/borland/BorlandLinker.java
@@ -43,7 +43,7 @@ public final class BorlandLinker extends CommandLineLinker {
}
private BorlandLinker(String outputSuffix) {
super("ilink32", "-r", new String[]{".obj", ".lib", ".res"},
- new String[]{".map", ".pdb", ".lnk"}, outputSuffix, false, null);
+ new String[]{".map", ".pdb", ".lnk"}, "", outputSuffix, false, null);
}
protected void addBase(long base, Vector args) {
if (base >= 0) {
diff --git a/src/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranLibrarian.java b/src/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranLibrarian.java
index 2488619..9522a4b 100644
--- a/src/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranLibrarian.java
+++ b/src/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranLibrarian.java
@@ -36,7 +36,7 @@ public class CompaqVisualFortranLibrarian extends CommandLineLinker {
return instance;
}
private CompaqVisualFortranLibrarian() {
- super("lib", "/bogus", new String[]{".obj"}, new String[0], ".lib",
+ super("lib", "/bogus", new String[]{".obj"}, new String[0], "", ".lib",
false, null);
}
protected void addBase(long base, Vector args) {
diff --git a/src/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranLinker.java b/src/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranLinker.java
index c8930f9..001d833 100644
--- a/src/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranLinker.java
+++ b/src/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranLinker.java
@@ -34,7 +34,7 @@ public final class CompaqVisualFortranLinker extends DevStudioCompatibleLinker {
return instance;
}
private CompaqVisualFortranLinker(String outputSuffix) {
- super("DF", "__bogus__.xxx", outputSuffix);
+ super("DF", "__bogus__.xxx", "", outputSuffix);
}
protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args) {
args.addElement("/NOLOGO");
diff --git a/src/net/sf/antcontrib/cpptasks/compiler/AbstractCompiler.java b/src/net/sf/antcontrib/cpptasks/compiler/AbstractCompiler.java
index e61bd64..a572930 100644
--- a/src/net/sf/antcontrib/cpptasks/compiler/AbstractCompiler.java
+++ b/src/net/sf/antcontrib/cpptasks/compiler/AbstractCompiler.java
@@ -41,6 +41,7 @@ public abstract class AbstractCompiler extends AbstractProcessor
Compiler {
private static final String[] emptyIncludeArray = new String[0];
private String outputSuffix;
+ private static String outputFilePrefix;
protected AbstractCompiler(String[] sourceExtensions,
String[] headerExtensions, String outputSuffix) {
super(sourceExtensions, headerExtensions);
@@ -205,4 +206,8 @@ public abstract class AbstractCompiler extends AbstractProcessor
}
return false;
}
+
+ public void setOutputFilePrefix(String outputFilePrefix){
+ this.outputFilePrefix = outputFilePrefix;
+ }
}
diff --git a/src/net/sf/antcontrib/cpptasks/compiler/AbstractLinker.java b/src/net/sf/antcontrib/cpptasks/compiler/AbstractLinker.java
index 9de9491..5b5beaf 100644
--- a/src/net/sf/antcontrib/cpptasks/compiler/AbstractLinker.java
+++ b/src/net/sf/antcontrib/cpptasks/compiler/AbstractLinker.java
@@ -32,8 +32,11 @@ import org.apache.tools.ant.types.Environment;
* @author Adam Murdoch
*/
public abstract class AbstractLinker extends AbstractProcessor
- implements
- Linker {
+ implements Linker {
+
+ protected static String outputFilePrefix = null;
+
+
public AbstractLinker(String[] objExtensions, String[] ignoredExtensions) {
super(objExtensions, ignoredExtensions);
}
@@ -64,13 +67,16 @@ public abstract class AbstractLinker extends AbstractProcessor
}
return bid;
}
+
public Processor changeEnvironment(boolean newEnvironment, Environment env) {
return this;
}
+
abstract protected LinkerConfiguration createConfiguration(CCTask task,
LinkType linkType, ProcessorDef[] baseConfigs,
LinkerDef specificConfig, TargetDef targetPlatform,
VersionInfo versionInfo);
+
public ProcessorConfiguration createConfiguration(CCTask task,
LinkType linkType, ProcessorDef[] baseConfigs,
ProcessorDef specificConfig,
@@ -82,11 +88,17 @@ public abstract class AbstractLinker extends AbstractProcessor
return createConfiguration(task, linkType, baseConfigs,
(LinkerDef) specificConfig, targetPlatform, versionInfo);
}
+
public String getLibraryKey(File libfile) {
return libfile.getName();
}
+
public abstract String[] getOutputFileNames(String fileName, VersionInfo versionInfo);
+ public void setOutputFilePrefix(String outputFilePrefix){
+ this.outputFilePrefix = outputFilePrefix;
+
+ }
/**
* Adds source or object files to the bidded fileset to
diff --git a/src/net/sf/antcontrib/cpptasks/compiler/CommandLineCompilerConfiguration.java b/src/net/sf/antcontrib/cpptasks/compiler/CommandLineCompilerConfiguration.java
index 38492ea..2295a5c 100644
--- a/src/net/sf/antcontrib/cpptasks/compiler/CommandLineCompilerConfiguration.java
+++ b/src/net/sf/antcontrib/cpptasks/compiler/CommandLineCompilerConfiguration.java
@@ -47,6 +47,7 @@ public final class CommandLineCompilerConfiguration
private/* final */ProcessorParam[] params;
private/* final */boolean rebuild;
private/* final */File[] sysIncludePath;
+ private static String outputFilePrefix;
public CommandLineCompilerConfiguration(CommandLineCompiler compiler,
String identifier, File[] includePath, File[] sysIncludePath,
File[] envIncludePath, String includePathIdentifier, String[] args,
@@ -223,4 +224,7 @@ public final class CommandLineCompilerConfiguration
public String getCommand() {
return compiler.getCommand();
}
+ public void setOutputFilePrefix(String outputFilePrefix){
+ this.outputFilePrefix = outputFilePrefix;
+ }
}
diff --git a/src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java b/src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java
index f9e4761..52b0d67 100644
--- a/src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java
+++ b/src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java
@@ -54,17 +54,25 @@ public abstract class CommandLineLinker extends AbstractLinker
private boolean newEnvironment = false;
private String outputSuffix;
+ protected String outputPrefix;
+
+ public void setOutputPrefix(String outputPrefix){
+ this.outputPrefix = outputPrefix;
+ }
+
+
/** Creates a comand line linker invocation */
public CommandLineLinker(String command,
String identifierArg,
String[] extensions,
- String[] ignoredExtensions, String outputSuffix,
+ String[] ignoredExtensions, String outputPrefix, String outputSuffix,
boolean isLibtool, CommandLineLinker libtoolLinker)
{
super(extensions, ignoredExtensions);
this.command = command;
this.identifierArg = identifierArg;
+ this.outputPrefix = outputPrefix;
this.outputSuffix = outputSuffix;
this.isLibtool = isLibtool;
this.libtoolLinker = libtoolLinker;
diff --git a/src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinkerConfiguration.java b/src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinkerConfiguration.java
index f0aad67..d67ffd3 100644
--- a/src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinkerConfiguration.java
+++ b/src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinkerConfiguration.java
@@ -87,8 +87,13 @@ public final class CommandLineLinkerConfiguration
return map;
}
public String[] getOutputFileNames(String inputFile, VersionInfo versionInfo) {
- return linker.getOutputFileNames(inputFile, versionInfo);
+ return linker.getOutputFileNames(inputFile, versionInfo);
}
+
+ public void setOutputFilePrefix(String outputFilePrefix) {
+ linker.setOutputFilePrefix(outputFilePrefix);
+ }
+
public LinkerParam getParam(String name) {
for (int i = 0; i < params.length; i++) {
if (name.equals(params[i].getName()))
diff --git a/src/net/sf/antcontrib/cpptasks/compiler/Linker.java b/src/net/sf/antcontrib/cpptasks/compiler/Linker.java
index 672a0e3..32c29ef 100644
--- a/src/net/sf/antcontrib/cpptasks/compiler/Linker.java
+++ b/src/net/sf/antcontrib/cpptasks/compiler/Linker.java
@@ -77,4 +77,6 @@ public interface Linker extends Processor {
final boolean isDebug,
final File objDir,
final TargetMatcher matcher) throws IOException;
+
+ public void setOutputFilePrefix(String outputFilePrefix);
}
diff --git a/src/net/sf/antcontrib/cpptasks/compiler/LinkerConfiguration.java b/src/net/sf/antcontrib/cpptasks/compiler/LinkerConfiguration.java
index ff7ac5d..c6fe2dc 100644
--- a/src/net/sf/antcontrib/cpptasks/compiler/LinkerConfiguration.java
+++ b/src/net/sf/antcontrib/cpptasks/compiler/LinkerConfiguration.java
@@ -28,6 +28,7 @@ import org.apache.tools.ant.BuildException;
public interface LinkerConfiguration extends ProcessorConfiguration {
public LinkerParam getParam(String name);
void link(CCTask task, TargetInfo linkTarget) throws BuildException;
+ public void setOutputFilePrefix(String outputFilePrefix);
Linker getLinker();
boolean isDebug();
}
diff --git a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLibrarian.java b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLibrarian.java
index 985dfcf..f0f7bb8 100644
--- a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLibrarian.java
+++ b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLibrarian.java
@@ -30,7 +30,7 @@ import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
public abstract class DevStudioCompatibleLibrarian extends CommandLineLinker {
public DevStudioCompatibleLibrarian(String command, String identifierArg) {
super(command, identifierArg, new String[]{".obj"}, new String[0],
- ".lib", false, null);
+ "", ".lib", false, null);
}
protected void addBase(long base, Vector args) {
}
diff --git a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java
index c21a6f6..07a0aea 100644
--- a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java
+++ b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java
@@ -35,9 +35,9 @@ import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
*/
public abstract class DevStudioCompatibleLinker extends CommandLineLinker {
public DevStudioCompatibleLinker(String command, String identifierArg,
- String outputSuffix) {
+ String outputPrefix, String outputSuffix) {
super(command, identifierArg, new String[]{".obj", ".lib", ".res"},
- new String[]{".map", ".pdb", ".lnk", ".dll"}, outputSuffix,
+ new String[]{".map", ".pdb", ".lnk", ".dll"}, outputPrefix, outputSuffix,
false, null);
}
protected void addBase(long base, Vector args) {
diff --git a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioLinker.java b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioLinker.java
index 826074b..be89bfa 100644
--- a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioLinker.java
+++ b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioLinker.java
@@ -30,7 +30,7 @@ public final class DevStudioLinker extends DevStudioCompatibleLinker {
return instance;
}
private DevStudioLinker(String outputSuffix) {
- super("link", "/DLL", outputSuffix);
+ super("link", "/DLL", "", outputSuffix);
}
public Linker getLinker(LinkType type) {
if (type.isSharedLibrary()) {
diff --git a/src/net/sf/antcontrib/cpptasks/gcc/AbstractArLibrarian.java b/src/net/sf/antcontrib/cpptasks/gcc/AbstractArLibrarian.java
index 2e8d4af..45a8100 100644
--- a/src/net/sf/antcontrib/cpptasks/gcc/AbstractArLibrarian.java
+++ b/src/net/sf/antcontrib/cpptasks/gcc/AbstractArLibrarian.java
@@ -33,15 +33,13 @@ import org.apache.tools.ant.BuildException;
* @author Curt Arnold
*/
public abstract class AbstractArLibrarian extends CommandLineLinker {
- private/* final */
- String outputPrefix;
+
protected AbstractArLibrarian(String command, String identificationArg,
String[] inputExtensions, String[] ignoredExtensions,
String outputPrefix, String outputExtension, boolean isLibtool,
AbstractArLibrarian libtoolLibrarian) {
- super(command, identificationArg, inputExtensions, ignoredExtensions,
- outputExtension, isLibtool, libtoolLibrarian);
- this.outputPrefix = outputPrefix;
+ super(command, identificationArg, inputExtensions, ignoredExtensions,
+ outputPrefix, outputExtension, isLibtool, libtoolLibrarian);
}
public void addBase(long base, Vector args) {
}
diff --git a/src/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java b/src/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java
index a210e7e..1465198 100644
--- a/src/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java
+++ b/src/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java
@@ -33,14 +33,14 @@ import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
* @author Curt Arnold
*/
public abstract class AbstractLdLinker extends CommandLineLinker {
- private String outputPrefix;
+
+
protected AbstractLdLinker(String command, String identifierArg,
String[] extensions, String[] ignoredExtensions,
String outputPrefix, String outputSuffix, boolean isLibtool,
AbstractLdLinker libtoolLinker) {
- super(command, identifierArg, extensions, ignoredExtensions,
+ super(command, identifierArg, extensions, ignoredExtensions, outputPrefix,
outputSuffix, isLibtool, libtoolLinker);
- this.outputPrefix = outputPrefix;
}
public void addBase(long base, Vector args) {
if (base >= 0) {
@@ -235,12 +235,19 @@ public abstract class AbstractLdLinker extends CommandLineLinker {
public int getMaximumCommandLength() {
return Integer.MAX_VALUE;
}
+
+
public String[] getOutputFileNames(String baseName, VersionInfo versionInfo) {
String[] baseNames = super.getOutputFileNames(baseName, versionInfo);
- if (outputPrefix.length() > 0) {
+ String currentOutputPrefix = "";
+ if(null != outputFilePrefix)
+ currentOutputPrefix = outputFilePrefix;
+ else
+ currentOutputPrefix = outputPrefix;
+ if (outputPrefix.length() > 0) {
for(int i = 0; i < baseNames.length; i++) {
- baseNames[i] = outputPrefix + baseNames[i];
- }
+ baseNames[i] = currentOutputPrefix + baseNames[i];
+ }
}
return baseNames;
}
diff --git a/src/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java b/src/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java
index 999ccf7..d58d1b3 100644
--- a/src/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java
+++ b/src/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java
@@ -234,7 +234,8 @@ public final class GccCCompiler extends GccCompatibleCCompiler {
return identifier;
}
public Linker getLinker(LinkType linkType) {
- return GccLinker.getInstance().getLinker(linkType);
+ GccLinker linker = GccLinker.getInstance();
+ return linker.getLinker(linkType);
}
public int getMaximumCommandLength() {
return Integer.MAX_VALUE;
diff --git a/src/net/sf/antcontrib/cpptasks/gcc/GccLinker.java b/src/net/sf/antcontrib/cpptasks/gcc/GccLinker.java
index c4720c8..6fff653 100644
--- a/src/net/sf/antcontrib/cpptasks/gcc/GccLinker.java
+++ b/src/net/sf/antcontrib/cpptasks/gcc/GccLinker.java
@@ -28,32 +28,59 @@ import net.sf.antcontrib.cpptasks.compiler.Linker;
*/
public class GccLinker extends AbstractLdLinker {
private static final String[] discardFiles = new String[0];
+
private static final String[] objFiles = new String[]{".o", ".a", ".lib",
".dll", ".so", ".sl"};
+
private static final String[] libtoolObjFiles = new String[]{".fo", ".a",
".lib", ".dll", ".so", ".sl"};
+
private static String[] linkerOptions = new String[]{"-bundle",
"-dynamiclib", "-nostartfiles", "-nostdlib", "-prebind", "-s",
"-static", "-shared", "-symbolic", "-Xlinker",
"--export-all-symbols", "-static-libgcc",};
- private static final GccLinker dllLinker = new GccLinker("gcc", objFiles,
- discardFiles, "lib", ".so", false, new GccLinker("gcc", objFiles,
- discardFiles, "lib", ".so", true, null));
- private static final GccLinker instance = new GccLinker("gcc", objFiles,
- discardFiles, "", "", false, null);
- private static final GccLinker machBundleLinker = new GccLinker("gcc",
- objFiles, discardFiles, "lib", ".bundle", false, null);
- private static final GccLinker machDllLinker = new GccLinker("gcc",
- objFiles, discardFiles, "lib", ".dylib", false, null);
+
+ private static GccLinker dllLinker;
+ private static Object dllLinkerGaurd = new Object(); //used as a gaurd for dllLinker since you can't synchronize on a null
+
+ private static GccLinker instance;
+ private static Object instanceGaurd = new Object();//used as a gaurd for instance
+
+ private static GccLinker machBundleLinker;
+ private static Object machBundleLinkerGaurd = new Object();
+
+
+ private static GccLinker machDllLinker;
+ private static Object machDllLinkerGaurd = new Object();
+
public static GccLinker getInstance() {
+ String currentOutputFilePrefix = outputFilePrefix == null ? "lib" : outputFilePrefix;
+ synchronized (instanceGaurd)
+ {
+ if (null == instance)
+ instance = new GccLinker("gcc", objFiles, discardFiles, currentOutputFilePrefix, "", false, null);
+ }
return instance;
}
+
+ public static GccLinker getInstance(String outputFilePrefix) {
+ String currentOutputFilePrefix = outputFilePrefix == null ? "lib" : outputFilePrefix;
+ synchronized (instanceGaurd)
+ {
+ if (null == instance)
+ instance = new GccLinker("gcc", objFiles, discardFiles, currentOutputFilePrefix, "", false, null);
+ }
+ return instance;
+ }
+
private File[] libDirs;
protected GccLinker(String command, String[] extensions,
String[] ignoredExtensions, String outputPrefix,
String outputSuffix, boolean isLibtool, GccLinker libtoolLinker) {
+
super(command, "-dumpversion", extensions, ignoredExtensions,
outputPrefix, outputSuffix, isLibtool, libtoolLinker);
+
}
protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args) {
super.addImpliedArgs(debug, linkType, args);
@@ -188,23 +215,60 @@ public class GccLinker extends AbstractLdLinker {
return libDirs;
}
public Linker getLinker(LinkType type) {
+ String currentOutputFilePrefix = outputFilePrefix == null ? "lib" : outputFilePrefix;
if (type.isStaticLibrary()) {
return GccLibrarian.getInstance();
}
+ //The seemingly heavy use of synchronized here is because of the late instanciation of a number of linkers. This, in turn,
+ //is to allow for setting the prefix
if (type.isPluginModule()) {
if (isDarwin()) {
- return machBundleLinker;
+ synchronized(machBundleLinkerGaurd)//used as a gaurd for machBundleLinker since you can't synchronize on a null
+ {
+ if(null == machBundleLinker){
+ machBundleLinker = new GccLinker("gcc", objFiles, discardFiles, currentOutputFilePrefix, ".bundle", false, null);
+ }
+ }
+ return machBundleLinker;
+
} else {
- return dllLinker;
+ synchronized(dllLinkerGaurd)//used as a gaurd for dllLinker since you can't synchronize on a null
+ {
+ if(null == dllLinker){
+ dllLinker = new GccLinker("gcc", objFiles, discardFiles,
+ "lib", ".so", false,
+ new GccLinker("gcc", objFiles, discardFiles, currentOutputFilePrefix, ".so", true, null));
+ }
+ }
+ return dllLinker;
}
}
if (type.isSharedLibrary()) {
if (isDarwin()) {
- return machDllLinker;
+ synchronized(machDllLinkerGaurd)//used as a gaurd for machDllLinker since you can't synchronize on a null
+ {
+ if(null == machDllLinker){
+ machDllLinker = new GccLinker("gcc", objFiles, discardFiles, currentOutputFilePrefix, ".dylib", false, null);;
+ }
+ }
+ return machDllLinker;
+
+
+
} else {
- return dllLinker;
+ synchronized(dllLinkerGaurd)//used as a gaurd for dllLinker since you can't synchronize on a null
+ {
+ if(null == dllLinker){
+ dllLinker = new GccLinker("gcc", objFiles, discardFiles,
+ "lib", ".so", false,
+ new GccLinker("gcc", objFiles, discardFiles, currentOutputFilePrefix, ".so", true, null));
+ }
+ }
+ return dllLinker;
+
}
}
- return instance;
+ return getInstance();
}
+
}
diff --git a/src/net/sf/antcontrib/cpptasks/intel/IntelWin32Linker.java b/src/net/sf/antcontrib/cpptasks/intel/IntelWin32Linker.java
index 66009f0..8700c42 100644
--- a/src/net/sf/antcontrib/cpptasks/intel/IntelWin32Linker.java
+++ b/src/net/sf/antcontrib/cpptasks/intel/IntelWin32Linker.java
@@ -32,7 +32,7 @@ public final class IntelWin32Linker extends DevStudioCompatibleLinker {
return instance;
}
private IntelWin32Linker(String outputSuffix) {
- super("xilink", "-qv", outputSuffix);
+ super("xilink", "-qv", "", outputSuffix);
}
public Linker getLinker(LinkType type) {
if (type.isStaticLibrary()) {
diff --git a/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomLibrarian.java b/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomLibrarian.java
index 848c395..d0e09fd 100644
--- a/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomLibrarian.java
+++ b/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomLibrarian.java
@@ -51,7 +51,7 @@ public final class OpenWatcomLibrarian
*/
private OpenWatcomLibrarian() {
super("wlib", null, new String[] {".obj"}
- , new String[0], ".lib", false,
+ , new String[0], "", ".lib", false,
null);
}
diff --git a/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomLinker.java b/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomLinker.java
index f0bbe3d..6daaebb 100644
--- a/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomLinker.java
+++ b/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomLinker.java
@@ -44,7 +44,7 @@ public abstract class OpenWatcomLinker
final String outputSuffix) {
super(command, "-r", new String[] {".obj", ".lib", ".res"}
,
- new String[] {".map", ".pdb", ".lnk"}
+ new String[] {".map", ".pdb", ".lnk"}, ""
, outputSuffix, false, null);
}
diff --git a/src/net/sf/antcontrib/cpptasks/os390/OS390Linker.java b/src/net/sf/antcontrib/cpptasks/os390/OS390Linker.java
index 9c4f845..5c66acf 100644
--- a/src/net/sf/antcontrib/cpptasks/os390/OS390Linker.java
+++ b/src/net/sf/antcontrib/cpptasks/os390/OS390Linker.java
@@ -48,18 +48,15 @@ public final class OS390Linker extends CommandLineLinker {
}
private boolean isADatasetLinker;
File outputFile;
- private String outputPrefix;
CCTask task;
private OS390Linker() {
super("cxx", "/bogus", new String[]{".o", ".a", ".lib", ".xds"},
- new String[]{".dll", ".x"}, ".xds", false, null);
- this.outputPrefix = "";
+ new String[]{".dll", ".x"}, "", ".xds", false, null);
this.isADatasetLinker = true;
}
private OS390Linker(String outputPrefix, String outputSuffix) {
super("cxx", "/bogus", new String[]{".o", ".a", ".lib", ".x"},
- new String[]{".dll"}, outputSuffix, false, null);
- this.outputPrefix = outputPrefix;
+ new String[]{".dll"}, outputPrefix, outputSuffix, false, null);
this.isADatasetLinker = false;
}
protected void addBase(long base, Vector args) {
diff --git a/src/net/sf/antcontrib/cpptasks/os400/IccLinker.java b/src/net/sf/antcontrib/cpptasks/os400/IccLinker.java
index ea10bcc..62407a8 100644
--- a/src/net/sf/antcontrib/cpptasks/os400/IccLinker.java
+++ b/src/net/sf/antcontrib/cpptasks/os400/IccLinker.java
@@ -46,18 +46,17 @@ public final class IccLinker extends CommandLineLinker {
}
private boolean isADatasetLinker;
File outputFile;
- private String outputPrefix;
+
CCTask task;
private IccLinker() {
super("icc", "/bogus", new String[]{".o", ".a", ".lib", ".xds"},
- new String[]{".dll", ".x"}, ".xds", false, null);
- this.outputPrefix = "";
+ new String[]{".dll", ".x"}, "", ".xds", false, null);
+
this.isADatasetLinker = true;
}
private IccLinker(String outputPrefix, String outputSuffix) {
super("icc", "/bogus", new String[]{".o", ".a", ".lib", ".x"},
- new String[]{".dll"}, outputSuffix, false, null);
- this.outputPrefix = outputPrefix;
+ new String[]{".dll"}, outputPrefix, outputSuffix, false, null);
this.isADatasetLinker = false;
}
protected void addBase(long base, Vector args) {
diff --git a/src/net/sf/antcontrib/cpptasks/sun/C89Linker.java b/src/net/sf/antcontrib/cpptasks/sun/C89Linker.java
index 6c41c89..22290fd 100644
--- a/src/net/sf/antcontrib/cpptasks/sun/C89Linker.java
+++ b/src/net/sf/antcontrib/cpptasks/sun/C89Linker.java
@@ -38,11 +38,11 @@ public final class C89Linker extends CommandLineLinker {
public static C89Linker getInstance() {
return instance;
}
- private String outputPrefix;
+
private C89Linker(String outputPrefix, String outputSuffix) {
super("ld", "/bogus", new String[]{".o", ".a", ".lib", ".x"},
- new String[]{}, outputSuffix, false, null);
- this.outputPrefix = outputPrefix;
+ new String[]{}, outputPrefix, outputSuffix, false, null);
+
}
protected void addBase(long base, Vector args) {
}
diff --git a/src/net/sf/antcontrib/cpptasks/ti/ClxxLibrarian.java b/src/net/sf/antcontrib/cpptasks/ti/ClxxLibrarian.java
index c48815a..2dc9002 100644
--- a/src/net/sf/antcontrib/cpptasks/ti/ClxxLibrarian.java
+++ b/src/net/sf/antcontrib/cpptasks/ti/ClxxLibrarian.java
@@ -39,7 +39,7 @@ public class ClxxLibrarian extends CommandLineLinker {
return cl6xInstance;
}
private ClxxLibrarian(String command) {
- super(command, null, new String[]{".o"}, new String[0], ".lib", false,
+ super(command, null, new String[]{".o"}, new String[0], "", ".lib", false,
null);
}
/*
diff --git a/src/net/sf/antcontrib/cpptasks/ti/ClxxLinker.java b/src/net/sf/antcontrib/cpptasks/ti/ClxxLinker.java
index bb644a4..b2976a3 100644
--- a/src/net/sf/antcontrib/cpptasks/ti/ClxxLinker.java
+++ b/src/net/sf/antcontrib/cpptasks/ti/ClxxLinker.java
@@ -52,7 +52,7 @@ public class ClxxLinker extends CommandLineLinker {
}
private ClxxLinker(String command, String outputSuffix) {
super(command, "-h", new String[]{".o", ".lib", ".res"}, new String[]{
- ".map", ".pdb", ".lnk"}, outputSuffix, false, null);
+ ".map", ".pdb", ".lnk"}, "", outputSuffix, false, null);
}
/*
* (non-Javadoc)