]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/arm/ADSCCompiler.java
Changed spelling to manifest
[mirror_edk2.git] / Tools / Source / Cpptasks / net / sf / antcontrib / cpptasks / arm / ADSCCompiler.java
1 /*
2 *
3 * Copyright 2003-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.arm;
18 import java.io.File;
19 import java.util.Vector;
20
21 import net.sf.antcontrib.cpptasks.CUtil;
22 import net.sf.antcontrib.cpptasks.OptimizationEnum;
23 import net.sf.antcontrib.cpptasks.compiler.CommandLineCCompiler;
24 import net.sf.antcontrib.cpptasks.compiler.LinkType;
25 import net.sf.antcontrib.cpptasks.compiler.Linker;
26
27 import org.apache.tools.ant.types.Environment;
28 /**
29 * Adapter for the ARM C Compilers
30 *
31 * See Doc No: ARM DUI 0151A, Issued: Nov 2001 at
32 * http://www.arm.com/arm/User_Guides?OpenDocument
33 *
34 * @author Curt Arnold
35 *
36 */
37 public class ADSCCompiler extends CommandLineCCompiler {
38 /**
39 * Header file extensions
40 */
41 private static final String[] headerExtensions = new String[]{".h", ".hpp",
42 ".inl"};
43 /**
44 * Source file extensions
45 */
46 private static final String[] sourceExtensions = new String[]{".c", ".cc",
47 ".cpp", ".cxx", ".c++"};
48 /**
49 * Singleton for ARM 32-bit C compiler
50 */
51 private static final ADSCCompiler armcc = new ADSCCompiler("armcc", false,
52 null);
53 /**
54 * Singleton for ARM 32-bit C++ compiler
55 */
56 private static final ADSCCompiler armcpp = new ADSCCompiler("armcpp",
57 false, null);
58 /**
59 * Singleton for ARM 16-bit C compiler
60 */
61 private static final ADSCCompiler tcc = new ADSCCompiler("tcc", false, null);
62 /**
63 * Singleton for ARM 16-bit C++ compiler
64 */
65 private static final ADSCCompiler tcpp = new ADSCCompiler("tcpp", false,
66 null);
67 /**
68 * Singleton for ARM 32-bit C compiler
69 */
70 public static ADSCCompiler getArmCC() {
71 return armcc;
72 }
73 /**
74 * Singleton for ARM 32-bit C++ compiler
75 */
76 public static ADSCCompiler getArmCpp() {
77 return armcpp;
78 }
79 /**
80 * Singleton for ARM 16-bit C compiler
81 */
82 public static ADSCCompiler getThumbCC() {
83 return tcpp;
84 }
85 /**
86 * Singleton for ARM 16-bit C++ compiler
87 */
88 public static ADSCCompiler getThumbCpp() {
89 return tcpp;
90 }
91 private static void quoteFile(StringBuffer buf, String outPath) {
92 if (outPath.indexOf(' ') >= 0) {
93 buf.append('\"');
94 buf.append(outPath);
95 buf.append('\"');
96 } else {
97 buf.append(outPath);
98 }
99 }
100 /**
101 * Private constructor
102 *
103 * @param command
104 * executable name
105 * @param newEnvironment
106 * Change environment
107 * @param env
108 * New environment
109 */
110 private ADSCCompiler(String command, boolean newEnvironment, Environment env) {
111 super(command, "-vsn", sourceExtensions, headerExtensions, ".o", false,
112 null, newEnvironment, env);
113 }
114 /**
115 * Adds command switches for generic configuration options
116 *
117 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#addImpliedArgs(java.util.Vector,
118 * boolean, boolean, boolean,
119 * net.sf.antcontrib.cpptasks.compiler.LinkType)
120 */
121 protected void addImpliedArgs(Vector args,
122 final boolean debug,
123 final boolean multithreaded,
124 final boolean exceptions,
125 final LinkType linkType,
126 final Boolean rtti,
127 final OptimizationEnum optimization,
128 final Boolean defaultflag) {
129 if (debug) {
130 args.addElement("-g");
131 }
132 //
133 // didn't see anything about producing
134 // anything other than executables in the docs
135 if (linkType.isExecutable()) {
136 } else if (linkType.isSharedLibrary()) {
137 }
138 }
139 /**
140 * Adds flags that customize the warnings reported
141 *
142 * Compiler does not appear to have warning levels but ability to turn off
143 * specific errors by explicit switches, could fabricate levels by
144 * prioritizing errors.
145 *
146 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#addWarningSwitch(java.util.Vector,
147 * int)
148 */
149 protected void addWarningSwitch(Vector args, int warnings) {
150 }
151 /**
152 * Add command line options for preprocessor macro
153 *
154 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getDefineSwitch(java.lang.StringBuffer,
155 * java.lang.String, java.lang.String)
156 */
157 protected void getDefineSwitch(StringBuffer buffer, String define,
158 String value) {
159 buffer.append("-D");
160 buffer.append(define);
161 if (value != null) {
162 buffer.append('=');
163 buffer.append(value);
164 }
165 }
166 /**
167 * ARMINC environment variable contains the default include path
168 *
169 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getEnvironmentIncludePath()
170 */
171 protected File[] getEnvironmentIncludePath() {
172 return CUtil.getPathFromEnvironment("ARMINC", ";");
173 }
174 /**
175 * Returns command line option to specify include directory
176 *
177 */
178 protected String getIncludeDirSwitch(String source) {
179 StringBuffer buf = new StringBuffer("-I");
180 quoteFile(buf, source);
181 return buf.toString();
182 }
183 /*
184 * (non-Javadoc)
185 *
186 * @see net.sf.antcontrib.cpptasks.compiler.Processor#getLinker(net.sf.antcontrib.cpptasks.compiler.LinkType)
187 */
188 public Linker getLinker(LinkType type) {
189 if (type.isStaticLibrary()) {
190 return ADSLibrarian.getInstance();
191 }
192 if (type.isSharedLibrary()) {
193 return ADSLinker.getDllInstance();
194 }
195 return ADSLinker.getInstance();
196 }
197 /**
198 * Maximum command line length
199 *
200 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getMaximumCommandLength()
201 */
202 public int getMaximumCommandLength() {
203 return 1000;
204 }
205 /*
206 * Adds command to undefine preprocessor macro
207 *
208 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getUndefineSwitch(java.lang.StringBuffer,
209 * java.lang.String)
210 */
211 protected void getUndefineSwitch(StringBuffer buffer, String define) {
212 buffer.append("-U");
213 buffer.append(define);
214 }
215 }