summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-12-11 12:33:13 +0100
committerSven Gothel <[email protected]>2019-12-11 12:33:13 +0100
commit79a8fed9fddab5429a3457c3077ee5012b405a51 (patch)
treeb54da232ade244b70d48d05bfdc970836a453004 /src
parentec14765d6baab247fa37d62845c139adc367af2a (diff)
Expose full linker output filename via TargetInfo; Cleanup AbstractLinker 'String[] getOutputFileNames(..)' -> 'String getOutputFileName(..)'
Diffstat (limited to 'src')
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/CCTask.java8
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/TargetInfo.java15
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/TargetMatcher.java10
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/compiler/AbstractLinker.java18
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java5
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineLinkerConfiguration.java7
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/compiler/LinkerConfiguration.java10
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/gcc/AbstractArLibrarian.java11
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java11
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/os390/OS390Linker.java11
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/os400/IccLinker.java11
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/sun/C89Linker.java11
12 files changed, 74 insertions, 54 deletions
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/CCTask.java b/src/main/java/net/sf/antcontrib/cpptasks/CCTask.java
index 3a5506d..3197080 100644
--- a/src/main/java/net/sf/antcontrib/cpptasks/CCTask.java
+++ b/src/main/java/net/sf/antcontrib/cpptasks/CCTask.java
@@ -874,11 +874,11 @@ public class CCTask extends Task {
objectFiles.copyInto(objectFileArray);
final File[] sysObjectFileArray = new File[sysObjectFiles.size()];
sysObjectFiles.copyInto(sysObjectFileArray);
- final String baseName = _outfile.getName();
- final String[] fullNames = linkerConfig.getOutputFileNames(baseName, versionInfo);
- final File outputFile = new File(_outfile.getParent(), fullNames[0]);
+ final String outputBaseNameWithDir = _outfile.getName(); // like '/use/lib/gluegen_rt'
+ final String outputFullName = linkerConfig.getOutputFileName(outputBaseNameWithDir, versionInfo); // like 'libgluegen-rt.so'
+ final File outputFile = new File(_outfile.getParent(), outputFullName);
return new TargetInfo(linkerConfig, objectFileArray,
- sysObjectFileArray, outputFile, linkerConfig.getRebuild());
+ sysObjectFileArray, outputFile, outputFullName, linkerConfig.getRebuild());
}
public File getObjdir() {
return _objDir;
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/TargetInfo.java b/src/main/java/net/sf/antcontrib/cpptasks/TargetInfo.java
index e3706ac..bfd1baa 100644
--- a/src/main/java/net/sf/antcontrib/cpptasks/TargetInfo.java
+++ b/src/main/java/net/sf/antcontrib/cpptasks/TargetInfo.java
@@ -25,11 +25,12 @@ public final class TargetInfo {
private static final File[] emptyFileArray = new File[0];
private final ProcessorConfiguration config;
private final File output;
+ private final String outputBasename;
private boolean rebuild;
private final File[] sources;
private File[] sysSources;
- public TargetInfo(ProcessorConfiguration config, File[] sources,
- File[] sysSources, File output, boolean rebuild) {
+ public TargetInfo(final ProcessorConfiguration config, final File[] sources,
+ final File[] sysSources, final File output, final String outputBasename, boolean rebuild) {
if (config == null) {
throw new NullPointerException("config");
}
@@ -39,6 +40,9 @@ public final class TargetInfo {
if (output == null) {
throw new NullPointerException("output");
}
+ if (outputBasename == null) {
+ throw new NullPointerException("outputBasename");
+ }
this.config = config;
this.sources = sources.clone();
if (sysSources == null) {
@@ -47,6 +51,7 @@ public final class TargetInfo {
this.sysSources = sysSources.clone();
}
this.output = output;
+ this.outputBasename = outputBasename;
this.rebuild = rebuild;
//
// if the output doesn't exist, must rebuild it
@@ -83,6 +88,12 @@ public final class TargetInfo {
public File getOutput() {
return output;
}
+ /**
+ * @return like 'libgluegen-rt.so'
+ */
+ public String getOutputBasename() {
+ return outputBasename;
+ }
public boolean getRebuild() {
return rebuild;
}
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/TargetMatcher.java b/src/main/java/net/sf/antcontrib/cpptasks/TargetMatcher.java
index 7661cf8..599aaf0 100644
--- a/src/main/java/net/sf/antcontrib/cpptasks/TargetMatcher.java
+++ b/src/main/java/net/sf/antcontrib/cpptasks/TargetMatcher.java
@@ -97,10 +97,12 @@ public final class TargetMatcher implements FileVisitor {
final TargetInfo previousTarget = (TargetInfo) targets
.get(outputFileNames[i]);
if (previousTarget == null) {
- targets.put(outputFileNames[i], new TargetInfo(
- selectedCompiler, sourceFiles, null, new File(
- outputDir, outputFileNames[i]),
- selectedCompiler.getRebuild()));
+ targets.put( outputFileNames[i],
+ new TargetInfo (
+ selectedCompiler, sourceFiles, null, new File(
+ outputDir, outputFileNames[i]), outputFileNames[i],
+ selectedCompiler.getRebuild() )
+ );
} else {
if (!previousTarget.getSources()[0].equals(sourceFiles[0])) {
final StringBuffer builder = new StringBuffer(
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/compiler/AbstractLinker.java b/src/main/java/net/sf/antcontrib/cpptasks/compiler/AbstractLinker.java
index 1ebd8cf..a5c24a4 100644
--- a/src/main/java/net/sf/antcontrib/cpptasks/compiler/AbstractLinker.java
+++ b/src/main/java/net/sf/antcontrib/cpptasks/compiler/AbstractLinker.java
@@ -92,7 +92,23 @@ public abstract class AbstractLinker extends AbstractProcessor
public String getLibraryKey(final File libfile) {
return libfile.getName();
}
- public abstract String[] getOutputFileNames(String fileName, VersionInfo versionInfo);
+ /**
+ * This implementation for a linker instance returns a unique output file
+ * as determined via {@link #getOutputFileName(String, VersionInfo)}.
+ */
+ @Override
+ public final String[] getOutputFileNames(final String baseName, final VersionInfo versionInfo) {
+ return new String[] { getOutputFileName(baseName, versionInfo) };
+ }
+ /**
+ * Unique output file for linker, also being used to fill a one element array
+ * of {@link #getOutputFileNames(String, VersionInfo)} implementation.
+ * @param inputFile the input file basename
+ * @param versionInfo the version number
+ * @return the unique output filename
+ * @see #getOutputFileNames(String, VersionInfo)
+ */
+ public abstract String getOutputFileName(String fileName, VersionInfo versionInfo);
/**
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java b/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java
index 24aa0d4..d7b30cd 100644
--- a/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java
+++ b/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java
@@ -236,8 +236,9 @@ public abstract class CommandLineLinker extends AbstractLinker
}
protected abstract int getMaximumCommandLength();
- public String[] getOutputFileNames(final String baseName, final VersionInfo versionInfo) {
- return new String[] { baseName + outputSuffix };
+ @Override
+ public String getOutputFileName(final String baseName, final VersionInfo versionInfo) {
+ return baseName + outputSuffix;
}
protected String[] getOutputFileSwitch(final CCTask task, final String outputFile) {
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineLinkerConfiguration.java b/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineLinkerConfiguration.java
index bc66648..ce42cc4 100644
--- a/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineLinkerConfiguration.java
+++ b/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineLinkerConfiguration.java
@@ -92,7 +92,12 @@ public final class CommandLineLinkerConfiguration
public final String[] getOutputFileNames(final String inputFile, final VersionInfo versionInfo) {
return linker.getOutputFileNames(inputFile, versionInfo);
}
- public LinkerParam getParam(String name) {
+ @Override
+ public final String getOutputFileName(final String inputFile, final VersionInfo versionInfo) {
+ return linker.getOutputFileName(inputFile, versionInfo);
+ }
+ @Override
+ public LinkerParam getParam(final String name) {
for (int i = 0; i < params.length; i++) {
if (name.equals(params[i].getName()))
return (LinkerParam) params[i];
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/compiler/LinkerConfiguration.java b/src/main/java/net/sf/antcontrib/cpptasks/compiler/LinkerConfiguration.java
index 114b8f1..4ef7ab3 100644
--- a/src/main/java/net/sf/antcontrib/cpptasks/compiler/LinkerConfiguration.java
+++ b/src/main/java/net/sf/antcontrib/cpptasks/compiler/LinkerConfiguration.java
@@ -18,6 +18,7 @@ package net.sf.antcontrib.cpptasks.compiler;
import net.sf.antcontrib.cpptasks.CCTask;
import net.sf.antcontrib.cpptasks.LinkerParam;
import net.sf.antcontrib.cpptasks.TargetInfo;
+import net.sf.antcontrib.cpptasks.VersionInfo;
import org.apache.tools.ant.BuildException;
/**
@@ -30,4 +31,13 @@ public interface LinkerConfiguration extends ProcessorConfiguration {
void link(CCTask task, TargetInfo linkTarget) throws BuildException;
Linker getLinker();
boolean isDebug();
+ /**
+ * Unique output file for linker, also being used to fill a one element array
+ * of {@link #getOutputFileNames(String, VersionInfo)} implementation.
+ * @param inputFile the input file basename
+ * @param versionInfo the version number
+ * @return the unique output filename
+ * @see #getOutputFileNames(String, VersionInfo)
+ */
+ String getOutputFileName(final String inputFile, final VersionInfo versionInfo);
}
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/gcc/AbstractArLibrarian.java b/src/main/java/net/sf/antcontrib/cpptasks/gcc/AbstractArLibrarian.java
index cfaa7f3..dfec253 100644
--- a/src/main/java/net/sf/antcontrib/cpptasks/gcc/AbstractArLibrarian.java
+++ b/src/main/java/net/sf/antcontrib/cpptasks/gcc/AbstractArLibrarian.java
@@ -84,14 +84,9 @@ public abstract class AbstractArLibrarian 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) {
- for(int i = 0; i < baseNames.length; i++) {
- baseNames[i] = outputPrefix + baseNames[i];
- }
- }
- return baseNames;
+ @Override
+ public String getOutputFileName(final String baseName, final VersionInfo versionInfo) {
+ return outputPrefix + super.getOutputFileName(baseName, versionInfo);
}
@Override
public String[] getOutputFileSwitch(final String outputFile) {
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java b/src/main/java/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java
index f99ba97..8543d4f 100644
--- a/src/main/java/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java
+++ b/src/main/java/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java
@@ -261,14 +261,9 @@ public abstract class AbstractLdLinker extends CommandLineLinker {
public int getMaximumCommandLength() {
return Integer.MAX_VALUE;
}
- public String[] getOutputFileNames(final String baseName, final VersionInfo versionInfo) {
- final String[] baseNames = super.getOutputFileNames(baseName, versionInfo);
- if (outputPrefix.length() > 0) {
- for(int i = 0; i < baseNames.length; i++) {
- baseNames[i] = outputPrefix + baseNames[i];
- }
- }
- return baseNames;
+ @Override
+ public String getOutputFileName(final String baseName, final VersionInfo versionInfo) {
+ return outputPrefix + super.getOutputFileName(baseName, versionInfo);
}
@Override
public String[] getOutputFileSwitch(final String outputFile) {
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/os390/OS390Linker.java b/src/main/java/net/sf/antcontrib/cpptasks/os390/OS390Linker.java
index b9aea47..7b4e581 100644
--- a/src/main/java/net/sf/antcontrib/cpptasks/os390/OS390Linker.java
+++ b/src/main/java/net/sf/antcontrib/cpptasks/os390/OS390Linker.java
@@ -162,14 +162,9 @@ public final class OS390Linker 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) {
- for(int i = 0; i < baseNames.length; i++) {
- baseNames[i] = outputPrefix + baseNames[i];
- }
- }
- return baseNames;
+ @Override
+ public String getOutputFileName(final String baseName, final VersionInfo versionInfo) {
+ return outputPrefix + super.getOutputFileName(baseName, versionInfo);
}
@Override
protected String[] getOutputFileSwitch(final CCTask task, String outputFile) {
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/os400/IccLinker.java b/src/main/java/net/sf/antcontrib/cpptasks/os400/IccLinker.java
index e942628..08c6055 100644
--- a/src/main/java/net/sf/antcontrib/cpptasks/os400/IccLinker.java
+++ b/src/main/java/net/sf/antcontrib/cpptasks/os400/IccLinker.java
@@ -215,13 +215,8 @@ public final class IccLinker extends CommandLineLinker {
}
return rc;
}
- public String[] getOutputFileNames(String baseName, VersionInfo versionInfo) {
- String[] baseNames = super.getOutputFileNames(baseName, versionInfo);
- if (outputPrefix.length() > 0) {
- for(int i = 0; i < baseNames.length; i++) {
- baseNames[i] = outputPrefix + baseNames[i];
- }
- }
- return baseNames;
+ @Override
+ public String getOutputFileName(final String baseName, final VersionInfo versionInfo) {
+ return outputPrefix + super.getOutputFileName(baseName, versionInfo);
}
}
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/sun/C89Linker.java b/src/main/java/net/sf/antcontrib/cpptasks/sun/C89Linker.java
index 3adb9e0..d1d2945 100644
--- a/src/main/java/net/sf/antcontrib/cpptasks/sun/C89Linker.java
+++ b/src/main/java/net/sf/antcontrib/cpptasks/sun/C89Linker.java
@@ -127,14 +127,9 @@ public final class C89Linker 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) {
- for(int i = 0; i < baseNames.length; i++) {
- baseNames[i] = outputPrefix + baseNames[i];
- }
- }
- return baseNames;
+ @Override
+ public String getOutputFileName(final String baseName, final VersionInfo versionInfo) {
+ return outputPrefix + super.getOutputFileName(baseName, versionInfo);
}
@Override
public String[] getOutputFileSwitch(final String outputFile) {