diff options
Diffstat (limited to 'src/net')
30 files changed, 88 insertions, 232 deletions
diff --git a/src/net/sf/antcontrib/cpptasks/CCTask.java b/src/net/sf/antcontrib/cpptasks/CCTask.java index d5c9f2e..beeed89 100644 --- a/src/net/sf/antcontrib/cpptasks/CCTask.java +++ b/src/net/sf/antcontrib/cpptasks/CCTask.java @@ -152,7 +152,6 @@ 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. */ @@ -209,10 +208,6 @@ 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 */ @@ -429,14 +424,11 @@ 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; - if(null != outputFilePrefixProperty){ - selectedLinkerDef.getLinker().setOutputFilePrefix(outputFilePrefixProperty); - } - selectedLinker = currentLinkerDef.getProcessor().getLinker(linkType); + selectedLinkerDef = currentLinkerDef; + selectedLinker = currentLinkerDef.getProcessor().getLinker( + linkType); // // skip the linker if it doesn't know how to // produce the specified link type @@ -471,12 +463,8 @@ public class CCTask extends Task { } if (linkerConfig == null) { linkerConfig = linkerDef.createConfiguration(this, linkType, null, targetPlatform, versionInfo); - - selectedLinker = (Linker) linkerDef.getLinker().getLinker( + selectedLinker = (Linker) linkerDef.getProcessor().getLinker( linkType); - if(null != outputFilePrefixProperty){ - selectedLinker.setOutputFilePrefix(outputFilePrefixProperty); - } objCollector = new ObjectFileCollector(selectedLinker, objectFiles); sysLibraryCollector = new SystemLibraryCollector(selectedLinker, sysLibraries); @@ -551,14 +539,7 @@ 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) { @@ -788,7 +769,6 @@ public class CCTask extends Task { log("Starting link"); LinkerConfiguration linkConfig = (LinkerConfiguration) linkTarget .getConfiguration(); - linkConfig.setOutputFilePrefix(outputFilePrefixProperty); if (failOnError) { linkConfig.link(this, linkTarget); } else { @@ -861,9 +841,6 @@ 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, @@ -1216,8 +1193,10 @@ public class CCTask extends Task { * */ public void setName(CompilerEnum name) { - compilerName = name; - + compilerDef.setName(name); + Processor compiler = compilerDef.getProcessor(); + Linker linker = compiler.getLinker(linkType); + linkerDef.setProcessor(linker); } /** * Do not propagate old environment when new environment variables are @@ -1267,15 +1246,6 @@ 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 51f3165..af1d307 100644 --- a/src/net/sf/antcontrib/cpptasks/LinkerDef.java +++ b/src/net/sf/antcontrib/cpptasks/LinkerDef.java @@ -281,17 +281,6 @@ 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 0efc1f6..65c430f 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 6b42b5c..fda52fa 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 bf9ee13..75846a4 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 ea1a523..315761f 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 9522a4b..2488619 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 001d833..c8930f9 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 a572930..e61bd64 100644 --- a/src/net/sf/antcontrib/cpptasks/compiler/AbstractCompiler.java +++ b/src/net/sf/antcontrib/cpptasks/compiler/AbstractCompiler.java @@ -41,7 +41,6 @@ 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); @@ -206,8 +205,4 @@ 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 5b5beaf..9de9491 100644 --- a/src/net/sf/antcontrib/cpptasks/compiler/AbstractLinker.java +++ b/src/net/sf/antcontrib/cpptasks/compiler/AbstractLinker.java @@ -32,11 +32,8 @@ import org.apache.tools.ant.types.Environment; * @author Adam Murdoch */ public abstract class AbstractLinker extends AbstractProcessor - implements Linker { - - protected static String outputFilePrefix = null; - - + implements + Linker { public AbstractLinker(String[] objExtensions, String[] ignoredExtensions) { super(objExtensions, ignoredExtensions); } @@ -67,16 +64,13 @@ 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, @@ -88,17 +82,11 @@ 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 2295a5c..38492ea 100644 --- a/src/net/sf/antcontrib/cpptasks/compiler/CommandLineCompilerConfiguration.java +++ b/src/net/sf/antcontrib/cpptasks/compiler/CommandLineCompilerConfiguration.java @@ -47,7 +47,6 @@ 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, @@ -224,7 +223,4 @@ 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 52b0d67..f9e4761 100644 --- a/src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java +++ b/src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java @@ -54,25 +54,17 @@ 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 outputPrefix, String outputSuffix, + String[] ignoredExtensions, 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 d67ffd3..f0aad67 100644 --- a/src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinkerConfiguration.java +++ b/src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinkerConfiguration.java @@ -87,13 +87,8 @@ 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 32c29ef..672a0e3 100644 --- a/src/net/sf/antcontrib/cpptasks/compiler/Linker.java +++ b/src/net/sf/antcontrib/cpptasks/compiler/Linker.java @@ -77,6 +77,4 @@ 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 c6fe2dc..ff7ac5d 100644 --- a/src/net/sf/antcontrib/cpptasks/compiler/LinkerConfiguration.java +++ b/src/net/sf/antcontrib/cpptasks/compiler/LinkerConfiguration.java @@ -28,7 +28,6 @@ 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 f0f7bb8..985dfcf 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 07a0aea..c21a6f6 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 outputPrefix, String outputSuffix) { + String outputSuffix) { super(command, identifierArg, new String[]{".obj", ".lib", ".res"}, - new String[]{".map", ".pdb", ".lnk", ".dll"}, outputPrefix, outputSuffix, + new String[]{".map", ".pdb", ".lnk", ".dll"}, 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 be89bfa..826074b 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 45a8100..2e8d4af 100644 --- a/src/net/sf/antcontrib/cpptasks/gcc/AbstractArLibrarian.java +++ b/src/net/sf/antcontrib/cpptasks/gcc/AbstractArLibrarian.java @@ -33,13 +33,15 @@ 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, - outputPrefix, outputExtension, isLibtool, libtoolLibrarian); + super(command, identificationArg, inputExtensions, ignoredExtensions, + outputExtension, isLibtool, libtoolLibrarian); + this.outputPrefix = outputPrefix; } 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 1465198..a210e7e 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, outputPrefix, + super(command, identifierArg, extensions, ignoredExtensions, outputSuffix, isLibtool, libtoolLinker); + this.outputPrefix = outputPrefix; } public void addBase(long base, Vector args) { if (base >= 0) { @@ -235,19 +235,12 @@ 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); - String currentOutputPrefix = ""; - if(null != outputFilePrefix) - currentOutputPrefix = outputFilePrefix; - else - currentOutputPrefix = outputPrefix; - if (outputPrefix.length() > 0) { + if (outputPrefix.length() > 0) { for(int i = 0; i < baseNames.length; i++) { - baseNames[i] = currentOutputPrefix + baseNames[i]; - } + baseNames[i] = outputPrefix + 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 d58d1b3..999ccf7 100644 --- a/src/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java +++ b/src/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java @@ -234,8 +234,7 @@ public final class GccCCompiler extends GccCompatibleCCompiler { return identifier; } public Linker getLinker(LinkType linkType) { - GccLinker linker = GccLinker.getInstance(); - return linker.getLinker(linkType); + return GccLinker.getInstance().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 6fff653..c4720c8 100644 --- a/src/net/sf/antcontrib/cpptasks/gcc/GccLinker.java +++ b/src/net/sf/antcontrib/cpptasks/gcc/GccLinker.java @@ -28,59 +28,32 @@ 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 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(); - + 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); 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); @@ -215,60 +188,23 @@ 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()) { - 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; - + return machBundleLinker; } else { - 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 dllLinker; } } if (type.isSharedLibrary()) { if (isDarwin()) { - 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; - - - + return machDllLinker; } else { - 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 dllLinker; } } - return getInstance(); + return instance; } - } diff --git a/src/net/sf/antcontrib/cpptasks/intel/IntelWin32Linker.java b/src/net/sf/antcontrib/cpptasks/intel/IntelWin32Linker.java index 8700c42..66009f0 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 d0e09fd..848c395 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 6daaebb..f0bbe3d 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 5c66acf..9c4f845 100644 --- a/src/net/sf/antcontrib/cpptasks/os390/OS390Linker.java +++ b/src/net/sf/antcontrib/cpptasks/os390/OS390Linker.java @@ -48,15 +48,18 @@ 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); + new String[]{".dll", ".x"}, ".xds", false, null); + this.outputPrefix = ""; this.isADatasetLinker = true; } private OS390Linker(String outputPrefix, String outputSuffix) { super("cxx", "/bogus", new String[]{".o", ".a", ".lib", ".x"}, - new String[]{".dll"}, outputPrefix, outputSuffix, false, null); + new String[]{".dll"}, outputSuffix, false, null); + this.outputPrefix = outputPrefix; 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 62407a8..ea10bcc 100644 --- a/src/net/sf/antcontrib/cpptasks/os400/IccLinker.java +++ b/src/net/sf/antcontrib/cpptasks/os400/IccLinker.java @@ -46,17 +46,18 @@ 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); - + new String[]{".dll", ".x"}, ".xds", false, null); + this.outputPrefix = ""; this.isADatasetLinker = true; } private IccLinker(String outputPrefix, String outputSuffix) { super("icc", "/bogus", new String[]{".o", ".a", ".lib", ".x"}, - new String[]{".dll"}, outputPrefix, outputSuffix, false, null); + new String[]{".dll"}, outputSuffix, false, null); + this.outputPrefix = outputPrefix; 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 22290fd..6c41c89 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[]{}, outputPrefix, outputSuffix, false, null); - + new String[]{}, outputSuffix, false, null); + this.outputPrefix = outputPrefix; } 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 2dc9002..c48815a 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 b2976a3..bb644a4 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) |