Mercurial > hg > truffle
comparison src/share/tools/ProjectCreator/WinGammaPlatformVC7.java @ 6801:1a9b9cfcef41
7163863: Updated projectcreator
Summary: Enable source browsing for all platform dependent code
Reviewed-by: brutisso, coleenp
author | neliasso |
---|---|
date | Thu, 29 Mar 2012 16:43:21 +0200 |
parents | 74e790c48cd4 |
children | b9a9ed0f8eeb |
comparison
equal
deleted
inserted
replaced
6800:9191895df19d | 6801:1a9b9cfcef41 |
---|---|
23 */ | 23 */ |
24 | 24 |
25 import java.io.FileWriter; | 25 import java.io.FileWriter; |
26 import java.io.IOException; | 26 import java.io.IOException; |
27 import java.io.PrintWriter; | 27 import java.io.PrintWriter; |
28 import java.util.Hashtable; | 28 import java.nio.file.FileSystems; |
29 import java.util.Iterator; | |
30 import java.util.TreeSet; | |
31 import java.util.Vector; | 29 import java.util.Vector; |
32 | 30 |
33 public class WinGammaPlatformVC7 extends WinGammaPlatform { | 31 public class WinGammaPlatformVC7 extends WinGammaPlatform { |
34 | 32 |
35 String projectVersion() {return "7.10";}; | 33 // TODO How about moving all globals configs to its own BuildConfig? |
36 | 34 |
37 public void writeProjectFile(String projectFileName, String projectName, | 35 String projectVersion() { |
38 Vector<BuildConfig> allConfigs) throws IOException { | 36 return "7.10"; |
39 System.out.println(); | 37 }; |
40 System.out.println(" Writing .vcproj file: "+projectFileName); | 38 |
41 // If we got this far without an error, we're safe to actually | 39 public void writeProjectFile(String projectFileName, String projectName, |
42 // write the .vcproj file | 40 Vector<BuildConfig> allConfigs) throws IOException { |
43 printWriter = new PrintWriter(new FileWriter(projectFileName)); | 41 System.out.println(); |
44 | 42 System.out.println(" Writing .vcproj file: " + projectFileName); |
45 printWriter.println("<?xml version=\"1.0\" encoding=\"windows-1251\"?>"); | 43 // If we got this far without an error, we're safe to actually |
46 startTag( | 44 // write the .vcproj file |
47 "VisualStudioProject", | 45 printWriter = new PrintWriter(new FileWriter(projectFileName)); |
46 | |
47 printWriter | |
48 .println("<?xml version=\"1.0\" encoding=\"windows-1251\"?>"); | |
49 startTag("VisualStudioProject", new String[] { "ProjectType", | |
50 "Visual C++", "Version", projectVersion(), "Name", projectName, | |
51 "ProjectGUID", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}", | |
52 "SccProjectName", "", "SccLocalPath", "" }); | |
53 startTag("Platforms"); | |
54 tag("Platform", | |
55 new String[] { "Name", | |
56 (String) BuildConfig.getField(null, "PlatformName") }); | |
57 endTag(); | |
58 | |
59 startTag("Configurations"); | |
60 | |
61 for (BuildConfig cfg : allConfigs) { | |
62 writeConfiguration(cfg); | |
63 } | |
64 | |
65 endTag(); | |
66 | |
67 tag("References"); | |
68 | |
69 writeFiles(allConfigs); | |
70 | |
71 tag("Globals"); | |
72 | |
73 endTag(); | |
74 printWriter.close(); | |
75 | |
76 System.out.println(" Done."); | |
77 } | |
78 | |
79 void writeCustomToolConfig(Vector<BuildConfig> configs, String[] customToolAttrs) { | |
80 for (BuildConfig cfg : configs) { | |
81 startTag("FileConfiguration", | |
82 new String[] { "Name", (String) cfg.get("Name") }); | |
83 tag("Tool", customToolAttrs); | |
84 | |
85 endTag(); | |
86 } | |
87 } | |
88 | |
89 void writeFiles(Vector<BuildConfig> allConfigs) { | |
90 | |
91 // This code assummes there are no config specific includes. | |
92 startTag("Files"); | |
93 String sourceBase = BuildConfig.getFieldString(null, "SourceBase"); | |
94 | |
95 // Use first config for all global absolute includes. | |
96 BuildConfig baseConfig = allConfigs.firstElement(); | |
97 Vector<String> rv = new Vector<String>(); | |
98 | |
99 // Then use first config for all relative includes | |
100 Vector<String> ri = new Vector<String>(); | |
101 baseConfig.collectRelevantVectors(ri, "RelativeSrcInclude"); | |
102 for (String f : ri) { | |
103 rv.add(sourceBase + Util.sep + f); | |
104 } | |
105 | |
106 baseConfig.collectRelevantVectors(rv, "AbsoluteSrcInclude"); | |
107 | |
108 handleIncludes(rv, allConfigs); | |
109 | |
110 startTag("Filter", new String[] { "Name", "Resource Files", "Filter", | |
111 "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" }); | |
112 endTag(); | |
113 | |
114 endTag(); | |
115 } | |
116 | |
117 // Will visit file tree for each include | |
118 private void handleIncludes(Vector<String> includes, Vector<BuildConfig> allConfigs) { | |
119 for (String path : includes) { | |
120 FileTreeCreatorVC7 ftc = new FileTreeCreatorVC7(FileSystems.getDefault().getPath(path) , allConfigs, this); | |
121 try { | |
122 ftc.writeFileTree(); | |
123 } catch (IOException e) { | |
124 e.printStackTrace(); | |
125 } | |
126 } | |
127 } | |
128 | |
129 void writeConfiguration(BuildConfig cfg) { | |
130 startTag("Configuration", new String[] { "Name", cfg.get("Name"), | |
131 "OutputDirectory", cfg.get("OutputDir"), | |
132 "IntermediateDirectory", cfg.get("OutputDir"), | |
133 "ConfigurationType", "2", "UseOfMFC", "0", | |
134 "ATLMinimizesCRunTimeLibraryUsage", "FALSE" }); | |
135 | |
136 tagV("Tool", cfg.getV("CompilerFlags")); | |
137 | |
138 tag("Tool", new String[] { "Name", "VCCustomBuildTool" }); | |
139 | |
140 tagV("Tool", cfg.getV("LinkerFlags")); | |
141 | |
142 tag("Tool", | |
48 new String[] { | 143 new String[] { |
49 "ProjectType", "Visual C++", | 144 "Name", |
50 "Version", projectVersion(), | 145 "VCPostBuildEventTool", |
51 "Name", projectName, | 146 "Description", |
52 "ProjectGUID", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}", | 147 BuildConfig |
53 "SccProjectName", "", | 148 .getFieldString(null, "PostbuildDescription"), |
54 "SccLocalPath", "" | 149 // Caution: String.replace(String,String) is available |
55 } | 150 // from JDK5 onwards only |
56 ); | 151 "CommandLine", |
57 startTag("Platforms"); | 152 cfg.expandFormat(BuildConfig.getFieldString(null, |
58 tag("Platform", new String[] {"Name", (String) BuildConfig.getField(null, "PlatformName")}); | 153 "PostbuildCommand").replace("\t", |
59 endTag("Platforms"); | 154 "
")) }); |
60 | 155 |
61 startTag("Configurations"); | 156 tag("Tool", new String[] { "Name", "VCPreBuildEventTool" }); |
62 | 157 |
63 for (Iterator i = allConfigs.iterator(); i.hasNext(); ) { | 158 tag("Tool", |
64 writeConfiguration((BuildConfig)i.next()); | |
65 } | |
66 | |
67 endTag("Configurations"); | |
68 | |
69 tag("References"); | |
70 | |
71 writeFiles(allConfigs); | |
72 | |
73 tag("Globals"); | |
74 | |
75 endTag("VisualStudioProject"); | |
76 printWriter.close(); | |
77 | |
78 System.out.println(" Done."); | |
79 } | |
80 | |
81 | |
82 abstract class NameFilter { | |
83 protected String fname; | |
84 | |
85 abstract boolean match(FileInfo fi); | |
86 | |
87 String filterString() { return ""; } | |
88 String name() { return this.fname;} | |
89 | |
90 @Override | |
91 // eclipse auto-generated | |
92 public int hashCode() { | |
93 final int prime = 31; | |
94 int result = 1; | |
95 result = prime * result + getOuterType().hashCode(); | |
96 result = prime * result + ((fname == null) ? 0 : fname.hashCode()); | |
97 return result; | |
98 } | |
99 | |
100 @Override | |
101 // eclipse auto-generated | |
102 public boolean equals(Object obj) { | |
103 if (this == obj) | |
104 return true; | |
105 if (obj == null) | |
106 return false; | |
107 if (getClass() != obj.getClass()) | |
108 return false; | |
109 NameFilter other = (NameFilter) obj; | |
110 if (!getOuterType().equals(other.getOuterType())) | |
111 return false; | |
112 if (fname == null) { | |
113 if (other.fname != null) | |
114 return false; | |
115 } else if (!fname.equals(other.fname)) | |
116 return false; | |
117 return true; | |
118 } | |
119 | |
120 // eclipse auto-generated | |
121 private WinGammaPlatformVC7 getOuterType() { | |
122 return WinGammaPlatformVC7.this; | |
123 } | |
124 } | |
125 | |
126 class DirectoryFilter extends NameFilter { | |
127 String dir; | |
128 int baseLen, dirLen; | |
129 | |
130 DirectoryFilter(String dir, String sbase) { | |
131 this.dir = dir; | |
132 this.baseLen = sbase.length(); | |
133 this.dirLen = dir.length(); | |
134 this.fname = dir; | |
135 } | |
136 | |
137 DirectoryFilter(String fname, String dir, String sbase) { | |
138 this.dir = dir; | |
139 this.baseLen = sbase.length(); | |
140 this.dirLen = dir.length(); | |
141 this.fname = fname; | |
142 } | |
143 | |
144 | |
145 boolean match(FileInfo fi) { | |
146 int lastSlashIndex = fi.full.lastIndexOf('/'); | |
147 String fullDir = fi.full.substring(0, lastSlashIndex); | |
148 return fullDir.endsWith(dir); | |
149 } | |
150 | |
151 @Override | |
152 // eclipse auto-generated | |
153 public int hashCode() { | |
154 final int prime = 31; | |
155 int result = super.hashCode(); | |
156 result = prime * result + getOuterType().hashCode(); | |
157 result = prime * result + baseLen; | |
158 result = prime * result + ((dir == null) ? 0 : dir.hashCode()); | |
159 result = prime * result + dirLen; | |
160 return result; | |
161 } | |
162 | |
163 @Override | |
164 // eclipse auto-generated | |
165 public boolean equals(Object obj) { | |
166 if (this == obj) | |
167 return true; | |
168 if (!super.equals(obj)) | |
169 return false; | |
170 if (getClass() != obj.getClass()) | |
171 return false; | |
172 DirectoryFilter other = (DirectoryFilter) obj; | |
173 if (!getOuterType().equals(other.getOuterType())) | |
174 return false; | |
175 if (baseLen != other.baseLen) | |
176 return false; | |
177 if (dir == null) { | |
178 if (other.dir != null) | |
179 return false; | |
180 } else if (!dir.equals(other.dir)) | |
181 return false; | |
182 if (dirLen != other.dirLen) | |
183 return false; | |
184 return true; | |
185 } | |
186 | |
187 // eclipse auto-generated | |
188 private WinGammaPlatformVC7 getOuterType() { | |
189 return WinGammaPlatformVC7.this; | |
190 } | |
191 } | |
192 | |
193 class TerminatorFilter extends NameFilter { | |
194 TerminatorFilter(String fname) { | |
195 this.fname = fname; | |
196 | |
197 } | |
198 boolean match(FileInfo fi) { | |
199 return true; | |
200 } | |
201 | |
202 } | |
203 | |
204 class SpecificNameFilter extends NameFilter { | |
205 String pats[]; | |
206 | |
207 SpecificNameFilter(String fname, String[] pats) { | |
208 this.fname = fname; | |
209 this.pats = pats; | |
210 } | |
211 | |
212 boolean match(FileInfo fi) { | |
213 for (int i=0; i<pats.length; i++) { | |
214 if (fi.attr.shortName.matches(pats[i])) { | |
215 return true; | |
216 } | |
217 } | |
218 return false; | |
219 } | |
220 | |
221 } | |
222 | |
223 class SpecificPathFilter extends NameFilter { | |
224 String pats[]; | |
225 | |
226 SpecificPathFilter(String fname, String[] pats) { | |
227 this.fname = fname; | |
228 this.pats = pats; | |
229 } | |
230 | |
231 boolean match(FileInfo fi) { | |
232 for (int i=0; i<pats.length; i++) { | |
233 if (fi.full.matches(pats[i])) { | |
234 return true; | |
235 } | |
236 } | |
237 return false; | |
238 } | |
239 | |
240 } | |
241 | |
242 class ContainerFilter extends NameFilter { | |
243 Vector children; | |
244 | |
245 ContainerFilter(String fname) { | |
246 this.fname = fname; | |
247 children = new Vector(); | |
248 | |
249 } | |
250 boolean match(FileInfo fi) { | |
251 return false; | |
252 } | |
253 | |
254 Iterator babies() { return children.iterator(); } | |
255 | |
256 void add(NameFilter f) { | |
257 children.add(f); | |
258 } | |
259 } | |
260 | |
261 | |
262 void writeCustomToolConfig(Vector configs, String[] customToolAttrs) { | |
263 for (Iterator i = configs.iterator(); i.hasNext(); ) { | |
264 startTag("FileConfiguration", | |
265 new String[] { | |
266 "Name", (String)i.next() | |
267 } | |
268 ); | |
269 tag("Tool", customToolAttrs); | |
270 | |
271 endTag("FileConfiguration"); | |
272 } | |
273 } | |
274 | |
275 // here we define filters, which define layout of what can be seen in 'Solution View' of MSVC | |
276 // Basically there are two types of entities - container filters and real filters | |
277 // - container filter just provides a container to group together real filters | |
278 // - real filter can select elements from the set according to some rule, put it into XML | |
279 // and remove from the list | |
280 Vector<NameFilter> makeFilters(TreeSet<FileInfo> files) { | |
281 Vector<NameFilter> rv = new Vector<NameFilter>(); | |
282 String sbase = Util.normalize(BuildConfig.getFieldString(null, "SourceBase")+"/src/"); | |
283 | |
284 String currentDir = ""; | |
285 DirectoryFilter container = null; | |
286 for(FileInfo fileInfo : files) { | |
287 | |
288 if (!fileInfo.full.startsWith(sbase)) { | |
289 continue; | |
290 } | |
291 | |
292 int lastSlash = fileInfo.full.lastIndexOf('/'); | |
293 String dir = fileInfo.full.substring(sbase.length(), lastSlash); | |
294 if(dir.equals("share/vm")) { | |
295 // skip files directly in share/vm - should only be precompiled.hpp which is handled below | |
296 continue; | |
297 } | |
298 if (!dir.equals(currentDir)) { | |
299 currentDir = dir; | |
300 if (container != null && !rv.contains(container)) { | |
301 rv.add(container); | |
302 } | |
303 | |
304 // remove "share/vm/" from names | |
305 String name = dir; | |
306 if (dir.startsWith("share/vm/")) { | |
307 name = dir.substring("share/vm/".length(), dir.length()); | |
308 } | |
309 DirectoryFilter newfilter = new DirectoryFilter(name, dir, sbase); | |
310 int i = rv.indexOf(newfilter); | |
311 if(i == -1) { | |
312 container = newfilter; | |
313 } else { | |
314 // if the filter already exists, reuse it | |
315 container = (DirectoryFilter) rv.get(i); | |
316 } | |
317 } | |
318 } | |
319 if (container != null && !rv.contains(container)) { | |
320 rv.add(container); | |
321 } | |
322 | |
323 ContainerFilter generated = new ContainerFilter("Generated"); | |
324 ContainerFilter c1Generated = new ContainerFilter("C1"); | |
325 c1Generated.add(new SpecificPathFilter("C++ Interpreter Generated", new String[] {".*compiler1/generated/jvmtifiles/bytecodeInterpreterWithChecks.+"})); | |
326 c1Generated.add(new SpecificPathFilter("jvmtifiles", new String[] {".*compiler1/generated/jvmtifiles/.*"})); | |
327 generated.add(c1Generated); | |
328 ContainerFilter c2Generated = new ContainerFilter("C2"); | |
329 c2Generated.add(new SpecificPathFilter("C++ Interpreter Generated", new String[] {".*compiler2/generated/jvmtifiles/bytecodeInterpreterWithChecks.+"})); | |
330 c2Generated.add(new SpecificPathFilter("adfiles", new String[] {".*compiler2/generated/adfiles/.*"})); | |
331 c2Generated.add(new SpecificPathFilter("jvmtifiles", new String[] {".*compiler2/generated/jvmtifiles/.*"})); | |
332 generated.add(c2Generated); | |
333 ContainerFilter coreGenerated = new ContainerFilter("Core"); | |
334 coreGenerated.add(new SpecificPathFilter("C++ Interpreter Generated", new String[] {".*core/generated/jvmtifiles/bytecodeInterpreterWithChecks.+"})); | |
335 coreGenerated.add(new SpecificPathFilter("jvmtifiles", new String[] {".*core/generated/jvmtifiles/.*"})); | |
336 generated.add(coreGenerated); | |
337 ContainerFilter tieredGenerated = new ContainerFilter("Tiered"); | |
338 tieredGenerated.add(new SpecificPathFilter("C++ Interpreter Generated", new String[] {".*tiered/generated/jvmtifiles/bytecodeInterpreterWithChecks.+"})); | |
339 tieredGenerated.add(new SpecificPathFilter("adfiles", new String[] {".*tiered/generated/adfiles/.*"})); | |
340 tieredGenerated.add(new SpecificPathFilter("jvmtifiles", new String[] {".*tiered/generated/jvmtifiles/.*"})); | |
341 generated.add(tieredGenerated); | |
342 ContainerFilter kernelGenerated = new ContainerFilter("Kernel"); | |
343 kernelGenerated.add(new SpecificPathFilter("C++ Interpreter Generated", new String[] {".*kernel/generated/jvmtifiles/bytecodeInterpreterWithChecks.+"})); | |
344 kernelGenerated.add(new SpecificPathFilter("jvmtifiles", new String[] {".*kernel/generated/jvmtifiles/.*"})); | |
345 generated.add(kernelGenerated); | |
346 rv.add(generated); | |
347 | |
348 rv.add(new SpecificNameFilter("Precompiled Header", new String[] {"precompiled.hpp"})); | |
349 | |
350 // this one is to catch files not caught by other filters | |
351 rv.add(new TerminatorFilter("Source Files")); | |
352 | |
353 return rv; | |
354 } | |
355 | |
356 void writeFiles(Vector<BuildConfig> allConfigs) { | |
357 | |
358 Hashtable allFiles = computeAttributedFiles(allConfigs); | |
359 | |
360 Vector allConfigNames = new Vector(); | |
361 for (Iterator i = allConfigs.iterator(); i.hasNext(); ) { | |
362 allConfigNames.add(((BuildConfig)i.next()).get("Name")); | |
363 } | |
364 | |
365 TreeSet sortedFiles = sortFiles(allFiles); | |
366 | |
367 startTag("Files"); | |
368 | |
369 for (Iterator i = makeFilters(sortedFiles).iterator(); i.hasNext(); ) { | |
370 doWriteFiles(sortedFiles, allConfigNames, (NameFilter)i.next()); | |
371 } | |
372 | |
373 | |
374 startTag("Filter", | |
375 new String[] { | |
376 "Name", "Resource Files", | |
377 "Filter", "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" | |
378 } | |
379 ); | |
380 endTag("Filter"); | |
381 | |
382 endTag("Files"); | |
383 } | |
384 | |
385 void doWriteFiles(TreeSet allFiles, Vector allConfigNames, NameFilter filter) { | |
386 startTag("Filter", | |
387 new String[] { | |
388 "Name", filter.name(), | |
389 "Filter", filter.filterString() | |
390 } | |
391 ); | |
392 | |
393 if (filter instanceof ContainerFilter) { | |
394 | |
395 Iterator i = ((ContainerFilter)filter).babies(); | |
396 while (i.hasNext()) { | |
397 doWriteFiles(allFiles, allConfigNames, (NameFilter)i.next()); | |
398 } | |
399 | |
400 } else { | |
401 | |
402 Iterator i = allFiles.iterator(); | |
403 while (i.hasNext()) { | |
404 FileInfo fi = (FileInfo)i.next(); | |
405 | |
406 if (!filter.match(fi)) { | |
407 continue; | |
408 } | |
409 | |
410 startTag("File", | |
411 new String[] { | |
412 "RelativePath", fi.full.replace('/', '\\') | |
413 } | |
414 ); | |
415 | |
416 FileAttribute a = fi.attr; | |
417 if (a.pchRoot) { | |
418 writeCustomToolConfig(allConfigNames, | |
419 new String[] { | |
420 "Name", "VCCLCompilerTool", | |
421 "UsePrecompiledHeader", "1" | |
422 }); | |
423 } | |
424 | |
425 if (a.noPch) { | |
426 writeCustomToolConfig(allConfigNames, | |
427 new String[] { | |
428 "Name", "VCCLCompilerTool", | |
429 "UsePrecompiledHeader", "0" | |
430 }); | |
431 } | |
432 | |
433 if (a.configs != null) { | |
434 for (Iterator j=allConfigNames.iterator(); j.hasNext();) { | |
435 String cfg = (String)j.next(); | |
436 if (!a.configs.contains(cfg)) { | |
437 startTag("FileConfiguration", | |
438 new String[] { | |
439 "Name", cfg, | |
440 "ExcludedFromBuild", "TRUE" | |
441 }); | |
442 endTag("FileConfiguration"); | |
443 | |
444 } | |
445 } | |
446 } | |
447 | |
448 endTag("File"); | |
449 | |
450 // we not gonna look at this file anymore | |
451 i.remove(); | |
452 } | |
453 } | |
454 | |
455 endTag("Filter"); | |
456 } | |
457 | |
458 | |
459 void writeConfiguration(BuildConfig cfg) { | |
460 startTag("Configuration", | |
461 new String[] { | |
462 "Name", cfg.get("Name"), | |
463 "OutputDirectory", cfg.get("OutputDir"), | |
464 "IntermediateDirectory", cfg.get("OutputDir"), | |
465 "ConfigurationType", "2", | |
466 "UseOfMFC", "0", | |
467 "ATLMinimizesCRunTimeLibraryUsage", "FALSE" | |
468 } | |
469 ); | |
470 | |
471 | |
472 | |
473 tagV("Tool", cfg.getV("CompilerFlags")); | |
474 | |
475 tag("Tool", | |
476 new String[] { | 159 new String[] { |
477 "Name", "VCCustomBuildTool" | 160 "Name", |
478 } | 161 "VCPreLinkEventTool", |
479 ); | 162 "Description", |
480 | 163 BuildConfig.getFieldString(null, "PrelinkDescription"), |
481 tagV("Tool", cfg.getV("LinkerFlags")); | 164 // Caution: String.replace(String,String) is available |
482 | 165 // from JDK5 onwards only |
483 tag("Tool", | 166 "CommandLine", |
484 new String[] { | 167 cfg.expandFormat(BuildConfig.getFieldString(null, |
485 "Name", "VCPostBuildEventTool", | 168 "PrelinkCommand").replace("\t", "
")) }); |
486 "Description", BuildConfig.getFieldString(null, "PostbuildDescription"), | 169 |
487 //Caution: String.replace(String,String) is available from JDK5 onwards only | 170 tag("Tool", new String[] { "Name", "VCResourceCompilerTool", |
488 "CommandLine", cfg.expandFormat(BuildConfig.getFieldString(null, "PostbuildCommand").replace | 171 "PreprocessorDefinitions", "NDEBUG", "Culture", "1033" }); |
489 ("\t", "
")) | 172 |
490 } | 173 tag("Tool", new String[] { "Name", "VCMIDLTool", |
491 ); | 174 "PreprocessorDefinitions", "NDEBUG", "MkTypLibCompatible", |
492 | 175 "TRUE", "SuppressStartupBanner", "TRUE", "TargetEnvironment", |
493 tag("Tool", | 176 "1", "TypeLibraryName", |
494 new String[] { | 177 cfg.get("OutputDir") + Util.sep + "vm.tlb", "HeaderFileName", |
495 "Name", "VCPreBuildEventTool" | 178 "" }); |
496 } | 179 |
497 ); | 180 endTag(); |
498 | 181 } |
499 tag("Tool", | 182 |
500 new String[] { | 183 |
501 "Name", "VCPreLinkEventTool", | 184 |
502 "Description", BuildConfig.getFieldString(null, "PrelinkDescription"), | 185 protected String getProjectExt() { |
503 //Caution: String.replace(String,String) is available from JDK5 onwards only | 186 return ".vcproj"; |
504 "CommandLine", cfg.expandFormat(BuildConfig.getFieldString(null, "PrelinkCommand").replace | 187 } |
505 ("\t", "
")) | |
506 } | |
507 ); | |
508 | |
509 tag("Tool", | |
510 new String[] { | |
511 "Name", "VCResourceCompilerTool", | |
512 // XXX??? | |
513 "PreprocessorDefinitions", "NDEBUG", | |
514 "Culture", "1033" | |
515 } | |
516 ); | |
517 | |
518 tag("Tool", | |
519 new String[] { | |
520 "Name", "VCMIDLTool", | |
521 "PreprocessorDefinitions", "NDEBUG", | |
522 "MkTypLibCompatible", "TRUE", | |
523 "SuppressStartupBanner", "TRUE", | |
524 "TargetEnvironment", "1", | |
525 "TypeLibraryName", cfg.get("OutputDir") + Util.sep + "vm.tlb", | |
526 "HeaderFileName", "" | |
527 } | |
528 ); | |
529 | |
530 endTag("Configuration"); | |
531 } | |
532 | |
533 int indent; | |
534 | |
535 private void startTagPrim(String name, | |
536 String[] attrs, | |
537 boolean close) { | |
538 startTagPrim(name, attrs, close, true); | |
539 } | |
540 | |
541 private void startTagPrim(String name, | |
542 String[] attrs, | |
543 boolean close, | |
544 boolean newline) { | |
545 doIndent(); | |
546 printWriter.print("<"+name); | |
547 indent++; | |
548 | |
549 if (attrs != null && attrs.length > 0) { | |
550 for (int i=0; i<attrs.length; i+=2) { | |
551 printWriter.print(" " + attrs[i]+"=\""+attrs[i+1]+"\""); | |
552 if (i < attrs.length - 2) { | |
553 } | |
554 } | |
555 } | |
556 | |
557 if (close) { | |
558 indent--; | |
559 printWriter.print(" />"); | |
560 } else { | |
561 printWriter.print(">"); | |
562 } | |
563 if(newline) { | |
564 printWriter.println(); | |
565 } | |
566 } | |
567 | |
568 void startTag(String name, String... attrs) { | |
569 startTagPrim(name, attrs, false); | |
570 } | |
571 | |
572 void startTagV(String name, Vector attrs) { | |
573 String s[] = new String [attrs.size()]; | |
574 for (int i=0; i<attrs.size(); i++) { | |
575 s[i] = (String)attrs.elementAt(i); | |
576 } | |
577 startTagPrim(name, s, false); | |
578 } | |
579 | |
580 void endTag(String name) { | |
581 indent--; | |
582 doIndent(); | |
583 printWriter.println("</"+name+">"); | |
584 } | |
585 | |
586 void tag(String name, String... attrs) { | |
587 startTagPrim(name, attrs, true); | |
588 } | |
589 | |
590 void tagData(String name, String data) { | |
591 doIndent(); | |
592 printWriter.print("<"+name+">"); | |
593 printWriter.print(data); | |
594 printWriter.println("</"+name+">"); | |
595 } | |
596 | |
597 void tagData(String name, String data, String... attrs) { | |
598 startTagPrim(name, attrs, false, false); | |
599 printWriter.print(data); | |
600 printWriter.println("</"+name+">"); | |
601 indent--; | |
602 } | |
603 | |
604 void tagV(String name, Vector attrs) { | |
605 String s[] = new String [attrs.size()]; | |
606 for (int i=0; i<attrs.size(); i++) { | |
607 s[i] = (String)attrs.elementAt(i); | |
608 } | |
609 startTagPrim(name, s, true); | |
610 } | |
611 | |
612 | |
613 void doIndent() { | |
614 for (int i=0; i<indent; i++) { | |
615 printWriter.print(" "); | |
616 } | |
617 } | |
618 | |
619 protected String getProjectExt() { | |
620 return ".vcproj"; | |
621 } | |
622 } | 188 } |
623 | 189 |
624 class CompilerInterfaceVC7 extends CompilerInterface { | 190 class CompilerInterfaceVC7 extends CompilerInterface { |
625 void getBaseCompilerFlags_common(Vector defines, Vector includes, String outDir,Vector rv) { | 191 void getBaseCompilerFlags_common(Vector defines, Vector includes, |
626 | 192 String outDir, Vector rv) { |
627 // advanced M$ IDE (2003) can only recognize name if it's first or | 193 |
628 // second attribute in the tag - go guess | 194 // advanced M$ IDE (2003) can only recognize name if it's first or |
629 addAttr(rv, "Name", "VCCLCompilerTool"); | 195 // second attribute in the tag - go guess |
630 addAttr(rv, "AdditionalIncludeDirectories", Util.join(",", includes)); | 196 addAttr(rv, "Name", "VCCLCompilerTool"); |
631 addAttr(rv, "PreprocessorDefinitions", | 197 addAttr(rv, "AdditionalIncludeDirectories", Util.join(",", includes)); |
632 Util.join(";", defines).replace("\"",""")); | 198 addAttr(rv, "PreprocessorDefinitions", |
633 addAttr(rv, "PrecompiledHeaderThrough", "precompiled.hpp"); | 199 Util.join(";", defines).replace("\"", """)); |
634 addAttr(rv, "PrecompiledHeaderFile", outDir+Util.sep+"vm.pch"); | 200 addAttr(rv, "PrecompiledHeaderThrough", "precompiled.hpp"); |
635 addAttr(rv, "AssemblerListingLocation", outDir); | 201 addAttr(rv, "PrecompiledHeaderFile", outDir + Util.sep + "vm.pch"); |
636 addAttr(rv, "ObjectFile", outDir+Util.sep); | 202 addAttr(rv, "AssemblerListingLocation", outDir); |
637 addAttr(rv, "ProgramDataBaseFileName", outDir+Util.sep+"jvm.pdb"); | 203 addAttr(rv, "ObjectFile", outDir + Util.sep); |
638 // Set /nologo optin | 204 addAttr(rv, "ProgramDataBaseFileName", outDir + Util.sep + "jvm.pdb"); |
639 addAttr(rv, "SuppressStartupBanner", "TRUE"); | 205 // Set /nologo optin |
640 // Surpass the default /Tc or /Tp. 0 is compileAsDefault | 206 addAttr(rv, "SuppressStartupBanner", "TRUE"); |
641 addAttr(rv, "CompileAs", "0"); | 207 // Surpass the default /Tc or /Tp. 0 is compileAsDefault |
642 // Set /W3 option. 3 is warningLevel_3 | 208 addAttr(rv, "CompileAs", "0"); |
643 addAttr(rv, "WarningLevel", "3"); | 209 // Set /W3 option. 3 is warningLevel_3 |
644 // Set /WX option, | 210 addAttr(rv, "WarningLevel", "3"); |
645 addAttr(rv, "WarnAsError", "TRUE"); | 211 // Set /WX option, |
646 // Set /GS option | 212 addAttr(rv, "WarnAsError", "TRUE"); |
647 addAttr(rv, "BufferSecurityCheck", "FALSE"); | 213 // Set /GS option |
648 // Set /Zi option. 3 is debugEnabled | 214 addAttr(rv, "BufferSecurityCheck", "FALSE"); |
649 addAttr(rv, "DebugInformationFormat", "3"); | 215 // Set /Zi option. 3 is debugEnabled |
650 } | 216 addAttr(rv, "DebugInformationFormat", "3"); |
651 Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir) { | 217 } |
652 Vector rv = new Vector(); | 218 |
653 | 219 Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir) { |
654 getBaseCompilerFlags_common(defines,includes, outDir, rv); | 220 Vector rv = new Vector(); |
655 // Set /Yu option. 3 is pchUseUsingSpecific | 221 |
656 // Note: Starting VC8 pchUseUsingSpecific is 2 !!! | 222 getBaseCompilerFlags_common(defines, includes, outDir, rv); |
657 addAttr(rv, "UsePrecompiledHeader", "3"); | 223 // Set /Yu option. 3 is pchUseUsingSpecific |
658 // Set /EHsc- option | 224 // Note: Starting VC8 pchUseUsingSpecific is 2 !!! |
659 addAttr(rv, "ExceptionHandling", "FALSE"); | 225 addAttr(rv, "UsePrecompiledHeader", "3"); |
660 | 226 // Set /EHsc- option |
661 return rv; | 227 addAttr(rv, "ExceptionHandling", "FALSE"); |
662 } | 228 |
663 | 229 return rv; |
664 Vector getBaseLinkerFlags(String outDir, String outDll, String platformName) { | 230 } |
665 Vector rv = new Vector(); | 231 |
666 | 232 Vector getBaseLinkerFlags(String outDir, String outDll, String platformName) { |
667 addAttr(rv, "Name", "VCLinkerTool"); | 233 Vector rv = new Vector(); |
668 addAttr(rv, "AdditionalOptions", | 234 |
669 "/export:JNI_GetDefaultJavaVMInitArgs " + | 235 addAttr(rv, "Name", "VCLinkerTool"); |
670 "/export:JNI_CreateJavaVM " + | 236 addAttr(rv, "AdditionalOptions", |
671 "/export:JVM_FindClassFromBootLoader "+ | 237 "/export:JNI_GetDefaultJavaVMInitArgs " |
672 "/export:JNI_GetCreatedJavaVMs "+ | 238 + "/export:JNI_CreateJavaVM " |
673 "/export:jio_snprintf /export:jio_printf "+ | 239 + "/export:JVM_FindClassFromBootLoader " |
674 "/export:jio_fprintf /export:jio_vfprintf "+ | 240 + "/export:JNI_GetCreatedJavaVMs " |
675 "/export:jio_vsnprintf "+ | 241 + "/export:jio_snprintf /export:jio_printf " |
676 "/export:JVM_GetVersionInfo "+ | 242 + "/export:jio_fprintf /export:jio_vfprintf " |
677 "/export:JVM_GetThreadStateNames "+ | 243 + "/export:jio_vsnprintf " |
678 "/export:JVM_GetThreadStateValues "+ | 244 + "/export:JVM_GetVersionInfo " |
679 "/export:JVM_InitAgentProperties "); | 245 + "/export:JVM_GetThreadStateNames " |
680 addAttr(rv, "AdditionalDependencies", "Wsock32.lib winmm.lib"); | 246 + "/export:JVM_GetThreadStateValues " |
681 addAttr(rv, "OutputFile", outDll); | 247 + "/export:JVM_InitAgentProperties "); |
682 // Set /INCREMENTAL option. 1 is linkIncrementalNo | 248 addAttr(rv, "AdditionalDependencies", "Wsock32.lib winmm.lib"); |
683 addAttr(rv, "LinkIncremental", "1"); | 249 addAttr(rv, "OutputFile", outDll); |
684 addAttr(rv, "SuppressStartupBanner", "TRUE"); | 250 // Set /INCREMENTAL option. 1 is linkIncrementalNo |
685 addAttr(rv, "ModuleDefinitionFile", outDir+Util.sep+"vm.def"); | 251 addAttr(rv, "LinkIncremental", "1"); |
686 addAttr(rv, "ProgramDatabaseFile", outDir+Util.sep+"jvm.pdb"); | 252 addAttr(rv, "SuppressStartupBanner", "TRUE"); |
687 // Set /SUBSYSTEM option. 2 is subSystemWindows | 253 addAttr(rv, "ModuleDefinitionFile", outDir + Util.sep + "vm.def"); |
688 addAttr(rv, "SubSystem", "2"); | 254 addAttr(rv, "ProgramDatabaseFile", outDir + Util.sep + "jvm.pdb"); |
689 addAttr(rv, "BaseAddress", "0x8000000"); | 255 // Set /SUBSYSTEM option. 2 is subSystemWindows |
690 addAttr(rv, "ImportLibrary", outDir+Util.sep+"jvm.lib"); | 256 addAttr(rv, "SubSystem", "2"); |
691 if(platformName.equals("Win32")) { | 257 addAttr(rv, "BaseAddress", "0x8000000"); |
692 // Set /MACHINE option. 1 is X86 | 258 addAttr(rv, "ImportLibrary", outDir + Util.sep + "jvm.lib"); |
693 addAttr(rv, "TargetMachine", "1"); | 259 if (platformName.equals("Win32")) { |
694 } else { | 260 // Set /MACHINE option. 1 is X86 |
695 // Set /MACHINE option. 17 is X64 | 261 addAttr(rv, "TargetMachine", "1"); |
696 addAttr(rv, "TargetMachine", "17"); | 262 } else { |
697 } | 263 // Set /MACHINE option. 17 is X64 |
698 | 264 addAttr(rv, "TargetMachine", "17"); |
699 return rv; | 265 } |
700 } | 266 |
701 | 267 return rv; |
702 void getDebugCompilerFlags_common(String opt,Vector rv) { | 268 } |
703 | 269 |
704 // Set /On option | 270 void getDebugCompilerFlags_common(String opt, Vector rv) { |
705 addAttr(rv, "Optimization", opt); | 271 |
706 // Set /FR option. 1 is brAllInfo | 272 // Set /On option |
707 addAttr(rv, "BrowseInformation", "1"); | 273 addAttr(rv, "Optimization", opt); |
708 addAttr(rv, "BrowseInformationFile", "$(IntDir)" + Util.sep); | 274 // Set /FR option. 1 is brAllInfo |
709 // Set /MD option. 2 is rtMultiThreadedDLL | 275 addAttr(rv, "BrowseInformation", "1"); |
710 addAttr(rv, "RuntimeLibrary", "2"); | 276 addAttr(rv, "BrowseInformationFile", "$(IntDir)" + Util.sep); |
711 // Set /Oy- option | 277 // Set /MD option. 2 is rtMultiThreadedDLL |
712 addAttr(rv, "OmitFramePointers", "FALSE"); | 278 addAttr(rv, "RuntimeLibrary", "2"); |
713 | 279 // Set /Oy- option |
714 } | 280 addAttr(rv, "OmitFramePointers", "FALSE"); |
715 | 281 |
716 Vector getDebugCompilerFlags(String opt) { | 282 } |
717 Vector rv = new Vector(); | 283 |
718 | 284 Vector getDebugCompilerFlags(String opt) { |
719 getDebugCompilerFlags_common(opt,rv); | 285 Vector rv = new Vector(); |
720 | 286 |
721 return rv; | 287 getDebugCompilerFlags_common(opt, rv); |
722 } | 288 |
723 | 289 return rv; |
724 Vector getDebugLinkerFlags() { | 290 } |
725 Vector rv = new Vector(); | 291 |
726 | 292 Vector getDebugLinkerFlags() { |
727 addAttr(rv, "GenerateDebugInformation", "TRUE"); // == /DEBUG option | 293 Vector rv = new Vector(); |
728 | 294 |
729 return rv; | 295 addAttr(rv, "GenerateDebugInformation", "TRUE"); // == /DEBUG option |
730 } | 296 |
731 | 297 return rv; |
732 void getAdditionalNonKernelLinkerFlags(Vector rv) { | 298 } |
733 extAttr(rv, "AdditionalOptions", | 299 |
734 "/export:AsyncGetCallTrace "); | 300 void getAdditionalNonKernelLinkerFlags(Vector rv) { |
735 } | 301 extAttr(rv, "AdditionalOptions", "/export:AsyncGetCallTrace "); |
736 | 302 } |
737 void getProductCompilerFlags_common(Vector rv) { | 303 |
738 // Set /O2 option. 2 is optimizeMaxSpeed | 304 void getProductCompilerFlags_common(Vector rv) { |
739 addAttr(rv, "Optimization", "2"); | 305 // Set /O2 option. 2 is optimizeMaxSpeed |
740 // Set /Oy- option | 306 addAttr(rv, "Optimization", "2"); |
741 addAttr(rv, "OmitFramePointers", "FALSE"); | 307 // Set /Oy- option |
742 // Set /Ob option. 1 is expandOnlyInline | 308 addAttr(rv, "OmitFramePointers", "FALSE"); |
743 addAttr(rv, "InlineFunctionExpansion", "1"); | 309 // Set /Ob option. 1 is expandOnlyInline |
744 // Set /GF option. | 310 addAttr(rv, "InlineFunctionExpansion", "1"); |
745 addAttr(rv, "StringPooling", "TRUE"); | 311 // Set /GF option. |
746 // Set /MD option. 2 is rtMultiThreadedDLL | 312 addAttr(rv, "StringPooling", "TRUE"); |
747 addAttr(rv, "RuntimeLibrary", "2"); | 313 // Set /MD option. 2 is rtMultiThreadedDLL |
748 // Set /Gy option | 314 addAttr(rv, "RuntimeLibrary", "2"); |
749 addAttr(rv, "EnableFunctionLevelLinking", "TRUE"); | 315 // Set /Gy option |
750 } | 316 addAttr(rv, "EnableFunctionLevelLinking", "TRUE"); |
751 | 317 } |
752 Vector getProductCompilerFlags() { | 318 |
753 Vector rv = new Vector(); | 319 Vector getProductCompilerFlags() { |
754 | 320 Vector rv = new Vector(); |
755 getProductCompilerFlags_common(rv); | 321 |
756 | 322 getProductCompilerFlags_common(rv); |
757 return rv; | 323 |
758 } | 324 return rv; |
759 | 325 } |
760 Vector getProductLinkerFlags() { | 326 |
761 Vector rv = new Vector(); | 327 Vector getProductLinkerFlags() { |
762 | 328 Vector rv = new Vector(); |
763 // Set /OPT:REF option. 2 is optReferences | 329 |
764 addAttr(rv, "OptimizeReferences", "2"); | 330 // Set /OPT:REF option. 2 is optReferences |
765 // Set /OPT:optFolding option. 2 is optFolding | 331 addAttr(rv, "OptimizeReferences", "2"); |
766 addAttr(rv, "EnableCOMDATFolding", "2"); | 332 // Set /OPT:optFolding option. 2 is optFolding |
767 | 333 addAttr(rv, "EnableCOMDATFolding", "2"); |
768 return rv; | 334 |
769 } | 335 return rv; |
770 | 336 } |
771 String getOptFlag() { | 337 |
772 return "2"; | 338 String getOptFlag() { |
773 } | 339 return "2"; |
774 | 340 } |
775 String getNoOptFlag() { | 341 |
776 return "0"; | 342 String getNoOptFlag() { |
777 } | 343 return "0"; |
778 | 344 } |
779 String makeCfgName(String flavourBuild, String platform) { | 345 |
780 return flavourBuild + "|" + platform; | 346 String makeCfgName(String flavourBuild, String platform) { |
781 } | 347 return flavourBuild + "|" + platform; |
348 } | |
349 | |
782 } | 350 } |