Browse Source

enable gcj's java -> native compilation.

Submitted by:	Arnaud Vandyck <arnaud dot vandyck at ulg dot ac dot be>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276301 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 21 years ago
parent
commit
17e505e629
3 changed files with 38 additions and 1 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +5
    -0
      WHATSNEW
  3. +32
    -1
      src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java

+ 1
- 0
CONTRIBUTORS View File

@@ -6,6 +6,7 @@ Andrew Everitt
Anil K. Vijendran
Anli Shundi
Antoine Levy-Lambert
Arnaud Vandyck
Arnout J. Kuiper
Aslak Hellesøy
Avik Sengupta


+ 5
- 0
WHATSNEW View File

@@ -105,6 +105,11 @@ Fixed bugs:

* failOnAny attribute for <parallel> was broken. Bugzilla Report 28122.

* If <javac> uses gcj and any of the nested <compilerarg>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:
--------------



+ 32
- 1
src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java View File

@@ -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 &lt;compilerarg&gt;
* 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"
};

}

Loading…
Cancel
Save