1 18 package org.apache.tools.ant.taskdefs.optional.javah; 19 20 import org.apache.tools.ant.BuildException; 21 import org.apache.tools.ant.taskdefs.Execute; 22 import org.apache.tools.ant.taskdefs.optional.Javah; 23 import org.apache.tools.ant.types.Commandline; 24 import org.apache.tools.ant.types.Path; 25 import org.apache.tools.ant.util.JavaEnvUtils; 26 27 32 public class Kaffeh implements JavahAdapter { 33 34 35 public static final String IMPLEMENTATION_NAME = "kaffeh"; 36 37 44 public boolean compile(Javah javah) throws BuildException { 45 Commandline cmd = setupKaffehCommand(javah); 46 try { 47 Execute.runCommand(javah, cmd.getCommandline()); 48 return true; 49 } catch (BuildException e) { 50 if (e.getMessage().indexOf("failed with return code") == -1) { 51 throw e; 52 } 53 } 54 return false; 55 } 56 57 private Commandline setupKaffehCommand(Javah javah) { 58 Commandline cmd = new Commandline(); 59 cmd.setExecutable(JavaEnvUtils.getJdkExecutable("kaffeh")); 60 61 if (javah.getDestdir() != null) { 62 cmd.createArgument().setValue("-d"); 63 cmd.createArgument().setFile(javah.getDestdir()); 64 } 65 66 if (javah.getOutputfile() != null) { 67 cmd.createArgument().setValue("-o"); 68 cmd.createArgument().setFile(javah.getOutputfile()); 69 } 70 71 Path cp = new Path(javah.getProject()); 72 if (javah.getBootclasspath() != null) { 73 cp.append(javah.getBootclasspath()); 74 } 75 cp = cp.concatSystemBootClasspath("ignore"); 76 if (javah.getClasspath() != null) { 77 cp.append(javah.getClasspath()); 78 } 79 if (cp.size() > 0) { 80 cmd.createArgument().setValue("-classpath"); 81 cmd.createArgument().setPath(cp); 82 } 83 84 if (!javah.getOld()) { 85 cmd.createArgument().setValue("-jni"); 86 } 87 88 cmd.addArguments(javah.getCurrentArgs()); 89 90 javah.logAndAddFiles(cmd); 91 return cmd; 92 } 93 94 } 95 | Popular Tags |