source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/main/org/apache/tools/ant/taskdefs/optional/javah/Kaffeh.java@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 2.8 KB
Line 
1/*
2 * Copyright 2005 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17package org.apache.tools.ant.taskdefs.optional.javah;
18
19import org.apache.tools.ant.BuildException;
20import org.apache.tools.ant.taskdefs.Execute;
21import org.apache.tools.ant.taskdefs.optional.Javah;
22import org.apache.tools.ant.types.Commandline;
23import org.apache.tools.ant.types.Path;
24import org.apache.tools.ant.util.JavaEnvUtils;
25
26/**
27 * Adapter to the native kaffeh compiler.
28 *
29 * @since Ant 1.6.3
30 */
31public class Kaffeh implements JavahAdapter {
32
33 public static final String IMPLEMENTATION_NAME = "kaffeh";
34
35 /**
36 * Performs the actual compilation.
37 *
38 * @since Ant 1.6.3
39 */
40 public boolean compile(Javah javah) throws BuildException {
41 Commandline cmd = setupKaffehCommand(javah);
42 try {
43 Execute.runCommand(javah, cmd.getCommandline());
44 return true;
45 } catch (BuildException e) {
46 if (e.getMessage().indexOf("failed with return code") == -1) {
47 throw e;
48 }
49 }
50 return false;
51 }
52
53 private Commandline setupKaffehCommand(Javah javah) {
54 Commandline cmd = new Commandline();
55 cmd.setExecutable(JavaEnvUtils.getJdkExecutable("kaffeh"));
56
57 if (javah.getDestdir() != null) {
58 cmd.createArgument().setValue("-d");
59 cmd.createArgument().setFile(javah.getDestdir());
60 }
61
62 if (javah.getOutputfile() != null) {
63 cmd.createArgument().setValue("-o");
64 cmd.createArgument().setFile(javah.getOutputfile());
65 }
66
67 Path cp = new Path(javah.getProject());
68 if (javah.getBootclasspath() != null) {
69 cp.append(javah.getBootclasspath());
70 }
71 if (javah.getClasspath() != null) {
72 cp.append(javah.getClasspath());
73 }
74 if (cp.size() > 0) {
75 cmd.createArgument().setValue("-classpath");
76 cmd.createArgument().setPath(cp);
77 }
78
79 if (!javah.getOld()) {
80 cmd.createArgument().setValue("-jni");
81 }
82
83 cmd.addArguments(javah.getCurrentArgs());
84
85 javah.logAndAddFiles(cmd);
86 return cmd;
87 }
88
89}
Note: See TracBrowser for help on using the repository browser.