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