summaryrefslogtreecommitdiff
path: root/src/main/java/net/sf/antcontrib/cpptasks/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/sf/antcontrib/cpptasks/gcc')
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java28
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java1
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCompatibleCCompiler.java2
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/gcc/GccProcessor.java2
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/gcc/GppLinker.java456
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/gcc/WindresResourceCompiler.java121
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/gcc/cross/GccProcessor.java2
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccProcessor.java2
8 files changed, 369 insertions, 245 deletions
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 32e6e7e..f1eb2d7 100644
--- a/src/main/java/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java
+++ b/src/main/java/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java
@@ -108,12 +108,18 @@ public abstract class AbstractLdLinker extends CommandLineLinker {
File libdir = set.getDir(null);
String[] libs = set.getLibs();
if (libdir != null) {
+ String relPath = libdir.getAbsolutePath();
+ File outputFile = task.getOutfile();
+ if (outputFile != null && outputFile.getParentFile() != null) {
+ relPath = CUtil.getRelativePath(
+ outputFile.getParentFile().getAbsolutePath(), libdir);
+ }
if (set.getType() != null &&
"framework".equals(set.getType().getValue()) &&
isDarwin()) {
- endargs.addElement("-F" + libdir.getAbsolutePath());
+ endargs.addElement("-F" + relPath);
} else {
- endargs.addElement("-L" + libdir.getAbsolutePath());
+ endargs.addElement("-L" + relPath);
}
}
//
@@ -123,7 +129,7 @@ public abstract class AbstractLdLinker extends CommandLineLinker {
if (set.getType() != null && "static".equals(set.getType().getValue())) {
// BEGINFREEHEP not on MacOS X
if (!isDarwin()) {
- endargs.addElement("-Bstatic");
+ endargs.addElement(getStaticLibFlag());
previousLibraryType = set.getType();
}
//ENDFREEHEP
@@ -132,7 +138,7 @@ public abstract class AbstractLdLinker extends CommandLineLinker {
if (set.getType() == null ||
!"framework".equals(set.getType().getValue()) &&
!isDarwin()) {
- endargs.addElement("-Bdynamic");
+ endargs.addElement(getDynamicLibFlag());
previousLibraryType = set.getType();
}
}
@@ -163,7 +169,7 @@ public abstract class AbstractLdLinker extends CommandLineLinker {
// BEGINFREEHEP if last was -Bstatic reset it to -Bdynamic so that libc and libm can be found as shareables
if ((previousLibraryType != null) && previousLibraryType.getValue().equals("static") && !isDarwin()) {
- endargs.addElement("-Bdynamic");
+ endargs.addElement(getDynamicLibFlag());
}
// ENDFREEHEP
@@ -286,8 +292,8 @@ public abstract class AbstractLdLinker extends CommandLineLinker {
* linker output file
* @param sourceFiles
* linker input files (.obj, .o, .res)
- * @param args
- * linker arguments
+ * @param config
+ * linker configuration
* @return arguments for runTask
*/
public String[] prepareArguments(CCTask task, String outputDir,
@@ -342,4 +348,12 @@ public abstract class AbstractLdLinker extends CommandLineLinker {
return super.prepareArguments(task, outputDir, outputFile,
finalSources, config);
}
+
+ protected String getDynamicLibFlag() {
+ return "-Bdynamic";
+ }
+
+ protected String getStaticLibFlag() {
+ return "-Bstatic";
+ }
}
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java b/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java
index 1abdbec..f9e4c0b 100644
--- a/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java
+++ b/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java
@@ -256,7 +256,6 @@ public final class GccCCompiler extends GccCompatibleCCompiler {
return GccLinker.getInstance().getLinker(linkType);
}
public int getMaximumCommandLength() {
-// FREEHEP
return isWindows() ? 20000 : Integer.MAX_VALUE;
}
}
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCompatibleCCompiler.java b/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCompatibleCCompiler.java
index fa134f0..fc7bbfc 100644
--- a/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCompatibleCCompiler.java
+++ b/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCompatibleCCompiler.java
@@ -98,7 +98,7 @@ public abstract class GccCompatibleCCompiler extends CommandLineCCompiler {
args.addElement("-mwindows");
}
}
-// BEGINFREEHEP
+// BEGINFREEHEP, tests have been modified
if (!exceptions) {
args.addElement("-fno-exceptions");
}
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccProcessor.java b/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccProcessor.java
index 058ef12..988848d 100644
--- a/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccProcessor.java
+++ b/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccProcessor.java
@@ -117,7 +117,7 @@ public class GccProcessor {
* -dumpversion. Attempts to use gcc -dumpspecs to provide this information
* resulted in stalling on the Execute.run
*
- * @returns contents of the specs file
+ * @return contents of the specs file
*/
public static String[] getSpecs() {
if (specs == null) {
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/gcc/GppLinker.java b/src/main/java/net/sf/antcontrib/cpptasks/gcc/GppLinker.java
index 097f96b..043720d 100644
--- a/src/main/java/net/sf/antcontrib/cpptasks/gcc/GppLinker.java
+++ b/src/main/java/net/sf/antcontrib/cpptasks/gcc/GppLinker.java
@@ -15,7 +15,6 @@
* limitations under the License.
*/
package net.sf.antcontrib.cpptasks.gcc;
-
import java.io.File;
import java.util.Vector;
@@ -25,245 +24,236 @@ import net.sf.antcontrib.cpptasks.compiler.CaptureStreamHandler;
import net.sf.antcontrib.cpptasks.compiler.LinkType;
import net.sf.antcontrib.cpptasks.compiler.Linker;
import net.sf.antcontrib.cpptasks.types.LibrarySet;
-
/**
* Adapter for the g++ variant of the GCC linker
*
* @author Stephen M. Webb <stephen.webb@bregmasoft.com>
*/
public class GppLinker extends AbstractLdLinker {
- protected static final String[] discardFiles = new String[0];
- protected static final String[] objFiles = new String[] { ".o", ".a",
- ".lib", ".dll", ".so", ".sl" };
- // FREEHEP refactored dllLinker into soLinker
- private static final GppLinker soLinker = new GppLinker("gcc", objFiles,
- discardFiles, "lib", ".so", false, new GppLinker("gcc", objFiles,
- discardFiles, "lib", ".so", true, null));
- private final static String libPrefix = "libraries: =";
- protected static final String[] libtoolObjFiles = new String[] { ".fo",
- ".a", ".lib", ".dll", ".so", ".sl" };
- private static String[] linkerOptions = new String[] { "-bundle", "-dylib",
- "-dynamic", "-dynamiclib", "-nostartfiles", "-nostdlib",
- "-prebind", "-s", "-static", "-shared", "-symbolic", "-Xlinker",
- // FREEHEP
- "-static-libgcc", "-shared-libgcc" };
- private static final GppLinker instance = new GppLinker("gcc", objFiles,
- discardFiles, "", "", false, null);
- private static final GppLinker machDllLinker = new GppLinker("gcc",
- objFiles, discardFiles, "lib", ".dylib", false, null);
- private static final GppLinker machPluginLinker = new GppLinker("gcc",
- objFiles, discardFiles, "lib", ".bundle", false, null);
- // FREEHEP
- private static final GppLinker machJNILinker = new GppLinker("gcc",
- objFiles, discardFiles, "lib", ".jnilib", false, null);
- // FREEHEP added dllLinker for windows
- private static final GppLinker dllLinker = new GppLinker("gcc", objFiles,
- discardFiles, "", ".dll", false, null);
-
- public static GppLinker getInstance() {
- return instance;
- }
-
- private File[] libDirs;
- private String runtimeLibrary;
- // FREEEHEP
- private String gccLibrary, gfortranLibrary;
-
- protected GppLinker(String command, String[] extensions,
- String[] ignoredExtensions, String outputPrefix,
- String outputSuffix, boolean isLibtool, GppLinker libtoolLinker) {
- super(command, "-dumpversion", extensions, ignoredExtensions,
- outputPrefix, outputSuffix, isLibtool, libtoolLinker);
- }
-
- protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args) {
- super.addImpliedArgs(debug, linkType, args);
- if (getIdentifier().indexOf("mingw") >= 0) {
- if (linkType.isSubsystemConsole()) {
- args.addElement("-mconsole");
- }
- if (linkType.isSubsystemGUI()) {
- args.addElement("-mwindows");
- }
- }
-
- // BEGINFREEHEP link or not with libstdc++
- // for MacOS X see:
- // http://developer.apple.com/documentation/DeveloperTools/Conceptual/CppRuntimeEnv/Articles/LibCPPDeployment.html
- gfortranLibrary = null;
- if (linkType.linkFortran()) {
- if (linkType.isStaticRuntime()) {
- String[] cmdin = new String[] { "gfortran",
- "-print-file-name=libgfortran.a" };
- String[] cmdout = CaptureStreamHandler.run(cmdin);
- if ((cmdout.length > 0) && (cmdout[0].indexOf('/') >= 0)) {
- gfortranLibrary = cmdout[0];
- }
- } else {
- gfortranLibrary = "-lgfortran";
- }
- }
-
- runtimeLibrary = null;
- if (linkType.linkCPP()) {
- if (linkType.isStaticRuntime()) {
- if (isDarwin()) {
- runtimeLibrary = "-lstdc++-static";
- } else {
- String[] cmdin = new String[] { "g++",
- "-print-file-name=libstdc++.a" };
- String[] cmdout = CaptureStreamHandler.run(cmdin);
- if ((cmdout.length > 0) && (cmdout[0].indexOf('/') >= 0)) {
- runtimeLibrary = cmdout[0];
- }
- }
- } else {
- runtimeLibrary = "-lstdc++";
- }
- }
-
- gccLibrary = null;
- if (linkType.isStaticRuntime()) {
- gccLibrary = "-static-libgcc";
- } else {
- if (linkType.linkCPP()) {
- // NOTE: added -fexceptions here for MacOS X
- gccLibrary = "-fexceptions";
- } else {
- gccLibrary = "-shared-libgcc";
- }
- }
- // ENDFREEHEP
- }
-
- public String[] addLibrarySets(CCTask task, LibrarySet[] libsets,
- Vector preargs, Vector midargs, Vector endargs) {
- String[] rs = super.addLibrarySets(task, libsets, preargs, midargs,
- endargs);
- // BEGINFREEHEP
- if (gfortranLibrary != null) {
- endargs.addElement(gfortranLibrary);
- }
- if (gccLibrary != null) {
- endargs.addElement(gccLibrary);
- }
- // ENDFREEHEP
- if (runtimeLibrary != null) {
- endargs.addElement(runtimeLibrary);
- }
- return rs;
- }
+ protected static final String[] discardFiles = new String[0];
+ protected static final String[] objFiles = new String[]{".o", ".a", ".lib",
+ ".dll", ".so", ".sl"};
+ // FREEHEP refactored dllLinker into soLinker
+ private static final GppLinker soLinker = new GppLinker("gcc", objFiles,
+ discardFiles, "lib", ".so", false, new GppLinker("gcc", objFiles,
+ discardFiles, "lib", ".so", true, null));
+ private final static String libPrefix = "libraries: =";
+ protected static final String[] libtoolObjFiles = new String[]{".fo", ".a",
+ ".lib", ".dll", ".so", ".sl"};
+ private static String[] linkerOptions = new String[]{"-bundle", "-dylib",
+ "-dynamic", "-dynamiclib", "-nostartfiles", "-nostdlib",
+ "-prebind", "-s", "-static", "-shared", "-symbolic", "-Xlinker",
+ // FREEHEP
+ "-static-libgcc", "-shared-libgcc" };
+ private static final GppLinker instance = new GppLinker("gcc", objFiles,
+ discardFiles, "", "", false, null);
+ private static final GppLinker machDllLinker = new GppLinker("gcc",
+ objFiles, discardFiles, "lib", ".dylib", false, null);
+ private static final GppLinker machPluginLinker = new GppLinker("gcc",
+ objFiles, discardFiles, "lib", ".bundle", false, null);
+ // FREEHEP
+ private static final GppLinker machJNILinker = new GppLinker("gcc",
+ objFiles, discardFiles, "lib", ".jnilib", false, null);
+ // FREEHEP added dllLinker for windows
+ private static final GppLinker dllLinker = new GppLinker("gcc", objFiles,
+ discardFiles, "", ".dll", false, null);
+ public static GppLinker getInstance() {
+ return instance;
+ }
+ private File[] libDirs;
+ private String runtimeLibrary;
+ // FREEEHEP
+ private String gccLibrary, gfortranLibrary;
- /**
- * Allows drived linker to decorate linker option. Override by GppLinker to
- * prepend a "-Wl," to pass option to through gcc to linker.
- *
- * @param buf
- * buffer that may be used and abused in the decoration process,
- * must not be null.
- * @param arg
- * linker argument
- */
- public String decorateLinkerOption(StringBuffer buf, String arg) {
- String decoratedArg = arg;
- if (arg.length() > 1 && arg.charAt(0) == '-') {
- switch (arg.charAt(1)) {
- //
- // passed automatically by GCC
- //
- case 'g':
- case 'f':
- case 'F':
- /* Darwin */
- case 'm':
- case 'O':
- case 'W':
- case 'l':
- case 'L':
- case 'u':
- break;
- default:
- boolean known = false;
- for (int i = 0; i < linkerOptions.length; i++) {
- if (linkerOptions[i].equals(arg)) {
- known = true;
- break;
- }
- }
- if (!known) {
- buf.setLength(0);
- buf.append("-Wl,");
- buf.append(arg);
- decoratedArg = buf.toString();
- }
- break;
- }
- }
- return decoratedArg;
- }
+ protected GppLinker(String command, String[] extensions,
+ String[] ignoredExtensions, String outputPrefix,
+ String outputSuffix, boolean isLibtool, GppLinker libtoolLinker) {
+ super(command, "-dumpversion", extensions, ignoredExtensions,
+ outputPrefix, outputSuffix, isLibtool, libtoolLinker);
+ }
+ protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args) {
+ super.addImpliedArgs(debug, linkType, args);
+ if (getIdentifier().indexOf("mingw") >= 0) {
+ if (linkType.isSubsystemConsole()) {
+ args.addElement("-mconsole");
+ }
+ if (linkType.isSubsystemGUI()) {
+ args.addElement("-mwindows");
+ }
+ }
+ // BEGINFREEHEP link or not with libstdc++
+ // for MacOS X see:
+ // http://developer.apple.com/documentation/DeveloperTools/Conceptual/CppRuntimeEnv/Articles/LibCPPDeployment.html
+ gfortranLibrary = null;
+ if (linkType.linkFortran()) {
+ if (linkType.isStaticRuntime()) {
+ String[] cmdin = new String[] { "gfortran",
+ "-print-file-name=libgfortran.a" };
+ String[] cmdout = CaptureStreamHandler.run(cmdin);
+ if ((cmdout.length > 0) && (cmdout[0].indexOf('/') >= 0)) {
+ gfortranLibrary = cmdout[0];
+ }
+ } else {
+ gfortranLibrary = "-lgfortran";
+ }
+ }
- /**
- * Returns library path.
- *
- */
- public File[] getLibraryPath() {
- if (libDirs == null) {
- Vector dirs = new Vector();
- // Ask GCC where it will look for its libraries.
- String[] args = new String[] { "g++", "-print-search-dirs" };
- String[] cmdout = CaptureStreamHandler.run(args);
- for (int i = 0; i < cmdout.length; ++i) {
- int prefixIndex = cmdout[i].indexOf(libPrefix);
- if (prefixIndex >= 0) {
- // Special case DOS-type GCCs like MinGW or Cygwin
- int s = prefixIndex + libPrefix.length();
- int t = cmdout[i].indexOf(';', s);
- while (t > 0) {
- dirs.addElement(cmdout[i].substring(s, t));
- s = t + 1;
- t = cmdout[i].indexOf(';', s);
- }
- dirs.addElement(cmdout[i].substring(s));
- ++i;
- for (; i < cmdout.length; ++i) {
- dirs.addElement(cmdout[i]);
- }
- }
- }
- // Eliminate all but actual directories.
- String[] libpath = new String[dirs.size()];
- dirs.copyInto(libpath);
- int count = CUtil.checkDirectoryArray(libpath);
- // Build return array.
- libDirs = new File[count];
- int index = 0;
- for (int i = 0; i < libpath.length; ++i) {
- if (libpath[i] != null) {
- libDirs[index++] = new File(libpath[i]);
- }
- }
- }
- return libDirs;
- }
+ runtimeLibrary = null;
+ if (linkType.linkCPP()) {
+ if (linkType.isStaticRuntime()) {
+ if (isDarwin()) {
+ runtimeLibrary = "-lstdc++-static";
+ } else {
+ String[] cmdin = new String[] { "g++",
+ "-print-file-name=libstdc++.a" };
+ String[] cmdout = CaptureStreamHandler.run(cmdin);
+ if ((cmdout.length > 0) && (cmdout[0].indexOf('/') >= 0)) {
+ runtimeLibrary = cmdout[0];
+ }
+ }
+ } else {
+ runtimeLibrary = "-lstdc++";
+ }
+ }
- public Linker getLinker(LinkType type) {
- if (type.isStaticLibrary()) {
- return GccLibrarian.getInstance();
- }
- // BEGINFREEHEP
- if (type.isJNIModule()) {
- return isDarwin() ? machJNILinker : isWindows() ? dllLinker
- : soLinker;
- }
- if (type.isPluginModule()) {
- return isDarwin() ? machPluginLinker : isWindows() ? dllLinker
- : soLinker;
- }
- if (type.isSharedLibrary()) {
- return isDarwin() ? machDllLinker : isWindows() ? dllLinker
- : soLinker;
- }
- // ENDFREEHEP
- return instance;
- }
+ gccLibrary = null;
+ if (linkType.isStaticRuntime()) {
+ gccLibrary = "-static-libgcc";
+ } else {
+ if (linkType.linkCPP()) {
+ // NOTE: added -fexceptions here for MacOS X
+ gccLibrary = "-fexceptions";
+ } else {
+ gccLibrary = "-shared-libgcc";
+ }
+ }
+ // ENDFREEHEP
+ }
+ public String[] addLibrarySets(CCTask task, LibrarySet[] libsets,
+ Vector preargs, Vector midargs, Vector endargs) {
+ String[] rs = super.addLibrarySets(task, libsets, preargs, midargs,
+ endargs);
+ // BEGINFREEHEP
+ if (gfortranLibrary != null) {
+ endargs.addElement(gfortranLibrary);
+ }
+ if (gccLibrary != null) {
+ endargs.addElement(gccLibrary);
+ }
+ // ENDFREEHEP
+ if (runtimeLibrary != null) {
+ endargs.addElement(runtimeLibrary);
+ }
+ return rs;
+ }
+ /**
+ * Allows drived linker to decorate linker option. Override by GppLinker to
+ * prepend a "-Wl," to pass option to through gcc to linker.
+ *
+ * @param buf
+ * buffer that may be used and abused in the decoration process,
+ * must not be null.
+ * @param arg
+ * linker argument
+ */
+ public String decorateLinkerOption(StringBuffer buf, String arg) {
+ String decoratedArg = arg;
+ if (arg.length() > 1 && arg.charAt(0) == '-') {
+ switch (arg.charAt(1)) {
+ //
+ // passed automatically by GCC
+ //
+ case 'g' :
+ case 'f' :
+ case 'F' :
+ /* Darwin */
+ case 'm' :
+ case 'O' :
+ case 'W' :
+ case 'l' :
+ case 'L' :
+ case 'u' :
+ break;
+ default :
+ boolean known = false;
+ for (int i = 0; i < linkerOptions.length; i++) {
+ if (linkerOptions[i].equals(arg)) {
+ known = true;
+ break;
+ }
+ }
+ if (!known) {
+ buf.setLength(0);
+ buf.append("-Wl,");
+ buf.append(arg);
+ decoratedArg = buf.toString();
+ }
+ break;
+ }
+ }
+ return decoratedArg;
+ }
+ /**
+ * Returns library path.
+ *
+ */
+ public File[] getLibraryPath() {
+ if (libDirs == null) {
+ Vector dirs = new Vector();
+ // Ask GCC where it will look for its libraries.
+ String[] args = new String[]{"g++", "-print-search-dirs"};
+ String[] cmdout = CaptureStreamHandler.run(args);
+ for (int i = 0; i < cmdout.length; ++i) {
+ int prefixIndex = cmdout[i].indexOf(libPrefix);
+ if (prefixIndex >= 0) {
+ // Special case DOS-type GCCs like MinGW or Cygwin
+ int s = prefixIndex + libPrefix.length();
+ int t = cmdout[i].indexOf(';', s);
+ while (t > 0) {
+ dirs.addElement(cmdout[i].substring(s, t));
+ s = t + 1;
+ t = cmdout[i].indexOf(';', s);
+ }
+ dirs.addElement(cmdout[i].substring(s));
+ ++i;
+ for (; i < cmdout.length; ++i) {
+ dirs.addElement(cmdout[i]);
+ }
+ }
+ }
+ // Eliminate all but actual directories.
+ String[] libpath = new String[dirs.size()];
+ dirs.copyInto(libpath);
+ int count = CUtil.checkDirectoryArray(libpath);
+ // Build return array.
+ libDirs = new File[count];
+ int index = 0;
+ for (int i = 0; i < libpath.length; ++i) {
+ if (libpath[i] != null) {
+ libDirs[index++] = new File(libpath[i]);
+ }
+ }
+ }
+ return libDirs;
+ }
+ public Linker getLinker(LinkType type) {
+ if (type.isStaticLibrary()) {
+ return GccLibrarian.getInstance();
+ }
+ // BEGINFREEHEP
+ if (type.isJNIModule()) {
+ return isDarwin() ? machJNILinker : isWindows() ? dllLinker
+ : soLinker;
+ }
+ if (type.isPluginModule()) {
+ return isDarwin() ? machPluginLinker : isWindows() ? dllLinker
+ : soLinker;
+ }
+ if (type.isSharedLibrary()) {
+ return isDarwin() ? machDllLinker : isWindows() ? dllLinker
+ : soLinker;
+ }
+ // ENDFREEHEP
+ return instance;
+ }
}
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/gcc/WindresResourceCompiler.java b/src/main/java/net/sf/antcontrib/cpptasks/gcc/WindresResourceCompiler.java
new file mode 100644
index 0000000..a617024
--- /dev/null
+++ b/src/main/java/net/sf/antcontrib/cpptasks/gcc/WindresResourceCompiler.java
@@ -0,0 +1,121 @@
+/*
+ *
+ * Copyright 2008 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+import net.sf.antcontrib.cpptasks.parser.CParser;
+import net.sf.antcontrib.cpptasks.parser.Parser;
+import net.sf.antcontrib.cpptasks.OptimizationEnum;
+
+import org.apache.tools.ant.types.Environment;
+/**
+ * Adapter for the GNU windres resource compiler.
+ *
+ * @author Curt Arnold
+ */
+public final class WindresResourceCompiler extends CommandLineCompiler {
+ private static final WindresResourceCompiler instance = new WindresResourceCompiler(
+ false, null);
+ public static WindresResourceCompiler getInstance() {
+ return instance;
+ }
+ private WindresResourceCompiler(boolean newEnvironment, Environment env) {
+ super("windres", null, new String[]{".rc"}, new String[]{".h", ".hpp",
+ ".inl"}, ".o", false, null, newEnvironment, env);
+ }
+ protected void addImpliedArgs(final Vector args,
+ final boolean debug,
+ final boolean multithreaded,
+ final boolean exceptions,
+ final LinkType linkType,
+ final Boolean rtti,
+ final OptimizationEnum optimization) {
+ if (debug) {
+ args.addElement("-D_DEBUG");
+ } else {
+ args.addElement("-DNDEBUG");
+ }
+ }
+ protected void addWarningSwitch(Vector args, int level) {
+ }
+ public Processor changeEnvironment(boolean newEnvironment, Environment env) {
+ if (newEnvironment || env != null) {
+ return new WindresResourceCompiler(newEnvironment, env);
+ }
+ return this;
+ }
+ /**
+ * The include parser for C will work just fine, but we didn't want to
+ * inherit from CommandLineCCompiler
+ */
+ protected Parser createParser(File source) {
+ return new CParser();
+ }
+ protected int getArgumentCountPerInputFile() {
+ return 2;
+ }
+ protected void getDefineSwitch(StringBuffer buffer, String define,
+ String value) {
+ buffer.append("-D");
+ buffer.append(define);
+ if (value != null && value.length() > 0) {
+ buffer.append('=');
+ buffer.append(value);
+ }
+ }
+ protected File[] getEnvironmentIncludePath() {
+ return new File[0];
+ }
+ protected String getIncludeDirSwitch(String includeDir) {
+ return "-I" + includeDir;
+ }
+ protected String getInputFileArgument(File outputDir, String filename,
+ int index) {
+ if (index == 0) {
+ String outputFileName = getOutputFileNames(filename, null)[0];
+ return "-o" + outputFileName;
+ }
+ return filename;
+ }
+ public Linker getLinker(LinkType type) {
+ return GccLinker.getInstance().getLinker(type);
+ }
+ public int getMaximumCommandLength() {
+ return 32767;
+ }
+ protected int getMaximumInputFilesPerCommand() {
+ return 1;
+ }
+ protected int getTotalArgumentLengthForInputFile(File outputDir,
+ String inputFile) {
+ String arg1 = getInputFileArgument(outputDir, inputFile, 0);
+ String arg2 = getInputFileArgument(outputDir, inputFile, 1);
+ return arg1.length() + arg2.length() + 2;
+ }
+ protected void getUndefineSwitch(StringBuffer buffer, String define) {
+ buffer.append("-U");
+ buffer.append(define);
+ }
+ public String getIdentifier() {
+ return "GNU windres";
+ }
+}
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/gcc/cross/GccProcessor.java b/src/main/java/net/sf/antcontrib/cpptasks/gcc/cross/GccProcessor.java
index 8e35995..728cd47 100644
--- a/src/main/java/net/sf/antcontrib/cpptasks/gcc/cross/GccProcessor.java
+++ b/src/main/java/net/sf/antcontrib/cpptasks/gcc/cross/GccProcessor.java
@@ -106,7 +106,7 @@ public class GccProcessor {
* -dumpversion. Attempts to use gcc -dumpspecs to provide this information
* resulted in stalling on the Execute.run
*
- * @returns contents of the specs file
+ * @return contents of the specs file
*/
public static String[] getSpecs() {
if (specs == null) {
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccProcessor.java b/src/main/java/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccProcessor.java
index 8a7a26e..bbcd13d 100644
--- a/src/main/java/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccProcessor.java
+++ b/src/main/java/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccProcessor.java
@@ -121,7 +121,7 @@ public class GccProcessor {
* -dumpversion. Attempts to use gcc -dumpspecs to provide this information
* resulted in stalling on the Execute.run
*
- * @returns contents of the specs file
+ * @return contents of the specs file
*/
public static String[] getSpecs() {
if (specs == null) {