]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ti/ClxxCCompiler.java
Initial import.
[mirror_edk2.git] / Tools / Source / Cpptasks / net / sf / antcontrib / cpptasks / ti / ClxxCCompiler.java
CommitLineData
878ddf1f 1/*\r
2 * \r
3 * Copyright 2001-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.ti;\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.compiler.CommandLineCCompiler;\r
23import net.sf.antcontrib.cpptasks.compiler.LinkType;\r
24import net.sf.antcontrib.cpptasks.compiler.Linker;\r
25import net.sf.antcontrib.cpptasks.OptimizationEnum;\r
26\r
27\r
28import org.apache.tools.ant.types.Environment;\r
29/**\r
30 * Adapter for TI DSP compilers with cl** commands\r
31 * \r
32 * @author CurtA\r
33 */\r
34public class ClxxCCompiler extends CommandLineCCompiler {\r
35 /**\r
36 * Header file extensions\r
37 */\r
38 private static final String[] headerExtensions = new String[]{".h", ".hpp",\r
39 ".inl"};\r
40 /**\r
41 * Source file extensions\r
42 */\r
43 private static final String[] sourceExtensions = new String[]{".c", ".cc",\r
44 ".cpp", ".cxx", ".c++"};\r
45 /**\r
46 * Singleton for TMS320C55x\r
47 */\r
48 private static final ClxxCCompiler cl55 = new ClxxCCompiler("cl55", false,\r
49 null);\r
50 /**\r
51 * Singleton for TMS320C6000\r
52 */\r
53 private static final ClxxCCompiler cl6x = new ClxxCCompiler("cl6x", false,\r
54 null);\r
55 public static ClxxCCompiler getCl55Instance() {\r
56 return cl55;\r
57 }\r
58 public static ClxxCCompiler getCl6xInstance() {\r
59 return cl6x;\r
60 }\r
61 /**\r
62 * Private constructor\r
63 * \r
64 * @param command\r
65 * executable name\r
66 * @param newEnvironment\r
67 * Change environment\r
68 * @param env\r
69 * New environment\r
70 */\r
71 private ClxxCCompiler(String command, boolean newEnvironment,\r
72 Environment env) {\r
73 super(command, "-h", sourceExtensions, headerExtensions, ".o", false,\r
74 null, newEnvironment, env);\r
75 }\r
76 /*\r
77 * (non-Javadoc)\r
78 * \r
79 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#addImpliedArgs(java.util.Vector,\r
80 * boolean, boolean, boolean,\r
81 * net.sf.antcontrib.cpptasks.compiler.LinkType)\r
82 */\r
83 protected void addImpliedArgs(\r
84 final Vector args, \r
85 final boolean debug,\r
86 final boolean multithreaded, \r
87 final boolean exceptions, \r
88 final LinkType linkType,\r
89 final Boolean rtti,\r
90 final OptimizationEnum optimization,\r
91 final Boolean defaultflag) {\r
92 if (debug) {\r
93 args.addElement("-gw");\r
94 }\r
95 }\r
96 /*\r
97 * (non-Javadoc)\r
98 * \r
99 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#addWarningSwitch(java.util.Vector,\r
100 * int)\r
101 */\r
102 protected void addWarningSwitch(Vector args, int warnings) {\r
103 // TODO Auto-generated method stub\r
104 }\r
105 /*\r
106 * (non-Javadoc)\r
107 * \r
108 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getDefineSwitch(java.lang.StringBuffer,\r
109 * java.lang.String, java.lang.String)\r
110 */\r
111 protected void getDefineSwitch(StringBuffer buffer, String define,\r
112 String value) {\r
113 buffer.append("-d");\r
114 buffer.append(define);\r
115 if (value != null) {\r
116 buffer.append('=');\r
117 buffer.append(value);\r
118 }\r
119 }\r
120 /*\r
121 * (non-Javadoc)\r
122 * \r
123 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getEnvironmentIncludePath()\r
124 */\r
125 protected File[] getEnvironmentIncludePath() {\r
126 File[] c_dir = CUtil.getPathFromEnvironment("C_DIR", ";");\r
127 File[] cx_dir = CUtil.getPathFromEnvironment("C6X_C_DIR", ";");\r
128 if (c_dir.length == 0) {\r
129 return cx_dir;\r
130 }\r
131 if (cx_dir.length == 0) {\r
132 return c_dir;\r
133 }\r
134 File[] combo = new File[c_dir.length + cx_dir.length];\r
135 for (int i = 0; i < cx_dir.length; i++) {\r
136 combo[i] = cx_dir[i];\r
137 }\r
138 for (int i = 0; i < c_dir.length; i++) {\r
139 combo[i + cx_dir.length] = c_dir[i];\r
140 }\r
141 return combo;\r
142 }\r
143 /*\r
144 * (non-Javadoc)\r
145 * \r
146 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getIncludeDirSwitch(java.lang.String)\r
147 */\r
148 protected String getIncludeDirSwitch(String source) {\r
149 return "-I" + source;\r
150 }\r
151 /*\r
152 * (non-Javadoc)\r
153 * \r
154 * @see net.sf.antcontrib.cpptasks.compiler.Processor#getLinker(net.sf.antcontrib.cpptasks.compiler.LinkType)\r
155 */\r
156 public Linker getLinker(LinkType type) {\r
157 if (type.isStaticLibrary()) {\r
158 if (this == cl6x) {\r
159 return ClxxLibrarian.getCl6xInstance();\r
160 }\r
161 return ClxxLibrarian.getCl55Instance();\r
162 }\r
163 if (type.isSharedLibrary()) {\r
164 if (this == cl6x) {\r
165 return ClxxLinker.getCl6xDllInstance();\r
166 }\r
167 return ClxxLinker.getCl55DllInstance();\r
168 }\r
169 if (this == cl6x) {\r
170 return ClxxLinker.getCl6xInstance();\r
171 }\r
172 return ClxxLinker.getCl55Instance();\r
173 }\r
174 /*\r
175 * (non-Javadoc)\r
176 * \r
177 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getMaximumCommandLength()\r
178 */\r
179 public int getMaximumCommandLength() {\r
180 return 1024;\r
181 }\r
182 /*\r
183 * (non-Javadoc)\r
184 * \r
185 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getUndefineSwitch(java.lang.StringBuffer,\r
186 * java.lang.String)\r
187 */\r
188 protected void getUndefineSwitch(StringBuffer buffer, String define) {\r
189 buffer.append("-u");\r
190 buffer.append(define);\r
191 }\r
192}\r