]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandCCompiler.java
Changed spelling to manifest
[mirror_edk2.git] / Tools / Source / Cpptasks / net / sf / antcontrib / cpptasks / borland / BorlandCCompiler.java
1 /*
2 *
3 * Copyright 2002-2004 The Ant-Contrib project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package net.sf.antcontrib.cpptasks.borland;
18 import java.io.File;
19 import java.util.Vector;
20
21 import net.sf.antcontrib.cpptasks.compiler.CommandLineCompilerConfiguration;
22 import net.sf.antcontrib.cpptasks.compiler.CompilerConfiguration;
23 import net.sf.antcontrib.cpptasks.compiler.LinkType;
24 import net.sf.antcontrib.cpptasks.compiler.Linker;
25 import net.sf.antcontrib.cpptasks.compiler.PrecompilingCommandLineCCompiler;
26 import net.sf.antcontrib.cpptasks.compiler.Processor;
27 import net.sf.antcontrib.cpptasks.OptimizationEnum;
28
29 import org.apache.tools.ant.types.Environment;
30 /**
31 * Adapter for the Borland(r) C/C++ compiler.
32 *
33 * @author Curt Arnold
34 */
35 public class BorlandCCompiler extends PrecompilingCommandLineCCompiler {
36 private static final String[] headerExtensions = new String[]{".h", ".hpp",
37 ".inl"};
38 private static final String[] sourceExtensions = new String[]{".c", ".cc",
39 ".cpp", ".cxx", ".c++"};
40 private static final BorlandCCompiler instance = new BorlandCCompiler(
41 false, null);
42 public static BorlandCCompiler getInstance() {
43 return instance;
44 }
45 private BorlandCCompiler(boolean newEnvironment, Environment env) {
46 super("bcc32", "--version", sourceExtensions, headerExtensions, ".obj", false,
47 null, newEnvironment, env);
48 }
49 protected void addImpliedArgs(final Vector args,
50 final boolean debug,
51 final boolean multithreaded,
52 final boolean exceptions,
53 final LinkType linkType,
54 final Boolean rtti,
55 final OptimizationEnum optimization,
56 final Boolean defaultflag) {
57 args.addElement("-c");
58 //
59 // turn off compiler autodependency since
60 // we do it ourselves
61 args.addElement("-X");
62 if (exceptions) {
63 args.addElement("-x");
64 } else {
65 args.addElement("-x-");
66 }
67 if (multithreaded) {
68 args.addElement("-tWM");
69 }
70 if (debug) {
71 args.addElement("-Od");
72 args.addElement("-v");
73 } else {
74 if (optimization != null) {
75 if (optimization.isSpeed()) {
76 args.addElement("-O1");
77 } else {
78 if (optimization.isSpeed()) {
79 args.addElement("-O2");
80 } else {
81 if (optimization.isNoOptimization()) {
82 args.addElement("-Od");
83 }
84 }
85 }
86 }
87 }
88 if (rtti != null && !rtti.booleanValue()) {
89 args.addElement("-RT-");
90 }
91 }
92 protected void addWarningSwitch(Vector args, int level) {
93 BorlandProcessor.addWarningSwitch(args, level);
94 }
95 public Processor changeEnvironment(boolean newEnvironment, Environment env) {
96 if (newEnvironment || env != null) {
97 return new BorlandCCompiler(newEnvironment, env);
98 }
99 return this;
100 }
101 protected CompilerConfiguration createPrecompileGeneratingConfig(
102 CommandLineCompilerConfiguration baseConfig, File prototype,
103 String lastInclude) {
104 String[] additionalArgs = new String[]{"-H=" + lastInclude, "-Hc"};
105 return new CommandLineCompilerConfiguration(baseConfig, additionalArgs,
106 null, true);
107 }
108 protected CompilerConfiguration createPrecompileUsingConfig(
109 CommandLineCompilerConfiguration baseConfig, File prototype,
110 String lastInclude, String[] exceptFiles) {
111 String[] additionalArgs = new String[]{"-Hu"};
112 return new CommandLineCompilerConfiguration(baseConfig, additionalArgs,
113 exceptFiles, false);
114 }
115 protected void getDefineSwitch(StringBuffer buffer, String define,
116 String value) {
117 BorlandProcessor.getDefineSwitch(buffer, define, value);
118 }
119 protected File[] getEnvironmentIncludePath() {
120 return BorlandProcessor.getEnvironmentPath("bcc32", 'I',
121 new String[]{"..\\include"});
122 }
123 protected String getIncludeDirSwitch(String includeDir) {
124 return BorlandProcessor.getIncludeDirSwitch("-I", includeDir);
125 }
126 public Linker getLinker(LinkType type) {
127 return BorlandLinker.getInstance().getLinker(type);
128 }
129 public int getMaximumCommandLength() {
130 return 1024;
131 }
132 protected void getUndefineSwitch(StringBuffer buffer, String define) {
133 BorlandProcessor.getUndefineSwitch(buffer, define);
134 }
135 }