diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 31e2df937..199afb158 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -6,6 +6,7 @@ Andrew Everitt Anil K. Vijendran Anli Shundi Antoine Levy-Lambert +Arnaud Vandyck Arnout J. Kuiper Aslak Hellesøy Avik Sengupta diff --git a/WHATSNEW b/WHATSNEW index 29c841098..004063020 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -105,6 +105,11 @@ Fixed bugs: * failOnAny attribute for was broken. Bugzilla Report 28122. +* If uses gcj and any of the nested s implies + compilation to native code (like -o or --main), Ant will not pass + the -C switch to gcj. This means you can now compile to native code + with gcj which has been impossible in Ant < 1.6.2. + Other changes: -------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java b/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java index 4a05cff05..ed00ef7ab 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java @@ -102,11 +102,42 @@ public class Gcj extends DefaultCompilerAdapter { /** * gcj should be set for generate class. + * ... if no 'compile to native' argument is passed */ - cmd.createArgument().setValue("-C"); + if (!isNativeBuild()) { + cmd.createArgument().setValue("-C"); + } addCurrentCompilerArgs(cmd); return cmd; } + + /** + * Whether any of the arguments given via <compilerarg> + * implies that compilation to native code is requested. + * + * @since Ant 1.6.2 + */ + public boolean isNativeBuild() { + boolean nativeBuild = false; + String[] additionalArguments = getJavac().getCurrentCompilerArgs(); + int argsLength=0; + while (!nativeBuild && argsLength < additionalArguments.length) { + int conflictLength = 0; + while (!nativeBuild + && conflictLength < CONFLICT_WITH_DASH_C.length) { + nativeBuild = (additionalArguments[argsLength].startsWith + (CONFLICT_WITH_DASH_C[conflictLength])); + conflictLength++; + } + argsLength++; + } + return nativeBuild; + } + + private static final String [] CONFLICT_WITH_DASH_C = { + "-o" , "--main=", "-D", "-fjni", "-L" + }; + }