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