1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.github.maven_nar.cpptasks.arm;
21
22 import java.io.File;
23 import java.util.Vector;
24
25 import org.apache.tools.ant.types.Environment;
26
27 import com.github.maven_nar.cpptasks.CUtil;
28 import com.github.maven_nar.cpptasks.OptimizationEnum;
29 import com.github.maven_nar.cpptasks.compiler.CommandLineCCompiler;
30 import com.github.maven_nar.cpptasks.compiler.LinkType;
31 import com.github.maven_nar.cpptasks.compiler.Linker;
32
33
34
35
36
37
38
39
40
41
42 public class ADSCCompiler extends CommandLineCCompiler {
43
44
45
46 private static final String[] headerExtensions = new String[] {
47 ".h", ".hpp", ".inl"
48 };
49
50
51
52 private static final String[] sourceExtensions = new String[] {
53 ".c", ".cc", ".cpp", ".cxx", ".c++"
54 };
55
56
57
58 private static final ADSCCompiler armcc = new ADSCCompiler("armcc", false, null);
59
60
61
62 private static final ADSCCompiler armcpp = new ADSCCompiler("armcpp", false, null);
63
64
65
66 private static final ADSCCompiler tcc = new ADSCCompiler("tcc", false, null);
67
68
69
70 private static final ADSCCompiler tcpp = new ADSCCompiler("tcpp", false, null);
71
72
73
74
75 public static ADSCCompiler getArmCC() {
76 return armcc;
77 }
78
79
80
81
82 public static ADSCCompiler getArmCpp() {
83 return armcpp;
84 }
85
86
87
88
89 public static ADSCCompiler getThumbCC() {
90 return tcc;
91 }
92
93
94
95
96 public static ADSCCompiler getThumbCpp() {
97 return tcpp;
98 }
99
100 private static void quoteFile(final StringBuffer buf, final String outPath) {
101 if (outPath.indexOf(' ') >= 0) {
102 buf.append('\"');
103 buf.append(outPath);
104 buf.append('\"');
105 } else {
106 buf.append(outPath);
107 }
108 }
109
110
111
112
113
114
115
116
117
118
119
120 private ADSCCompiler(final String command, final boolean newEnvironment, final Environment env) {
121 super(command, "-vsn", sourceExtensions, headerExtensions, ".o", false, null, newEnvironment, env);
122 }
123
124
125
126
127 @Override
128 protected void addImpliedArgs(final Vector<String> args, final boolean debug, final boolean multithreaded,
129 final boolean exceptions, final LinkType linkType, final Boolean rtti, final OptimizationEnum optimization) {
130 if (debug) {
131 args.addElement("-g");
132 }
133
134
135
136 if (linkType.isExecutable()) {
137 } else if (linkType.isSharedLibrary()) {
138 }
139 }
140
141
142
143
144
145
146
147
148
149
150
151 @Override
152 protected void addWarningSwitch(final Vector<String> args, final int warnings) {
153 }
154
155
156
157
158
159
160
161 @Override
162 protected void getDefineSwitch(final StringBuffer buffer, final String define, final String value) {
163 buffer.append("-D");
164 buffer.append(define);
165 if (value != null) {
166 buffer.append('=');
167 buffer.append(value);
168 }
169 }
170
171
172
173
174
175
176 @Override
177 protected File[] getEnvironmentIncludePath() {
178 return CUtil.getPathFromEnvironment("ARMINC", ";");
179 }
180
181
182
183
184
185 @Override
186 protected String getIncludeDirSwitch(final String source) {
187 final StringBuffer buf = new StringBuffer("-I");
188 quoteFile(buf, source);
189 return buf.toString();
190 }
191
192 @Override
193 public Linker getLinker(final LinkType type) {
194 if (type.isStaticLibrary()) {
195 return ADSLibrarian.getInstance();
196 }
197 if (type.isSharedLibrary()) {
198 return ADSLinker.getDllInstance();
199 }
200 return ADSLinker.getInstance();
201 }
202
203
204
205
206
207
208 @Override
209 public int getMaximumCommandLength() {
210 return 1000;
211 }
212
213
214 @Override
215 protected void getUndefineSwitch(final StringBuffer buffer, final String define) {
216 buffer.append("-U");
217 buffer.append(define);
218 }
219 }