3 * Copyright 2001-2004 The Ant-Contrib project
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package net
.sf
.antcontrib
.cpptasks
.ti
;
19 import java
.util
.Vector
;
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
;
28 import org
.apache
.tools
.ant
.types
.Environment
;
30 * Adapter for TI DSP compilers with cl** commands
34 public class ClxxCCompiler
extends CommandLineCCompiler
{
36 * Header file extensions
38 private static final String
[] headerExtensions
= new String
[]{".h", ".hpp",
41 * Source file extensions
43 private static final String
[] sourceExtensions
= new String
[]{".c", ".cc",
44 ".cpp", ".cxx", ".c++"};
46 * Singleton for TMS320C55x
48 private static final ClxxCCompiler cl55
= new ClxxCCompiler("cl55", false,
51 * Singleton for TMS320C6000
53 private static final ClxxCCompiler cl6x
= new ClxxCCompiler("cl6x", false,
55 public static ClxxCCompiler
getCl55Instance() {
58 public static ClxxCCompiler
getCl6xInstance() {
66 * @param newEnvironment
71 private ClxxCCompiler(String command
, boolean newEnvironment
,
73 super(command
, "-h", sourceExtensions
, headerExtensions
, ".o", false,
74 null, newEnvironment
, env
);
79 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#addImpliedArgs(java.util.Vector,
80 * boolean, boolean, boolean,
81 * net.sf.antcontrib.cpptasks.compiler.LinkType)
83 protected void addImpliedArgs(
86 final boolean multithreaded
,
87 final boolean exceptions
,
88 final LinkType linkType
,
90 final OptimizationEnum optimization
,
91 final Boolean defaultflag
) {
93 args
.addElement("-gw");
99 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#addWarningSwitch(java.util.Vector,
102 protected void addWarningSwitch(Vector args
, int warnings
) {
103 // TODO Auto-generated method stub
108 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getDefineSwitch(java.lang.StringBuffer,
109 * java.lang.String, java.lang.String)
111 protected void getDefineSwitch(StringBuffer buffer
, String define
,
114 buffer
.append(define
);
117 buffer
.append(value
);
123 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getEnvironmentIncludePath()
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) {
131 if (cx_dir
.length
== 0) {
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
];
138 for (int i
= 0; i
< c_dir
.length
; i
++) {
139 combo
[i
+ cx_dir
.length
] = c_dir
[i
];
146 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getIncludeDirSwitch(java.lang.String)
148 protected String
getIncludeDirSwitch(String source
) {
149 return "-I" + source
;
154 * @see net.sf.antcontrib.cpptasks.compiler.Processor#getLinker(net.sf.antcontrib.cpptasks.compiler.LinkType)
156 public Linker
getLinker(LinkType type
) {
157 if (type
.isStaticLibrary()) {
159 return ClxxLibrarian
.getCl6xInstance();
161 return ClxxLibrarian
.getCl55Instance();
163 if (type
.isSharedLibrary()) {
165 return ClxxLinker
.getCl6xDllInstance();
167 return ClxxLinker
.getCl55DllInstance();
170 return ClxxLinker
.getCl6xInstance();
172 return ClxxLinker
.getCl55Instance();
177 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getMaximumCommandLength()
179 public int getMaximumCommandLength() {
185 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getUndefineSwitch(java.lang.StringBuffer,
188 protected void getUndefineSwitch(StringBuffer buffer
, String define
) {
190 buffer
.append(define
);