git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1027025 13f79535-47bb-0310-9956-ffa450edef68master
@@ -33,6 +33,7 @@ Benjamin Burgess | |||||
Ben Galbraith | Ben Galbraith | ||||
Benoit Moussaud | Benoit Moussaud | ||||
Bernd Dutkowski | Bernd Dutkowski | ||||
Bernhard Rosenkraenzer | |||||
Brad Clark | Brad Clark | ||||
Brant Langer Gurganus | Brant Langer Gurganus | ||||
Brian Curnow | Brian Curnow | ||||
@@ -229,6 +229,9 @@ Other changes: | |||||
* A new <cutdirsmapper> can be used like wget's --cut-dirs option to | * A new <cutdirsmapper> can be used like wget's --cut-dirs option to | ||||
strip leading directories from file names. | strip leading directories from file names. | ||||
* <javah> now supports the GNU project's gcjh compiler. | |||||
Bugzilla Report 50149. | |||||
Changes from Ant 1.8.0 TO Ant 1.8.1 | Changes from Ant 1.8.0 TO Ant 1.8.1 | ||||
=================================== | =================================== | ||||
@@ -156,6 +156,10 @@ | |||||
<first>Bernd</first> | <first>Bernd</first> | ||||
<last>Dutkowski</last> | <last>Dutkowski</last> | ||||
</name> | </name> | ||||
<name> | |||||
<first>Bernhard</first> | |||||
<last>Rosenkraenzer</last> | |||||
</name> | |||||
<name> | <name> | ||||
<first>Brad</first> | <first>Brad</first> | ||||
<last>Clark</last> | <last>Clark</last> | ||||
@@ -40,6 +40,9 @@ name="implementationvalues">Here are the choices of the attribute</a>:</p> | |||||
<li>default - the default compiler (kaffeh or sun) for the platform.</li> | <li>default - the default compiler (kaffeh or sun) for the platform.</li> | ||||
<li>sun (the standard compiler of the JDK)</li> | <li>sun (the standard compiler of the JDK)</li> | ||||
<li>kaffeh (the native standard compiler of <a href="http://www.kaffe.org" target="_top">Kaffe</a>)</li> | <li>kaffeh (the native standard compiler of <a href="http://www.kaffe.org" target="_top">Kaffe</a>)</li> | ||||
<li>gcjh (the native standard compiler | |||||
of <a href="http://gcc.gnu.org/java/" | |||||
target="_top">gcj and gij</a>) <em>since Ant 1.8.2</em></li> | |||||
</ul> | </ul> | ||||
<p><b>Note:</b> if you are using this task to work on multiple files | <p><b>Note:</b> if you are using this task to work on multiple files | ||||
@@ -0,0 +1,89 @@ | |||||
/* | |||||
* Licensed to the Apache Software Foundation (ASF) under one or more | |||||
* contributor license agreements. See the NOTICE file distributed with | |||||
* this work for additional information regarding copyright ownership. | |||||
* The ASF licenses this file to You 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 org.apache.tools.ant.taskdefs.optional.javah; | |||||
import org.apache.tools.ant.BuildException; | |||||
import org.apache.tools.ant.taskdefs.Execute; | |||||
import org.apache.tools.ant.taskdefs.optional.Javah; | |||||
import org.apache.tools.ant.types.Commandline; | |||||
import org.apache.tools.ant.types.Path; | |||||
import org.apache.tools.ant.util.JavaEnvUtils; | |||||
/** | |||||
* Adapter to the native gcjh compiler. | |||||
* | |||||
* @since Ant 1.8.2 | |||||
*/ | |||||
public class Gcjh implements JavahAdapter { | |||||
public static final String IMPLEMENTATION_NAME = "gcjh"; | |||||
/** | |||||
* Performs the actual compilation. | |||||
*/ | |||||
public boolean compile(Javah javah) throws BuildException { | |||||
Commandline cmd = setupGcjhCommand(javah); | |||||
try { | |||||
Execute.runCommand(javah, cmd.getCommandline()); | |||||
return true; | |||||
} catch (BuildException e) { | |||||
if (e.getMessage().indexOf("failed with return code") == -1) { | |||||
throw e; | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
private Commandline setupGcjhCommand(Javah javah) { | |||||
Commandline cmd = new Commandline(); | |||||
cmd.setExecutable(JavaEnvUtils.getJdkExecutable("gcjh")); | |||||
if (javah.getDestdir() != null) { | |||||
cmd.createArgument().setValue("-d"); | |||||
cmd.createArgument().setFile(javah.getDestdir()); | |||||
} | |||||
if (javah.getOutputfile() != null) { | |||||
cmd.createArgument().setValue("-o"); | |||||
cmd.createArgument().setFile(javah.getOutputfile()); | |||||
} | |||||
Path cp = new Path(javah.getProject()); | |||||
if (javah.getBootclasspath() != null) { | |||||
cp.append(javah.getBootclasspath()); | |||||
} | |||||
cp = cp.concatSystemBootClasspath("ignore"); | |||||
if (javah.getClasspath() != null) { | |||||
cp.append(javah.getClasspath()); | |||||
} | |||||
if (cp.size() > 0) { | |||||
cmd.createArgument().setValue("--classpath"); | |||||
cmd.createArgument().setPath(cp); | |||||
} | |||||
if (!javah.getOld()) { | |||||
cmd.createArgument().setValue("-jni"); | |||||
} | |||||
cmd.addArguments(javah.getCurrentArgs()); | |||||
javah.logAndAddFiles(cmd); | |||||
return cmd; | |||||
} | |||||
} |
@@ -42,6 +42,8 @@ public class JavahAdapterFactory { | |||||
public static String getDefault() { | public static String getDefault() { | ||||
if (JavaEnvUtils.isKaffe()) { | if (JavaEnvUtils.isKaffe()) { | ||||
return Kaffeh.IMPLEMENTATION_NAME; | return Kaffeh.IMPLEMENTATION_NAME; | ||||
} else if (JavaEnvUtils.isGij()) { | |||||
return Gcjh.IMPLEMENTATION_NAME; | |||||
} | } | ||||
return SunJavah.IMPLEMENTATION_NAME; | return SunJavah.IMPLEMENTATION_NAME; | ||||
} | } | ||||
@@ -82,6 +84,9 @@ public class JavahAdapterFactory { | |||||
if ((JavaEnvUtils.isKaffe() && choice == null) | if ((JavaEnvUtils.isKaffe() && choice == null) | ||||
|| Kaffeh.IMPLEMENTATION_NAME.equals(choice)) { | || Kaffeh.IMPLEMENTATION_NAME.equals(choice)) { | ||||
return new Kaffeh(); | return new Kaffeh(); | ||||
} else if ((JavaEnvUtils.isGij() && choice == null) | |||||
|| Gcjh.IMPLEMENTATION_NAME.equals(choice)) { | |||||
return new Gcjh(); | |||||
} else if (SunJavah.IMPLEMENTATION_NAME.equals(choice)) { | } else if (SunJavah.IMPLEMENTATION_NAME.equals(choice)) { | ||||
return new SunJavah(); | return new SunJavah(); | ||||
} else if (choice != null) { | } else if (choice != null) { | ||||
@@ -91,6 +91,8 @@ public final class JavaEnvUtils { | |||||
/** Whether this is the Kaffe VM */ | /** Whether this is the Kaffe VM */ | ||||
private static boolean kaffeDetected; | private static boolean kaffeDetected; | ||||
/** Whether this is the GNU VM (gcj/gij) */ | |||||
private static boolean gijDetected; | |||||
/** array of packages in the runtime */ | /** array of packages in the runtime */ | ||||
private static Vector jrePackages; | private static Vector jrePackages; | ||||
@@ -138,6 +140,13 @@ public final class JavaEnvUtils { | |||||
} catch (Throwable t) { | } catch (Throwable t) { | ||||
// swallow as this simply doesn't seem to be Kaffe | // swallow as this simply doesn't seem to be Kaffe | ||||
} | } | ||||
gijDetected = false; | |||||
try { | |||||
Class.forName("gnu.gcj.Core"); | |||||
gijDetected = true; | |||||
} catch (Throwable t) { | |||||
// swallow as this simply doesn't seem to be gcj/gij | |||||
} | |||||
} | } | ||||
/** | /** | ||||
@@ -198,6 +207,15 @@ public final class JavaEnvUtils { | |||||
return kaffeDetected; | return kaffeDetected; | ||||
} | } | ||||
/** | |||||
* Checks whether the current Java VM is the GNU interpreter gij | |||||
* or we are running in a gcj precompiled binary. | |||||
* @return true if the current Java VM is gcj/gij. | |||||
*/ | |||||
public static boolean isGij() { | |||||
return gijDetected; | |||||
} | |||||
/** | /** | ||||
* Finds an executable that is part of a JRE installation based on | * Finds an executable that is part of a JRE installation based on | ||||
* the java.home system property. | * the java.home system property. | ||||