diff options
Diffstat (limited to 'src/main/java/net/sf')
14 files changed, 380 insertions, 264 deletions
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/CCTask.java b/src/main/java/net/sf/antcontrib/cpptasks/CCTask.java index 994e8d5..3a5506d 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/CCTask.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/CCTask.java @@ -127,6 +127,7 @@ public class CCTask extends Task { this.linker = linker; this.libraries = libraries; } + @Override public void visit(final File basedir, final String filename) { if (linker.bid(filename) > 0) { final File libfile = new File(basedir, filename); @@ -150,6 +151,7 @@ public class CCTask extends Task { * @param parentDir parent directory * @param filename filename within directory */ + @Override public void visit(final File parentDir, final String filename) { files.add(new File(parentDir, filename)); } @@ -569,6 +571,7 @@ public class CCTask extends Task { * @throws BuildException * if someting goes wrong with the build */ + @Override public void execute() throws BuildException { // // if link type allowed objdir to be defaulted @@ -1101,6 +1104,7 @@ public class CCTask extends Task { * * @deprecated */ + @Deprecated public void setLink(final OutputTypeEnum outputType) { linkType.setOutputType(outputType); } @@ -1316,6 +1320,7 @@ public class CCTask extends Task { /** * Sets the project. */ + @Override public void setProject(final Project project) { super.setProject(project); compilerDef.setProject(project); diff --git a/src/main/java/net/sf/antcontrib/cpptasks/TargetInfo.java b/src/main/java/net/sf/antcontrib/cpptasks/TargetInfo.java index 8fd5bb4..e3706ac 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/TargetInfo.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/TargetInfo.java @@ -1,5 +1,5 @@ /* - * + * * Copyright 2002-2004 The Ant-Contrib project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,10 +23,10 @@ import net.sf.antcontrib.cpptasks.compiler.ProcessorConfiguration; */ public final class TargetInfo { private static final File[] emptyFileArray = new File[0]; - private/* final */ProcessorConfiguration config; - private/* final */File output; + private final ProcessorConfiguration config; + private final File output; private boolean rebuild; - private/* final */File[] sources; + private final File[] sources; private File[] sysSources; public TargetInfo(ProcessorConfiguration config, File[] sources, File[] sysSources, File output, boolean rebuild) { @@ -40,11 +40,11 @@ public final class TargetInfo { throw new NullPointerException("output"); } this.config = config; - this.sources = (File[]) sources.clone(); + this.sources = sources.clone(); if (sysSources == null) { this.sysSources = emptyFileArray; } else { - this.sysSources = (File[]) sysSources.clone(); + this.sysSources = sysSources.clone(); } this.output = output; this.rebuild = rebuild; @@ -56,22 +56,22 @@ public final class TargetInfo { } } public String[] getAllSourcePaths() { - String[] paths = new String[sysSources.length + sources.length]; + final String[] paths = new String[sysSources.length + sources.length]; for (int i = 0; i < sysSources.length; i++) { paths[i] = sysSources[i].toString(); } - int offset = sysSources.length; + final int offset = sysSources.length; for (int i = 0; i < sources.length; i++) { paths[offset + i] = sources[i].toString(); } return paths; } public File[] getAllSources() { - File[] allSources = new File[sources.length + sysSources.length]; + final File[] allSources = new File[sources.length + sysSources.length]; for (int i = 0; i < sysSources.length; i++) { allSources[i] = sysSources[i]; } - int offset = sysSources.length; + final int offset = sysSources.length; for (int i = 0; i < sources.length; i++) { allSources[i + offset] = sources[i]; } @@ -90,35 +90,35 @@ public final class TargetInfo { * Returns an array of SourceHistory objects (contains relative path and * last modified time) for the source[s] of this target */ - public SourceHistory[] getSourceHistories(String basePath) { - SourceHistory[] histories = new SourceHistory[sources.length]; + public SourceHistory[] getSourceHistories(final String basePath) { + final SourceHistory[] histories = new SourceHistory[sources.length]; for (int i = 0; i < sources.length; i++) { - String relativeName = CUtil.getRelativePath(basePath, sources[i]); - long lastModified = sources[i].lastModified(); + final String relativeName = CUtil.getRelativePath(basePath, sources[i]); + final long lastModified = sources[i].lastModified(); histories[i] = new SourceHistory(relativeName, lastModified); } return histories; } public String[] getSourcePaths() { - String[] paths = new String[sources.length]; + final String[] paths = new String[sources.length]; for (int i = 0; i < sources.length; i++) { paths[i] = sources[i].toString(); } return paths; } public File[] getSources() { - File[] clone = (File[]) sources.clone(); + final File[] clone = sources.clone(); return clone; } public String[] getSysSourcePaths() { - String[] paths = new String[sysSources.length]; + final String[] paths = new String[sysSources.length]; for (int i = 0; i < sysSources.length; i++) { paths[i] = sysSources[i].toString(); } return paths; } public File[] getSysSources() { - File[] clone = (File[]) sysSources.clone(); + final File[] clone = sysSources.clone(); return clone; } public void mustRebuild() { diff --git a/src/main/java/net/sf/antcontrib/cpptasks/TargetMatcher.java b/src/main/java/net/sf/antcontrib/cpptasks/TargetMatcher.java index 9260f77..7661cf8 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/TargetMatcher.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/TargetMatcher.java @@ -29,18 +29,18 @@ import org.apache.tools.ant.BuildException; * @author Curt Arnold */ public final class TargetMatcher implements FileVisitor { - private LinkerConfiguration linker; - private Vector objectFiles; - private File outputDir; - private ProcessorConfiguration[] processors; + private final LinkerConfiguration linker; + private final Vector objectFiles; + private final File outputDir; + private final ProcessorConfiguration[] processors; private final File sourceFiles[] = new File[1]; - private Hashtable targets; - private VersionInfo versionInfo; - private CCTask task; - public TargetMatcher(CCTask task, File outputDir, - ProcessorConfiguration[] processors, LinkerConfiguration linker, - Vector objectFiles, Hashtable targets, - VersionInfo versionInfo) { + private final Hashtable targets; + private final VersionInfo versionInfo; + private final CCTask task; + public TargetMatcher(final CCTask task, final File outputDir, + final ProcessorConfiguration[] processors, final LinkerConfiguration linker, + final Vector objectFiles, final Hashtable targets, + final VersionInfo versionInfo) { this.task = task; this.outputDir = outputDir; this.processors = processors; @@ -49,8 +49,8 @@ public final class TargetMatcher implements FileVisitor { this.objectFiles = objectFiles; this.versionInfo = versionInfo; } - public void visit(File parentDir, String filename) throws BuildException { - File fullPath = new File(parentDir, filename); + public void visit(final File parentDir, final String filename) throws BuildException { + final File fullPath = new File(parentDir, filename); // // see if any processor wants to bid // on this one @@ -58,7 +58,7 @@ public final class TargetMatcher implements FileVisitor { int bid = 0; if (processors != null) { for (int k = 0; k < processors.length; k++) { - int newBid = processors[k].bid(fullPath.toString()); + final int newBid = processors[k].bid(fullPath.toString()); if (newBid > bid) { bid = newBid; selectedCompiler = processors[k]; @@ -70,7 +70,7 @@ public final class TargetMatcher implements FileVisitor { // log diagnostic message if (bid <= 0) { if (linker != null) { - int linkerbid = linker.bid(filename); + final int linkerbid = linker.bid(filename); if (linkerbid > 0) { objectFiles.addElement(fullPath); if (linkerbid == 1) { @@ -83,7 +83,7 @@ public final class TargetMatcher implements FileVisitor { // // get output file name // - String[] outputFileNames = selectedCompiler + final String[] outputFileNames = selectedCompiler .getOutputFileNames(filename, versionInfo); sourceFiles[0] = fullPath; // @@ -94,7 +94,7 @@ public final class TargetMatcher implements FileVisitor { // // see if the same output file has already been registered // - TargetInfo previousTarget = (TargetInfo) targets + final TargetInfo previousTarget = (TargetInfo) targets .get(outputFileNames[i]); if (previousTarget == null) { targets.put(outputFileNames[i], new TargetInfo( @@ -103,7 +103,7 @@ public final class TargetMatcher implements FileVisitor { selectedCompiler.getRebuild())); } else { if (!previousTarget.getSources()[0].equals(sourceFiles[0])) { - StringBuffer builder = new StringBuffer( + final StringBuffer builder = new StringBuffer( "Output filename conflict: "); builder.append(outputFileNames[i]); builder.append(" would be produced from "); diff --git a/src/main/java/net/sf/antcontrib/cpptasks/compiler/AbstractCompiler.java b/src/main/java/net/sf/antcontrib/cpptasks/compiler/AbstractCompiler.java index c75334d..aa40d0b 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/compiler/AbstractCompiler.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/compiler/AbstractCompiler.java @@ -41,12 +41,12 @@ public abstract class AbstractCompiler extends AbstractProcessor Compiler { private static final String[] emptyIncludeArray = new String[0]; private final String outputSuffix; - protected AbstractCompiler(String[] sourceExtensions, - String[] headerExtensions, String outputSuffix) { + protected AbstractCompiler(final String[] sourceExtensions, + final String[] headerExtensions, final String outputSuffix) { super(sourceExtensions, headerExtensions); this.outputSuffix = outputSuffix; } - protected AbstractCompiler(AbstractCompiler cc) { + protected AbstractCompiler(final AbstractCompiler cc) { super(cc); this.outputSuffix = cc.outputSuffix; } @@ -57,11 +57,11 @@ public abstract class AbstractCompiler extends AbstractProcessor * 'tlb', '.res' * */ - protected boolean canParse(File sourceFile) { - String sourceName = sourceFile.toString(); - int lastPeriod = sourceName.lastIndexOf('.'); + protected boolean canParse(final File sourceFile) { + final String sourceName = sourceFile.toString(); + final int lastPeriod = sourceName.lastIndexOf('.'); if (lastPeriod >= 0 && lastPeriod == sourceName.length() - 4) { - String ext = sourceName.substring(lastPeriod).toUpperCase(); + final String ext = sourceName.substring(lastPeriod).toUpperCase(); if (ext.equals(".DLL") || ext.equals(".TLB") || ext.equals(".RES")) { return false; } @@ -72,10 +72,11 @@ public abstract class AbstractCompiler extends AbstractProcessor LinkType linkType, ProcessorDef[] baseConfigs, CompilerDef specificConfig, TargetDef targetPlatform, VersionInfo versionInfo); - public ProcessorConfiguration createConfiguration(CCTask task, - LinkType linkType, ProcessorDef[] baseConfigs, - ProcessorDef specificConfig, TargetDef targetPlatform, - VersionInfo versionInfo) { + @Override + public ProcessorConfiguration createConfiguration(final CCTask task, + final LinkType linkType, final ProcessorDef[] baseConfigs, + final ProcessorDef specificConfig, final TargetDef targetPlatform, + final VersionInfo versionInfo) { if (specificConfig == null) { throw new NullPointerException("specificConfig"); } @@ -83,10 +84,10 @@ public abstract class AbstractCompiler extends AbstractProcessor (CompilerDef) specificConfig, targetPlatform, versionInfo); } abstract protected Parser createParser(File sourceFile); - protected String getBaseOutputName(String inputFile) { + protected String getBaseOutputName(final String inputFile) { int lastSlash = inputFile.lastIndexOf('/'); - int lastReverse = inputFile.lastIndexOf('\\'); - int lastSep = inputFile.lastIndexOf(File.separatorChar); + final int lastReverse = inputFile.lastIndexOf('\\'); + final int lastSep = inputFile.lastIndexOf(File.separatorChar); if (lastReverse > lastSlash) { lastSlash = lastReverse; } @@ -99,12 +100,13 @@ public abstract class AbstractCompiler extends AbstractProcessor } return inputFile.substring(lastSlash + 1, lastPeriod); } - public String[] getOutputFileNames(String inputFile, VersionInfo versionInfo) { + @Override + public String[] getOutputFileNames(final String inputFile, final VersionInfo versionInfo) { // // if a recognized input file // if (bid(inputFile) > 1) { - String baseName = getBaseOutputName(inputFile); + final String baseName = getBaseOutputName(inputFile); return new String[] { baseName + outputSuffix }; } return new String[0]; @@ -134,40 +136,40 @@ public abstract class AbstractCompiler extends AbstractProcessor * path settings * */ - public final DependencyInfo parseIncludes(CCTask task, File source, - File[] includePath, File[] sysIncludePath, File[] envIncludePath, - File baseDir, String includePathIdentifier) { + public final DependencyInfo parseIncludes(final CCTask task, final File source, + final File[] includePath, final File[] sysIncludePath, final File[] envIncludePath, + final File baseDir, final String includePathIdentifier) { // // if any of the include files can not be identified // change the sourceLastModified to Long.MAX_VALUE to // force recompilation of anything that depends on it long sourceLastModified = source.lastModified(); - File[] sourcePath = new File[1]; + final File[] sourcePath = new File[1]; sourcePath[0] = new File(source.getParent()); - Vector onIncludePath = new Vector(); - Vector onSysIncludePath = new Vector(); + final Vector onIncludePath = new Vector(); + final Vector onSysIncludePath = new Vector(); String baseDirPath; try { baseDirPath = baseDir.getCanonicalPath(); - } catch (IOException ex) { + } catch (final IOException ex) { baseDirPath = baseDir.toString(); } - String relativeSource = CUtil.getRelativePath(baseDirPath, source); + final String relativeSource = CUtil.getRelativePath(baseDirPath, source); String[] includes = emptyIncludeArray; if (canParse(source)) { - Parser parser = createParser(source); + final Parser parser = createParser(source); try { - Reader reader = new BufferedReader(new FileReader(source)); + final Reader reader = new BufferedReader(new FileReader(source)); parser.parse(reader); includes = parser.getIncludes(); - } catch (IOException ex) { + } catch (final IOException ex) { task.log("Error parsing " + source.toString() + ":" + ex.toString()); includes = new String[0]; } } for (int i = 0; i < includes.length; i++) { - String includeName = includes[i]; + final String includeName = includes[i]; if (!resolveInclude(includeName, sourcePath, onIncludePath)) { if (!resolveInclude(includeName, includePath, onIncludePath)) { if (!resolveInclude(includeName, sysIncludePath, @@ -185,22 +187,22 @@ public abstract class AbstractCompiler extends AbstractProcessor } } for (int i = 0; i < onIncludePath.size(); i++) { - String relativeInclude = CUtil.getRelativePath(baseDirPath, + final String relativeInclude = CUtil.getRelativePath(baseDirPath, (File) onIncludePath.elementAt(i)); onIncludePath.setElementAt(relativeInclude, i); } for (int i = 0; i < onSysIncludePath.size(); i++) { - String relativeInclude = CUtil.getRelativePath(baseDirPath, + final String relativeInclude = CUtil.getRelativePath(baseDirPath, (File) onSysIncludePath.elementAt(i)); onSysIncludePath.setElementAt(relativeInclude, i); } return new DependencyInfo(includePathIdentifier, relativeSource, sourceLastModified, onIncludePath, onSysIncludePath); } - protected boolean resolveInclude(String includeName, File[] includePath, - Vector onThisPath) { + protected boolean resolveInclude(final String includeName, final File[] includePath, + final Vector onThisPath) { for (int i = 0; i < includePath.length; i++) { - File includeFile = new File(includePath[i], includeName); + final File includeFile = new File(includePath[i], includeName); if (includeFile.exists()) { onThisPath.addElement(includeFile); return true; 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 4e81408..1ebd8cf 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/compiler/AbstractLinker.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/compiler/AbstractLinker.java @@ -34,10 +34,10 @@ import org.apache.tools.ant.types.Environment; public abstract class AbstractLinker extends AbstractProcessor implements Linker { - public AbstractLinker(String[] objExtensions, String[] ignoredExtensions) { + public AbstractLinker(final String[] objExtensions, final String[] ignoredExtensions) { super(objExtensions, ignoredExtensions); } - public AbstractLinker(AbstractLinker ld) { + public AbstractLinker(final AbstractLinker ld) { super(ld); } /** @@ -51,8 +51,9 @@ public abstract class AbstractLinker extends AbstractProcessor * processor recognizes the file but doesn't process it (header * files, for example), 100 indicates strong interest */ - public int bid(String inputFile) { - int bid = super.bid(inputFile); + @Override + public int bid(final String inputFile) { + final int bid = super.bid(inputFile); switch (bid) { // // unrecognized extension, take the file @@ -67,25 +68,28 @@ public abstract class AbstractLinker extends AbstractProcessor } return bid; } - public Processor changeEnvironment(boolean newEnvironment, Environment env) { + @Override + public Processor changeEnvironment(final boolean newEnvironment, final 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, - TargetDef targetPlatform, - VersionInfo versionInfo) { + @Override + public ProcessorConfiguration createConfiguration(final CCTask task, + final LinkType linkType, final ProcessorDef[] baseConfigs, + final ProcessorDef specificConfig, + final TargetDef targetPlatform, + final VersionInfo versionInfo) { if (specificConfig == null) { throw new NullPointerException("specificConfig"); } return createConfiguration(task, linkType, baseConfigs, (LinkerDef) specificConfig, targetPlatform, versionInfo); } - public String getLibraryKey(File libfile) { + @Override + public String getLibraryKey(final File libfile) { return libfile.getName(); } public abstract String[] getOutputFileNames(String fileName, VersionInfo versionInfo); @@ -102,7 +106,8 @@ public abstract class AbstractLinker extends AbstractProcessor * @param objDir directory for generated files * @param matcher bidded fileset */ - public void addVersionFiles(final VersionInfo versionInfo, + @Override + public void addVersionFiles(final VersionInfo versionInfo, final LinkType linkType, final File outputFile, final boolean isDebug, diff --git a/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineCompilerConfiguration.java b/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineCompilerConfiguration.java index 38492ea..1cbfd27 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineCompilerConfiguration.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineCompilerConfiguration.java @@ -1,5 +1,5 @@ /* - * + * * Copyright 2002-2004 The Ant-Contrib project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,31 +26,31 @@ import net.sf.antcontrib.cpptasks.VersionInfo; import org.apache.tools.ant.BuildException; /** * A configuration for a C++ compiler - * + * * @author Curt Arnold */ public final class CommandLineCompilerConfiguration implements CompilerConfiguration { private/* final */String[] args; - private/* final */CommandLineCompiler compiler; - private String[] endArgs; + private final /* final */CommandLineCompiler compiler; + private final String[] endArgs; // // include path from environment variable not // explicitly stated in Ant script private/* final */File[] envIncludePath; private String[] exceptFiles; - private/* final */String identifier; + private final /* final */String identifier; private/* final */File[] includePath; - private/* final */String includePathIdentifier; - private boolean isPrecompiledHeaderGeneration; + private final /* final */String includePathIdentifier; + private final boolean isPrecompiledHeaderGeneration; private/* final */ProcessorParam[] params; - private/* final */boolean rebuild; + private final /* final */boolean rebuild; private/* final */File[] sysIncludePath; - public CommandLineCompilerConfiguration(CommandLineCompiler compiler, - String identifier, File[] includePath, File[] sysIncludePath, - File[] envIncludePath, String includePathIdentifier, String[] args, - ProcessorParam[] params, boolean rebuild, String[] endArgs) { + public CommandLineCompilerConfiguration(final CommandLineCompiler compiler, + final String identifier, final File[] includePath, final File[] sysIncludePath, + final File[] envIncludePath, final String includePathIdentifier, final String[] args, + final ProcessorParam[] params, final boolean rebuild, final String[] endArgs) { if (compiler == null) { throw new NullPointerException("compiler"); } @@ -63,45 +63,45 @@ public final class CommandLineCompilerConfiguration if (args == null) { this.args = new String[0]; } else { - this.args = (String[]) args.clone(); + this.args = args.clone(); } if (includePath == null) { this.includePath = new File[0]; } else { - this.includePath = (File[]) includePath.clone(); + this.includePath = includePath.clone(); } if (sysIncludePath == null) { this.sysIncludePath = new File[0]; } else { - this.sysIncludePath = (File[]) sysIncludePath.clone(); + this.sysIncludePath = sysIncludePath.clone(); } if (envIncludePath == null) { this.envIncludePath = new File[0]; } else { - this.envIncludePath = (File[]) envIncludePath.clone(); + this.envIncludePath = envIncludePath.clone(); } this.compiler = compiler; - this.params = (ProcessorParam[]) params.clone(); + this.params = params.clone(); this.rebuild = rebuild; this.identifier = identifier; this.includePathIdentifier = includePathIdentifier; - this.endArgs = (String[]) endArgs.clone(); + this.endArgs = endArgs.clone(); exceptFiles = null; isPrecompiledHeaderGeneration = false; } public CommandLineCompilerConfiguration( - CommandLineCompilerConfiguration base, String[] additionalArgs, - String[] exceptFiles, boolean isPrecompileHeaderGeneration) { + final CommandLineCompilerConfiguration base, final String[] additionalArgs, + final String[] exceptFiles, final boolean isPrecompileHeaderGeneration) { compiler = base.compiler; identifier = base.identifier; rebuild = base.rebuild; - includePath = (File[]) base.includePath.clone(); - sysIncludePath = (File[]) base.sysIncludePath.clone(); - endArgs = (String[]) base.endArgs.clone(); - envIncludePath = (File[]) base.envIncludePath.clone(); + includePath = base.includePath.clone(); + sysIncludePath = base.sysIncludePath.clone(); + endArgs = base.endArgs.clone(); + envIncludePath = base.envIncludePath.clone(); includePathIdentifier = base.includePathIdentifier; if (exceptFiles != null) { - this.exceptFiles = (String[]) exceptFiles.clone(); + this.exceptFiles = exceptFiles.clone(); } this.isPrecompiledHeaderGeneration = isPrecompileHeaderGeneration; args = new String[base.args.length + additionalArgs.length]; @@ -113,8 +113,9 @@ public final class CommandLineCompilerConfiguration args[index++] = additionalArgs[i]; } } - public int bid(String inputFile) { - int compilerBid = compiler.bid(inputFile); + @Override + public int bid(final String inputFile) { + final int compilerBid = compiler.bid(inputFile); if (compilerBid > 0 && exceptFiles != null) { for (int i = 0; i < exceptFiles.length; i++) { if (inputFile.equals(exceptFiles[i])) { @@ -124,8 +125,9 @@ public final class CommandLineCompilerConfiguration } return compilerBid; } - public void compile(CCTask task, File outputDir, String[] sourceFiles, - boolean relentless, ProgressMonitor monitor) throws BuildException { + @Override + public void compile(final CCTask task, final File outputDir, final String[] sourceFiles, + final boolean relentless, final ProgressMonitor monitor) throws BuildException { if (monitor != null) { monitor.start(this); } @@ -135,7 +137,7 @@ public final class CommandLineCompilerConfiguration if (monitor != null) { monitor.finish(this, true); } - } catch (BuildException ex) { + } catch (final BuildException ex) { if (monitor != null) { monitor.finish(this, false); } @@ -143,26 +145,27 @@ public final class CommandLineCompilerConfiguration } } /** - * + * * This method may be used to get two distinct compiler configurations, one * for compiling the specified file and producing a precompiled header * file, and a second for compiling other files using the precompiled * header file. - * + * * The last (preferrably only) include directive in the prototype file will * be used to mark the boundary between pre-compiled and normally compiled * headers. - * + * * @param prototype * A source file (for example, stdafx.cpp) that is used to build * the precompiled header file. @returns null if precompiled * headers are not supported or a two element array containing * the precompiled header generation configuration and the * consuming configuration - * + * */ + @Override public CompilerConfiguration[] createPrecompileConfigurations( - File prototype, String[] nonPrecompiledFiles) { + final File prototype, final String[] nonPrecompiledFiles) { if (compiler instanceof PrecompilingCompiler) { return ((PrecompilingCompiler) compiler) .createPrecompileConfigurations(this, prototype, @@ -175,47 +178,56 @@ public final class CommandLineCompilerConfiguration * canonical so that equivalent configurations will have equivalent string * representations */ + @Override public String getIdentifier() { return identifier; } + @Override public String getIncludePathIdentifier() { return includePathIdentifier; } - public String[] getOutputFileNames(String inputFile, VersionInfo versionInfo) { + @Override + public final String[] getOutputFileNames(final String inputFile, final VersionInfo versionInfo) { return compiler.getOutputFileNames(inputFile, versionInfo); } - public CompilerParam getParam(String name) { + @Override + public CompilerParam getParam(final String name) { for (int i = 0; i < params.length; i++) { if (name.equals(params[i].getName())) return (CompilerParam) params[i]; } return null; } + @Override public ProcessorParam[] getParams() { return params; } + @Override public boolean getRebuild() { return rebuild; } + @Override public boolean isPrecompileGeneration() { return isPrecompiledHeaderGeneration; } - public DependencyInfo parseIncludes(CCTask task, File baseDir, File source) { + @Override + public DependencyInfo parseIncludes(final CCTask task, final File baseDir, final File source) { return compiler.parseIncludes(task, source, includePath, sysIncludePath, envIncludePath, baseDir, getIncludePathIdentifier()); } + @Override public String toString() { return identifier; } public String[] getPreArguments() { - return (String[]) args.clone(); + return args.clone(); } public String[] getEndArguments() { - return (String[]) endArgs.clone(); + return endArgs.clone(); } public File[] getIncludePath() { - return (File[]) includePath.clone(); + return includePath.clone(); } public Compiler getCompiler() { return compiler; 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 321bd29..24aa0d4 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java @@ -105,6 +105,7 @@ public abstract class CommandLineLinker extends AbstractLinker protected abstract void addStack(int stack, Vector args); protected abstract void addEntry(String entry, Vector args); + @Override protected LinkerConfiguration createConfiguration( final CCTask task, final LinkType linkType, @@ -215,7 +216,8 @@ public abstract class CommandLineLinker extends AbstractLinker protected abstract String getCommandFileSwitch(String commandFile); - public String getIdentifier() { + @Override + public String getIdentifier() { if(identifier == null) { if (identifierArg == null) { identifier = getIdentifier(new String[] { command }, command); 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 f0aad67..bc66648 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineLinkerConfiguration.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineLinkerConfiguration.java @@ -1,5 +1,5 @@ /* - * + * * Copyright 2002-2004 The Ant-Contrib project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,35 +24,35 @@ import net.sf.antcontrib.cpptasks.VersionInfo; import org.apache.tools.ant.BuildException; /** * A configuration for a command line linker - * + * * @author Curt Arnold */ public final class CommandLineLinkerConfiguration implements LinkerConfiguration { private/* final */String[][] args; - private/* final */String identifier; + private final /* final */String identifier; private String[] libraryNames; - private/* final */CommandLineLinker linker; - private/* final */boolean map; - private/* final */ProcessorParam[] params; - private/* final */boolean rebuild; - private boolean debug; - private String startupObject; - public CommandLineLinkerConfiguration(CommandLineLinker linker, - String identifier, String[][] args, ProcessorParam[] params, - boolean rebuild, boolean map, boolean debug, String[] libraryNames, - String startupObject) { + private final /* final */CommandLineLinker linker; + private final /* final */boolean map; + private final /* final */ProcessorParam[] params; + private final /* final */boolean rebuild; + private final boolean debug; + private final String startupObject; + public CommandLineLinkerConfiguration(final CommandLineLinker linker, + final String identifier, final String[][] args, final ProcessorParam[] params, + final boolean rebuild, final boolean map, final boolean debug, final String[] libraryNames, + final String startupObject) { if (linker == null) { throw new NullPointerException("linker"); } if (args == null) { throw new NullPointerException("args"); } else { - this.args = (String[][]) args.clone(); + this.args = args.clone(); } this.linker = linker; - this.params = (ProcessorParam[]) params.clone(); + this.params = params.clone(); this.rebuild = rebuild; this.identifier = identifier; this.map = map; @@ -60,15 +60,16 @@ public final class CommandLineLinkerConfiguration if (libraryNames == null) { this.libraryNames = new String[0]; } else { - this.libraryNames = (String[]) libraryNames.clone(); + this.libraryNames = libraryNames.clone(); } this.startupObject = startupObject; } - public int bid(String filename) { + @Override + public int bid(final String filename) { return linker.bid(filename); } public String[] getEndArguments() { - String[] clone = (String[]) args[1].clone(); + final String[] clone = args[1].clone(); return clone; } /** @@ -76,17 +77,19 @@ public final class CommandLineLinkerConfiguration * canonical so that equivalent configurations will have equivalent string * representations */ + @Override public String getIdentifier() { return identifier; } public String[] getLibraryNames() { - String[] clone = (String[]) libraryNames.clone(); + final String[] clone = libraryNames.clone(); return clone; } public boolean getMap() { return map; } - public String[] getOutputFileNames(String inputFile, VersionInfo versionInfo) { + @Override + public final String[] getOutputFileNames(final String inputFile, final VersionInfo versionInfo) { return linker.getOutputFileNames(inputFile, versionInfo); } public LinkerParam getParam(String name) { @@ -96,32 +99,38 @@ public final class CommandLineLinkerConfiguration } return null; } + @Override public ProcessorParam[] getParams() { return params; } public String[] getPreArguments() { - String[] clone = (String[]) args[0].clone(); + final String[] clone = args[0].clone(); return clone; } + @Override public boolean getRebuild() { return rebuild; } public String getStartupObject() { return startupObject; } - public void link(CCTask task, TargetInfo linkTarget) throws BuildException { + @Override + public void link(final CCTask task, final TargetInfo linkTarget) throws BuildException { // // AllSourcePath's include any syslibsets // - String[] sourcePaths = linkTarget.getAllSourcePaths(); + final String[] sourcePaths = linkTarget.getAllSourcePaths(); linker.link(task, linkTarget.getOutput(), sourcePaths, this); } + @Override public String toString() { return identifier; } + @Override public Linker getLinker() { return linker; } + @Override public boolean isDebug() { return debug; } 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 ff7ac5d..114b8f1 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/compiler/LinkerConfiguration.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/compiler/LinkerConfiguration.java @@ -1,5 +1,5 @@ /* - * + * * Copyright 2002-2004 The Ant-Contrib project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +22,7 @@ import net.sf.antcontrib.cpptasks.TargetInfo; import org.apache.tools.ant.BuildException; /** * A configuration for a linker - * + * * @author Curt Arnold */ public interface LinkerConfiguration extends ProcessorConfiguration { 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 3b496b9..cfaa7f3 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/gcc/AbstractArLibrarian.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/gcc/AbstractArLibrarian.java @@ -1,5 +1,5 @@ /* - * + * * Copyright 2001-2004 The Ant-Contrib project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,48 +28,59 @@ import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum; import org.apache.tools.ant.BuildException; /** * Adapter for the "ar" tool - * + * * @author Adam Murdoch * @author Curt Arnold */ public abstract class AbstractArLibrarian extends CommandLineLinker { - private/* final */ + private final /* final */ String outputPrefix; - protected AbstractArLibrarian(String command, String identificationArg, - String[] inputExtensions, String[] ignoredExtensions, - String outputPrefix, String outputExtension, boolean isLibtool, - AbstractArLibrarian libtoolLibrarian) { + protected AbstractArLibrarian(final String command, final String identificationArg, + final String[] inputExtensions, final String[] ignoredExtensions, + final String outputPrefix, final String outputExtension, final boolean isLibtool, + final AbstractArLibrarian libtoolLibrarian) { super(command, identificationArg, inputExtensions, ignoredExtensions, outputExtension, false, isLibtool, libtoolLibrarian); this.outputPrefix = outputPrefix; } - public void addBase(long base, Vector args) { + @Override + public void addBase(final long base, final Vector args) { } - public void addFixed(Boolean fixed, Vector args) { + @Override + public void addFixed(final Boolean fixed, final Vector args) { } - public void addImpliedArgs(boolean debug, LinkType linkType, Vector args) { + @Override + public void addImpliedArgs(final boolean debug, final LinkType linkType, final Vector args) { } - public void addIncremental(boolean incremental, Vector args) { + @Override + public void addIncremental(final boolean incremental, final Vector args) { } - public void addMap(boolean map, Vector args) { + @Override + public void addMap(final boolean map, final Vector args) { } - public void addStack(int stack, Vector args) { + @Override + public void addStack(final int stack, final Vector args) { } /* (non-Javadoc) * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector) */ - protected void addEntry(String entry, Vector args) { + @Override + protected void addEntry(final String entry, final Vector args) { } - - public String getCommandFileSwitch(String commandFile) { + + @Override + public String getCommandFileSwitch(final String commandFile) { return null; } + @Override public File[] getLibraryPath() { return new File[0]; } - public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) { + @Override + public String[] getLibraryPatterns(final String[] libnames, final LibraryTypeEnum libType) { return new String[0]; } + @Override public int getMaximumCommandLength() { return Integer.MAX_VALUE; } @@ -82,14 +93,17 @@ public abstract class AbstractArLibrarian extends CommandLineLinker { } return baseNames; } - public String[] getOutputFileSwitch(String outputFile) { + @Override + public String[] getOutputFileSwitch(final String outputFile) { return GccProcessor.getOutputFileSwitch("rvs", outputFile); } + @Override public boolean isCaseSensitive() { return true; } - public void link(CCTask task, File outputFile, String[] sourceFiles, - CommandLineLinkerConfiguration config) throws BuildException { + @Override + public void link(final CCTask task, final File outputFile, final String[] sourceFiles, + final CommandLineLinkerConfiguration config) throws BuildException { // // if there is an existing library then // we must delete it before executing "ar" 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 2db05f5..f99ba97 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java @@ -46,14 +46,17 @@ public abstract class AbstractLdLinker extends CommandLineLinker { super(ld, isXCoderun); this.outputPrefix = ld.outputPrefix; } + @Override public void addBase(final long base, final Vector args) { if (base >= 0) { args.addElement("--image-base"); args.addElement(Long.toHexString(base)); } } + @Override public void addFixed(final Boolean fixed, final Vector args) { } + @Override protected void addImpliedArgs(final boolean debug, final LinkType linkType, final Vector args) { if (debug) { args.addElement("-g"); @@ -83,6 +86,7 @@ public abstract class AbstractLdLinker extends CommandLineLinker { } } } + @Override public void addIncremental(final boolean incremental, final Vector args) { if (incremental) { args.addElement("-i"); @@ -99,6 +103,7 @@ public abstract class AbstractLdLinker extends CommandLineLinker { } return offset + libnames.length; } + @Override public String[] addLibrarySets(final CCTask task, final LibrarySet[] libsets, final Vector preargs, final Vector midargs, final Vector endargs) { final Vector libnames = new Vector(); @@ -167,11 +172,13 @@ public abstract class AbstractLdLinker extends CommandLineLinker { } return rc; } + @Override public void addMap(final boolean map, final Vector args) { if (map) { args.addElement("-M"); } } + @Override public void addStack(final int stack, final Vector args) { if (stack > 0) { args.addElement("--stack"); @@ -181,6 +188,7 @@ public abstract class AbstractLdLinker extends CommandLineLinker { /* (non-Javadoc) * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector) */ + @Override protected void addEntry(final String entry, final Vector args) { if (entry != null) { args.addElement("-e"); @@ -188,6 +196,7 @@ public abstract class AbstractLdLinker extends CommandLineLinker { } } + @Override public String getCommandFileSwitch(final String commandFile) { throw new IllegalStateException("ld does not support command files"); } @@ -198,6 +207,7 @@ public abstract class AbstractLdLinker extends CommandLineLinker { protected File[] getEnvironmentIncludePath() { return CUtil.getPathFromEnvironment("LIB", ":"); } + @Override public String getLibraryKey(final File libfile) { final String libname = libfile.getName(); final int lastDot = libname.lastIndexOf('.'); @@ -210,9 +220,11 @@ public abstract class AbstractLdLinker extends CommandLineLinker { * Returns library path. * */ + @Override public File[] getLibraryPath() { return new File[0]; } + @Override public String[] getLibraryPatterns(final String[] libnames, final LibraryTypeEnum libType) { final StringBuffer buf = new StringBuffer(); int patternCount = libnames.length; @@ -245,6 +257,7 @@ public abstract class AbstractLdLinker extends CommandLineLinker { } return patterns; } + @Override public int getMaximumCommandLength() { return Integer.MAX_VALUE; } @@ -257,10 +270,12 @@ public abstract class AbstractLdLinker extends CommandLineLinker { } return baseNames; } + @Override public String[] getOutputFileSwitch(final String outputFile) { return GccProcessor.getOutputFileSwitch("-o", outputFile); } + @Override public boolean isCaseSensitive() { return true; } @@ -283,6 +298,7 @@ public abstract class AbstractLdLinker extends CommandLineLinker { * linker configuration * @return arguments for runTask */ + @Override public String[] prepareArguments(final CCTask task, final String outputDir, final String outputFile, final String[] sourceFiles, final CommandLineLinkerConfiguration config) { 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 a091665..b9aea47 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/os390/OS390Linker.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/os390/OS390Linker.java @@ -1,5 +1,5 @@ /* - * + * * Copyright 2002-2004 The Ant-Contrib project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -33,7 +33,7 @@ import net.sf.antcontrib.cpptasks.VersionInfo; import org.apache.tools.ant.BuildException; /** * Adapter for the IBM (R) OS/390 (tm) Linker - * + * * @author Hiram Chirino ([email protected]) */ public final class OS390Linker extends CommandLineLinker { @@ -46,9 +46,9 @@ public final class OS390Linker extends CommandLineLinker { public static OS390Linker getInstance() { return instance; } - private boolean isADatasetLinker; + private final boolean isADatasetLinker; File outputFile; - private String outputPrefix; + private final String outputPrefix; CCTask task; private OS390Linker() { super("cxx", "/bogus", new String[]{".o", ".a", ".lib", ".xds"}, @@ -56,30 +56,35 @@ public final class OS390Linker extends CommandLineLinker { this.outputPrefix = ""; this.isADatasetLinker = true; } - private OS390Linker(String outputPrefix, String outputSuffix) { + private OS390Linker(final String outputPrefix, final String outputSuffix) { super("cxx", "/bogus", new String[]{".o", ".a", ".lib", ".x"}, new String[]{".dll"}, outputSuffix, false, false, null); this.outputPrefix = outputPrefix; this.isADatasetLinker = false; } - protected void addBase(long base, Vector args) { + @Override + protected void addBase(final long base, final Vector args) { } - protected void addFixed(Boolean fixed, Vector args) { + @Override + protected void addFixed(final Boolean fixed, final Vector args) { } - protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args) { + @Override + protected void addImpliedArgs(final boolean debug, final LinkType linkType, final Vector args) { if (linkType.isSharedLibrary()) { args.addElement("-W"); args.addElement("l,DLL"); } } - protected void addIncremental(boolean incremental, Vector args) { + @Override + protected void addIncremental(final boolean incremental, final Vector args) { } /* * @see CommandLineLinker#addLibrarySets(LibrarySet[], Vector, Vector, * Vector) */ - protected String[] addLibrarySets(CCTask task, LibrarySet[] libsets, - Vector preargs, Vector midargs, Vector endargs) { + @Override + protected String[] addLibrarySets(final CCTask task, final LibrarySet[] libsets, + final Vector preargs, final Vector midargs, final Vector endargs) { // If yo want to link against a library sitting in a dataset and // not in the HFS, you can just use the //'dataset' notation // to specify it. e.g: @@ -90,13 +95,13 @@ public final class OS390Linker extends CommandLineLinker { // as part of the link command. if (libsets != null) { for (int i = 0; i < libsets.length; i++) { - String libs[] = libsets[i].getLibs(); + final String libs[] = libsets[i].getLibs(); for (int j = 0; j < libs.length; j++) { if (libs[j].startsWith("//")) { endargs.addElement("-l"); endargs.addElement(libs[j]); } else if (libsets[i].getDataset() != null) { - String ds = libsets[i].getDataset(); + final String ds = libsets[i].getDataset(); endargs.addElement("//'" + ds + "(" + libs[j] + ")'"); } } @@ -104,31 +109,37 @@ public final class OS390Linker extends CommandLineLinker { } return super.addLibrarySets(task, libsets, preargs, midargs, endargs); } - protected void addMap(boolean map, Vector args) { + @Override + protected void addMap(final boolean map, final Vector args) { } - protected void addStack(int stack, Vector args) { + @Override + protected void addStack(final int stack, final Vector args) { } - protected void addEntry(String entry, Vector args) { + @Override + protected void addEntry(final String entry, final Vector args) { } - - public String getCommandFileSwitch(String commandFile) { + + @Override + public String getCommandFileSwitch(final String commandFile) { return "@" + commandFile; } + @Override public File[] getLibraryPath() { return CUtil.getPathFromEnvironment("LIB", ";"); } - - public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) { - StringBuffer buf = new StringBuffer(); - String[] patterns = new String[libnames.length * 3]; + + @Override + public String[] getLibraryPatterns(final String[] libnames, final LibraryTypeEnum libType) { + final StringBuffer buf = new StringBuffer(); + final String[] patterns = new String[libnames.length * 3]; int offset = addLibraryPatterns(libnames, buf, "lib", ".a", patterns, 0); offset = addLibraryPatterns(libnames, buf, "", ".x", patterns, offset); offset = addLibraryPatterns(libnames, buf, "", ".o", patterns, offset); return patterns; } - - private static int addLibraryPatterns(String[] libnames, StringBuffer buf, - String prefix, String extension, String[] patterns, int offset) { + + private static int addLibraryPatterns(final String[] libnames, final StringBuffer buf, + final String prefix, final String extension, final String[] patterns, final int offset) { for (int i = 0; i < libnames.length; i++) { buf.setLength(0); buf.append(prefix); @@ -138,14 +149,16 @@ public final class OS390Linker extends CommandLineLinker { } return offset + libnames.length; } - - public Linker getLinker(LinkType linkType) { + + @Override + public Linker getLinker(final LinkType linkType) { if (this == datasetLinker) return datasetLinker; if (linkType.isSharedLibrary()) return dllLinker; return instance; } + @Override public int getMaximumCommandLength() { return Integer.MAX_VALUE; } @@ -158,16 +171,19 @@ public final class OS390Linker extends CommandLineLinker { } return baseNames; } - protected String[] getOutputFileSwitch(CCTask task, String outputFile) { + @Override + protected String[] getOutputFileSwitch(final CCTask task, String outputFile) { if (isADatasetLinker && task.getDataset() != null) { - String ds = task.getDataset(); + final String ds = task.getDataset(); outputFile = "//'" + ds + "(" + outputFile + ")'"; } return getOutputFileSwitch(outputFile); } - public String[] getOutputFileSwitch(String outputFile) { + @Override + public String[] getOutputFileSwitch(final String outputFile) { return new String[]{"-o", outputFile}; } + @Override public boolean isCaseSensitive() { return OS390Processor.isCaseSensitive(); } @@ -175,14 +191,15 @@ public final class OS390Linker extends CommandLineLinker { * @see CommandLineLinker#link(Task, File, String[], * CommandLineLinkerConfiguration) */ - public void link(CCTask task, File outputFile, String[] sourceFiles, - CommandLineLinkerConfiguration config) throws BuildException { + @Override + public void link(final CCTask task, File outputFile, final String[] sourceFiles, + final CommandLineLinkerConfiguration config) throws BuildException { this.task = task; this.outputFile = outputFile; if (isADatasetLinker) { - int p = outputFile.getName().indexOf("."); + final int p = outputFile.getName().indexOf("."); if (p >= 0) { - String newname = outputFile.getName().substring(0, p); + final String newname = outputFile.getName().substring(0, p); outputFile = new File(outputFile.getParent(), newname); } } @@ -191,15 +208,16 @@ public final class OS390Linker extends CommandLineLinker { /* * @see CommandLineLinker#runCommand(Task, File, String[]) */ - protected int runCommand(CCTask task, File workingDir, String[] cmdline) + @Override + protected int runCommand(final CCTask task, final File workingDir, final String[] cmdline) throws BuildException { - int rc = super.runCommand(task, workingDir, cmdline); + final int rc = super.runCommand(task, workingDir, cmdline); // create the .xds file if everything was ok. if (rc == 0) { try { outputFile.delete(); new FileOutputStream(outputFile).close(); - } catch (IOException e) { + } catch (final IOException e) { throw new BuildException(e.getMessage()); } } 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 f271e21..e942628 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/os400/IccLinker.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/os400/IccLinker.java @@ -1,5 +1,5 @@ /* - * + * * Copyright 2002-2004 The Ant-Contrib project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -31,7 +31,7 @@ import net.sf.antcontrib.cpptasks.VersionInfo; import org.apache.tools.ant.BuildException; /** * Adapter for the IBM (R) OS/390 (tm) Linker - * + * * @author Hiram Chirino ([email protected]) */ public final class IccLinker extends CommandLineLinker { @@ -44,9 +44,9 @@ public final class IccLinker extends CommandLineLinker { public static IccLinker getInstance() { return instance; } - private boolean isADatasetLinker; + private final boolean isADatasetLinker; File outputFile; - private String outputPrefix; + private final String outputPrefix; CCTask task; private IccLinker() { super("icc", "/bogus", new String[]{".o", ".a", ".lib", ".xds"}, @@ -54,30 +54,35 @@ public final class IccLinker extends CommandLineLinker { this.outputPrefix = ""; this.isADatasetLinker = true; } - private IccLinker(String outputPrefix, String outputSuffix) { + private IccLinker(final String outputPrefix, final String outputSuffix) { super("icc", "/bogus", new String[]{".o", ".a", ".lib", ".x"}, new String[]{".dll"}, outputSuffix, false, false, null); this.outputPrefix = outputPrefix; this.isADatasetLinker = false; } - protected void addBase(long base, Vector args) { + @Override + protected void addBase(final long base, final Vector args) { } - protected void addFixed(Boolean fixed, Vector args) { + @Override + protected void addFixed(final Boolean fixed, final Vector args) { } - protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args) { + @Override + protected void addImpliedArgs(final boolean debug, final LinkType linkType, final Vector args) { if (linkType.isSharedLibrary()) { args.addElement("-W"); args.addElement("l,DLL"); } } - protected void addIncremental(boolean incremental, Vector args) { + @Override + protected void addIncremental(final boolean incremental, final Vector args) { } /* * @see CommandLineLinker#addLibrarySets(LibrarySet[], Vector, Vector, * Vector) */ - protected String[] addLibrarySets(CCTask task, LibrarySet[] libsets, - Vector preargs, Vector midargs, Vector endargs) { + @Override + protected String[] addLibrarySets(final CCTask task, final LibrarySet[] libsets, + final Vector preargs, final Vector midargs, final Vector endargs) { // If yo want to link against a library sitting in a dataset and // not in the HFS, you can just use the //'dataset' notation // to specify it. e.g: @@ -88,13 +93,13 @@ public final class IccLinker extends CommandLineLinker { // as part of the link command. if (libsets != null) { for (int i = 0; i < libsets.length; i++) { - String libs[] = libsets[i].getLibs(); + final String libs[] = libsets[i].getLibs(); for (int j = 0; j < libs.length; j++) { if (libs[j].startsWith("//")) { endargs.addElement("-l"); endargs.addElement(libs[j]); } else if (libsets[i].getDataset() != null) { - String ds = libsets[i].getDataset(); + final String ds = libsets[i].getDataset(); endargs.addElement("//'" + ds + "(" + libs[j] + ")'"); } } @@ -102,33 +107,39 @@ public final class IccLinker extends CommandLineLinker { } return super.addLibrarySets(task, libsets, preargs, midargs, endargs); } - protected void addMap(boolean map, Vector args) { + @Override + protected void addMap(final boolean map, final Vector args) { } - protected void addStack(int stack, Vector args) { + @Override + protected void addStack(final int stack, final Vector args) { } /* (non-Javadoc) * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector) */ - protected void addEntry(String entry, Vector args) { + @Override + protected void addEntry(final String entry, final Vector args) { } - - public String getCommandFileSwitch(String commandFile) { + + @Override + public String getCommandFileSwitch(final String commandFile) { return "@" + commandFile; } + @Override public File[] getLibraryPath() { return CUtil.getPathFromEnvironment("LIB", ";"); } - public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) { - StringBuffer buf = new StringBuffer(); - String[] patterns = new String[libnames.length * 3]; + @Override + public String[] getLibraryPatterns(final String[] libnames, final LibraryTypeEnum libType) { + final StringBuffer buf = new StringBuffer(); + final String[] patterns = new String[libnames.length * 3]; int offset = addLibraryPatterns(libnames, buf, "lib", ".a", patterns, 0); offset = addLibraryPatterns(libnames, buf, "", ".x", patterns, offset); offset = addLibraryPatterns(libnames, buf, "", ".o", patterns, offset); return patterns; } - - private static int addLibraryPatterns(String[] libnames, StringBuffer buf, - String prefix, String extension, String[] patterns, int offset) { + + private static int addLibraryPatterns(final String[] libnames, final StringBuffer buf, + final String prefix, final String extension, final String[] patterns, final int offset) { for (int i = 0; i < libnames.length; i++) { buf.setLength(0); buf.append(prefix); @@ -138,28 +149,33 @@ public final class IccLinker extends CommandLineLinker { } return offset + libnames.length; } - - - public Linker getLinker(LinkType linkType) { + + + @Override + public Linker getLinker(final LinkType linkType) { if (this == datasetLinker) return datasetLinker; if (linkType.isSharedLibrary()) return dllLinker; return instance; } + @Override public int getMaximumCommandLength() { return Integer.MAX_VALUE; } - protected String[] getOutputFileSwitch(CCTask task, String outputFile) { + @Override + protected String[] getOutputFileSwitch(final CCTask task, String outputFile) { if (isADatasetLinker && task.getDataset() != null) { - String ds = task.getDataset(); + final String ds = task.getDataset(); outputFile = "//'" + ds + "(" + outputFile + ")'"; } return getOutputFileSwitch(outputFile); } - public String[] getOutputFileSwitch(String outputFile) { + @Override + public String[] getOutputFileSwitch(final String outputFile) { return new String[]{"-o", outputFile}; } + @Override public boolean isCaseSensitive() { return IccProcessor.isCaseSensitive(); } @@ -167,14 +183,15 @@ public final class IccLinker extends CommandLineLinker { * @see CommandLineLinker#link(Task, File, String[], * CommandLineLinkerConfiguration) */ - public void link(CCTask task, File outputFile, String[] sourceFiles, - CommandLineLinkerConfiguration config) throws BuildException { + @Override + public void link(final CCTask task, File outputFile, final String[] sourceFiles, + final CommandLineLinkerConfiguration config) throws BuildException { this.task = task; this.outputFile = outputFile; if (isADatasetLinker) { - int p = outputFile.getName().indexOf("."); + final int p = outputFile.getName().indexOf("."); if (p >= 0) { - String newname = outputFile.getName().substring(0, p); + final String newname = outputFile.getName().substring(0, p); outputFile = new File(outputFile.getParent(), newname); } } @@ -183,15 +200,16 @@ public final class IccLinker extends CommandLineLinker { /* * @see CommandLineLinker#runCommand(Task, File, String[]) */ - protected int runCommand(CCTask task, File workingDir, String[] cmdline) + @Override + protected int runCommand(final CCTask task, final File workingDir, final String[] cmdline) throws BuildException { - int rc = super.runCommand(task, workingDir, cmdline); + final int rc = super.runCommand(task, workingDir, cmdline); // create the .xds file if everything was ok. if (rc == 0) { try { outputFile.delete(); new FileOutputStream(outputFile).close(); - } catch (IOException e) { + } catch (final IOException e) { throw new BuildException(e.getMessage()); } } 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 58c5396..3adb9e0 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/sun/C89Linker.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/sun/C89Linker.java @@ -1,5 +1,5 @@ /* - * + * * Copyright 2002-2004 The Ant-Contrib project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,7 +29,7 @@ import net.sf.antcontrib.cpptasks.VersionInfo; /** * Adapter for the Sun C89 Linker - * + * * @author Hiram Chirino ([email protected]) */ public final class C89Linker extends CommandLineLinker { @@ -38,31 +38,36 @@ public final class C89Linker extends CommandLineLinker { public static C89Linker getInstance() { return instance; } - private String outputPrefix; - private C89Linker(String outputPrefix, String outputSuffix) { + private final String outputPrefix; + private C89Linker(final String outputPrefix, final String outputSuffix) { super("ld", "/bogus", new String[]{".o", ".a", ".lib", ".x"}, new String[]{}, outputSuffix, false, false, null); this.outputPrefix = outputPrefix; } - protected void addBase(long base, Vector args) { + @Override + protected void addBase(final long base, final Vector args) { } - protected void addFixed(Boolean fixed, Vector args) { + @Override + protected void addFixed(final Boolean fixed, final Vector args) { } - protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args) { + @Override + protected void addImpliedArgs(final boolean debug, final LinkType linkType, final Vector args) { if (linkType.isSharedLibrary()) { args.addElement("-G"); } } - protected void addIncremental(boolean incremental, Vector args) { + @Override + protected void addIncremental(final boolean incremental, final Vector args) { } - public String[] addLibrarySets(CCTask task, LibrarySet[] libsets, - Vector preargs, Vector midargs, Vector endargs) { + @Override + public String[] addLibrarySets(final CCTask task, final LibrarySet[] libsets, + final Vector preargs, final Vector midargs, final Vector endargs) { super.addLibrarySets(task, libsets, preargs, midargs, endargs); - StringBuffer buf = new StringBuffer("-l"); + final StringBuffer buf = new StringBuffer("-l"); for (int i = 0; i < libsets.length; i++) { - LibrarySet set = libsets[i]; - File libdir = set.getDir(null); - String[] libs = set.getLibs(); + final LibrarySet set = libsets[i]; + final File libdir = set.getDir(null); + final String[] libs = set.getLibs(); if (libdir != null) { endargs.addElement("-L"); endargs.addElement(libdir.getAbsolutePath()); @@ -82,26 +87,33 @@ public final class C89Linker extends CommandLineLinker { } return null; } - protected void addMap(boolean map, Vector args) { + @Override + protected void addMap(final boolean map, final Vector args) { } - protected void addStack(int stack, Vector args) { + @Override + protected void addStack(final int stack, final Vector args) { } /* (non-Javadoc) * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector) */ - protected void addEntry(String entry, Vector args) { + @Override + protected void addEntry(final String entry, final Vector args) { } - - public String getCommandFileSwitch(String commandFile) { + + @Override + public String getCommandFileSwitch(final String commandFile) { return "@" + commandFile; } + @Override public File[] getLibraryPath() { return CUtil.getPathFromEnvironment("LIB", ";"); } - public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) { + @Override + public String[] getLibraryPatterns(final String[] libnames, final LibraryTypeEnum libType) { return C89Processor.getLibraryPatterns(libnames, libType); } - public Linker getLinker(LinkType linkType) { + @Override + public Linker getLinker(final LinkType linkType) { if (linkType.isSharedLibrary()) { return dllLinker; } @@ -111,6 +123,7 @@ public final class C89Linker extends CommandLineLinker { */ return instance; } + @Override public int getMaximumCommandLength() { return Integer.MAX_VALUE; } @@ -123,9 +136,11 @@ public final class C89Linker extends CommandLineLinker { } return baseNames; } - public String[] getOutputFileSwitch(String outputFile) { + @Override + public String[] getOutputFileSwitch(final String outputFile) { return new String[]{"-o", outputFile}; } + @Override public boolean isCaseSensitive() { return C89Processor.isCaseSensitive(); } |