1 | /*
|
---|
2 | * Copyright 2001-2004 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 | */
|
---|
17 |
|
---|
18 | package org.apache.tools.ant.taskdefs.compilers;
|
---|
19 |
|
---|
20 | import org.apache.tools.ant.BuildException;
|
---|
21 | import org.apache.tools.ant.Project;
|
---|
22 | import org.apache.tools.ant.types.Commandline;
|
---|
23 | import org.apache.tools.ant.types.Path;
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * The implementation of the jvc compiler from microsoft.
|
---|
27 | * This is primarily a cut-and-paste from the original javac task before it
|
---|
28 | * was refactored.
|
---|
29 | *
|
---|
30 | * @since Ant 1.3
|
---|
31 | */
|
---|
32 | public class Jvc extends DefaultCompilerAdapter {
|
---|
33 |
|
---|
34 | /**
|
---|
35 | * Run the compilation.
|
---|
36 | *
|
---|
37 | * @exception BuildException if the compilation has problems.
|
---|
38 | */
|
---|
39 | public boolean execute() throws BuildException {
|
---|
40 | attributes.log("Using jvc compiler", Project.MSG_VERBOSE);
|
---|
41 |
|
---|
42 | Path classpath = new Path(project);
|
---|
43 |
|
---|
44 | // jvc doesn't support bootclasspath dir (-bootclasspath)
|
---|
45 | // so we'll emulate it for compatibility and convenience.
|
---|
46 | if (bootclasspath != null) {
|
---|
47 | classpath.append(bootclasspath);
|
---|
48 | }
|
---|
49 |
|
---|
50 | if (includeJavaRuntime) {
|
---|
51 | // jvc doesn't support an extension dir (-extdir)
|
---|
52 | // so we'll emulate it for compatibility and convenience.
|
---|
53 | classpath.addExtdirs(extdirs);
|
---|
54 | }
|
---|
55 |
|
---|
56 | classpath.append(getCompileClasspath());
|
---|
57 |
|
---|
58 | // jvc has no option for source-path so we
|
---|
59 | // will add it to classpath.
|
---|
60 | if (compileSourcepath != null) {
|
---|
61 | classpath.append(compileSourcepath);
|
---|
62 | } else {
|
---|
63 | classpath.append(src);
|
---|
64 | }
|
---|
65 |
|
---|
66 | Commandline cmd = new Commandline();
|
---|
67 | String exec = getJavac().getExecutable();
|
---|
68 | cmd.setExecutable(exec == null ? "jvc" : exec);
|
---|
69 |
|
---|
70 | if (destDir != null) {
|
---|
71 | cmd.createArgument().setValue("/d");
|
---|
72 | cmd.createArgument().setFile(destDir);
|
---|
73 | }
|
---|
74 |
|
---|
75 | // Add the Classpath before the "internal" one.
|
---|
76 | cmd.createArgument().setValue("/cp:p");
|
---|
77 | cmd.createArgument().setPath(classpath);
|
---|
78 |
|
---|
79 | boolean msExtensions = true;
|
---|
80 | String mse = getProject().getProperty("build.compiler.jvc.extensions");
|
---|
81 | if (mse != null) {
|
---|
82 | msExtensions = Project.toBoolean(mse);
|
---|
83 | }
|
---|
84 |
|
---|
85 | if (msExtensions) {
|
---|
86 | // Enable MS-Extensions and ...
|
---|
87 | cmd.createArgument().setValue("/x-");
|
---|
88 | // ... do not display a Message about this.
|
---|
89 | cmd.createArgument().setValue("/nomessage");
|
---|
90 | }
|
---|
91 |
|
---|
92 | // Do not display Logo
|
---|
93 | cmd.createArgument().setValue("/nologo");
|
---|
94 |
|
---|
95 | if (debug) {
|
---|
96 | cmd.createArgument().setValue("/g");
|
---|
97 | }
|
---|
98 | if (optimize) {
|
---|
99 | cmd.createArgument().setValue("/O");
|
---|
100 | }
|
---|
101 | if (verbose) {
|
---|
102 | cmd.createArgument().setValue("/verbose");
|
---|
103 | }
|
---|
104 |
|
---|
105 | addCurrentCompilerArgs(cmd);
|
---|
106 |
|
---|
107 | int firstFileName = cmd.size();
|
---|
108 | logAndAddFilesToCompile(cmd);
|
---|
109 |
|
---|
110 | return
|
---|
111 | executeExternalCompile(cmd.getCommandline(), firstFileName) == 0;
|
---|
112 | }
|
---|
113 | }
|
---|