comparison src/share/tools/MakeDeps/WinGammaPlatformVC7.java @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children 520d43965b1f
comparison
equal deleted inserted replaced
-1:000000000000 0:a61af66fc99e
1 /*
2 * Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
23 */
24
25 import java.io.*;
26 import java.util.*;
27
28 public class WinGammaPlatformVC7 extends WinGammaPlatform {
29
30 public void writeProjectFile(String projectFileName, String projectName,
31 Vector allConfigs) throws IOException {
32 System.out.println();
33 System.out.println(" Writing .vcproj file...");
34 // If we got this far without an error, we're safe to actually
35 // write the .vcproj file
36 printWriter = new PrintWriter(new FileWriter(projectFileName));
37
38 printWriter.println("<?xml version=\"1.0\" encoding=\"windows-1251\"?>");
39 startTag(
40 "VisualStudioProject",
41 new String[] {
42 "ProjectType", "Visual C++",
43 "Version", "7.10",
44 "Name", projectName,
45 "ProjectGUID", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}",
46 "SccProjectName", "",
47 "SccLocalPath", ""
48 }
49 );
50
51 startTag("Platforms", null);
52 tag("Platform", new String[] {"Name", Util.os});
53 endTag("Platforms");
54
55 startTag("Configurations", null);
56
57 for (Iterator i = allConfigs.iterator(); i.hasNext(); ) {
58 writeConfiguration((BuildConfig)i.next());
59 }
60
61 endTag("Configurations");
62
63 tag("References", null);
64
65 writeFiles(allConfigs);
66
67 tag("Globals", null);
68
69 endTag("VisualStudioProject");
70 printWriter.close();
71
72 System.out.println(" Done.");
73 }
74
75
76 abstract class NameFilter {
77 protected String fname;
78
79 abstract boolean match(FileInfo fi);
80
81 String filterString() { return ""; }
82 String name() { return this.fname;}
83 }
84
85 class DirectoryFilter extends NameFilter {
86 String dir;
87 int baseLen, dirLen;
88
89 DirectoryFilter(String dir, String sbase) {
90 this.dir = dir;
91 this.baseLen = sbase.length();
92 this.dirLen = dir.length();
93 this.fname = dir;
94 }
95
96 DirectoryFilter(String fname, String dir, String sbase) {
97 this.dir = dir;
98 this.baseLen = sbase.length();
99 this.dirLen = dir.length();
100 this.fname = fname;
101 }
102
103
104 boolean match(FileInfo fi) {
105 return fi.full.regionMatches(true, baseLen, dir, 0, dirLen);
106 }
107 }
108
109 class TypeFilter extends NameFilter {
110 String[] exts;
111
112 TypeFilter(String fname, String[] exts) {
113 this.fname = fname;
114 this.exts = exts;
115 }
116
117 boolean match(FileInfo fi) {
118 for (int i=0; i<exts.length; i++) {
119 if (fi.full.endsWith(exts[i])) {
120 return true;
121 }
122 }
123 return false;
124 }
125
126 String filterString() {
127 return Util.join(";", exts);
128 }
129 }
130
131 class TerminatorFilter extends NameFilter {
132 TerminatorFilter(String fname) {
133 this.fname = fname;
134
135 }
136 boolean match(FileInfo fi) {
137 return true;
138 }
139
140 }
141
142 class SpecificNameFilter extends NameFilter {
143 String pats[];
144
145 SpecificNameFilter(String fname, String[] pats) {
146 this.fname = fname;
147 this.pats = pats;
148 }
149
150 boolean match(FileInfo fi) {
151 for (int i=0; i<pats.length; i++) {
152 if (fi.attr.shortName.matches(pats[i])) {
153 return true;
154 }
155 }
156 return false;
157 }
158
159 }
160
161 class ContainerFilter extends NameFilter {
162 Vector children;
163
164 ContainerFilter(String fname) {
165 this.fname = fname;
166 children = new Vector();
167
168 }
169 boolean match(FileInfo fi) {
170 return false;
171 }
172
173 Iterator babies() { return children.iterator(); }
174
175 void add(NameFilter f) {
176 children.add(f);
177 }
178 }
179
180
181 void writeCustomToolConfig(Vector configs, String[] customToolAttrs) {
182 for (Iterator i = configs.iterator(); i.hasNext(); ) {
183 startTag("FileConfiguration",
184 new String[] {
185 "Name", (String)i.next()
186 }
187 );
188 tag("Tool", customToolAttrs);
189
190 endTag("FileConfiguration");
191 }
192 }
193
194 // here we define filters, which define layout of what can be seen in 'Solution View' of MSVC
195 // Basically there are two types of entities - container filters and real filters
196 // - container filter just provides a container to group together real filters
197 // - real filter can select elements from the set according to some rule, put it into XML
198 // and remove from the list
199 Vector makeFilters(TreeSet files) {
200 Vector rv = new Vector();
201 String sbase = Util.normalize(BuildConfig.getFieldString(null, "SourceBase")+"/src/");
202
203 ContainerFilter rt = new ContainerFilter("Runtime");
204 rt.add(new DirectoryFilter("share/vm/prims", sbase));
205 rt.add(new DirectoryFilter("share/vm/runtime", sbase));
206 rt.add(new DirectoryFilter("share/vm/oops", sbase));
207 rv.add(rt);
208
209 ContainerFilter gc = new ContainerFilter("GC");
210 gc.add(new DirectoryFilter("share/vm/memory", sbase));
211 gc.add(new DirectoryFilter("share/vm/gc_interface", sbase));
212
213 ContainerFilter gc_impl = new ContainerFilter("Implementations");
214 gc_impl.add(new DirectoryFilter("CMS",
215 "share/vm/gc_implementation/concurrentMarkSweep",
216 sbase));
217 gc_impl.add(new DirectoryFilter("Parallel Scavenge",
218 "share/vm/gc_implementation/parallelScavenge",
219 sbase));
220 gc_impl.add(new DirectoryFilter("Shared",
221 "share/vm/gc_implementation/shared",
222 sbase));
223 // for all leftovers
224 gc_impl.add(new DirectoryFilter("Misc",
225 "share/vm/gc_implementation",
226 sbase));
227
228 gc.add(gc_impl);
229 rv.add(gc);
230
231 rv.add(new DirectoryFilter("C1", "share/vm/c1", sbase));
232
233 ContainerFilter c2 = new ContainerFilter("C2");
234 //c2.add(new DirectoryFilter("share/vm/adlc", sbase));
235 c2.add(new DirectoryFilter("share/vm/opto", sbase));
236 c2.add(new SpecificNameFilter("Generated", new String[] {"^ad_.+", "^dfa_.+", "^adGlobals.+"}));
237 rv.add(c2);
238
239 ContainerFilter comp = new ContainerFilter("Compiler Common");
240 comp.add(new DirectoryFilter("share/vm/asm", sbase));
241 comp.add(new DirectoryFilter("share/vm/ci", sbase));
242 comp.add(new DirectoryFilter("share/vm/code", sbase));
243 comp.add(new DirectoryFilter("share/vm/compiler", sbase));
244 rv.add(comp);
245
246 rv.add(new DirectoryFilter("Interpreter",
247 "share/vm/interpreter",
248 sbase));
249
250 ContainerFilter misc = new ContainerFilter("Misc");
251 //misc.add(new DirectoryFilter("share/vm/launch", sbase));
252 misc.add(new DirectoryFilter("share/vm/libadt", sbase));
253 misc.add(new DirectoryFilter("share/vm/services", sbase));
254 misc.add(new DirectoryFilter("share/vm/utilities", sbase));
255 rv.add(misc);
256
257 rv.add(new DirectoryFilter("os_cpu", sbase));
258
259 rv.add(new DirectoryFilter("cpu", sbase));
260
261 rv.add(new DirectoryFilter("os", sbase));
262
263 rv.add(new SpecificNameFilter("JVMTI Generated", new String[] {"^jvmti.+"}));
264
265 rv.add(new SpecificNameFilter("C++ Interpreter Generated", new String[] {"^bytecodeInterpreterWithChecks.+"}));
266
267 rv.add(new SpecificNameFilter("Include DBs", new String[] {"^includeDB_.+"}));
268
269 // this one is to catch files not caught by other filters
270 //rv.add(new TypeFilter("Header Files", new String[] {"h", "hpp", "hxx", "hm", "inl", "fi", "fd"}));
271 rv.add(new TerminatorFilter("Source Files"));
272
273 return rv;
274 }
275
276 void writeFiles(Vector allConfigs) {
277
278 Hashtable allFiles = computeAttributedFiles(allConfigs);
279
280 Vector allConfigNames = new Vector();
281 for (Iterator i = allConfigs.iterator(); i.hasNext(); ) {
282 allConfigNames.add(((BuildConfig)i.next()).get("Name"));
283 }
284
285 TreeSet sortedFiles = sortFiles(allFiles);
286
287 startTag("Files", null);
288
289 for (Iterator i = makeFilters(sortedFiles).iterator(); i.hasNext(); ) {
290 doWriteFiles(sortedFiles, allConfigNames, (NameFilter)i.next());
291 }
292
293
294 startTag("Filter",
295 new String[] {
296 "Name", "Resource Files",
297 "Filter", "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
298 }
299 );
300 endTag("Filter");
301
302 endTag("Files");
303 }
304
305 void doWriteFiles(TreeSet allFiles, Vector allConfigNames, NameFilter filter) {
306 startTag("Filter",
307 new String[] {
308 "Name", filter.name(),
309 "Filter", filter.filterString()
310 }
311 );
312
313 if (filter instanceof ContainerFilter) {
314
315 Iterator i = ((ContainerFilter)filter).babies();
316 while (i.hasNext()) {
317 doWriteFiles(allFiles, allConfigNames, (NameFilter)i.next());
318 }
319
320 } else {
321
322 Iterator i = allFiles.iterator();
323 while (i.hasNext()) {
324 FileInfo fi = (FileInfo)i.next();
325
326 if (!filter.match(fi)) {
327 continue;
328 }
329
330 startTag("File",
331 new String[] {
332 "RelativePath", fi.full.replace('/', '\\')
333 }
334 );
335
336 FileAttribute a = fi.attr;
337 if (a.pchRoot) {
338 writeCustomToolConfig(allConfigNames,
339 new String[] {
340 "Name", "VCCLCompilerTool",
341 "UsePrecompiledHeader", "1"
342 });
343 }
344
345 if (a.noPch) {
346 writeCustomToolConfig(allConfigNames,
347 new String[] {
348 "Name", "VCCLCompilerTool",
349 "UsePrecompiledHeader", "0"
350 });
351 }
352
353 if (a.configs != null) {
354 for (Iterator j=allConfigNames.iterator(); j.hasNext();) {
355 String cfg = (String)j.next();
356 if (!a.configs.contains(cfg)) {
357 startTag("FileConfiguration",
358 new String[] {
359 "Name", cfg,
360 "ExcludedFromBuild", "TRUE"
361 });
362 tag("Tool", new String[] {"Name", "VCCLCompilerTool"});
363 endTag("FileConfiguration");
364
365 }
366 }
367 }
368
369 endTag("File");
370
371 // we not gonna look at this file anymore
372 i.remove();
373 }
374 }
375
376 endTag("Filter");
377 }
378
379
380 void writeConfiguration(BuildConfig cfg) {
381 startTag("Configuration",
382 new String[] {
383 "Name", cfg.get("Name"),
384 "OutputDirectory", cfg.get("OutputDir"),
385 "IntermediateDirectory", cfg.get("OutputDir"),
386 "ConfigurationType", "2",
387 "UseOfMFC", "0",
388 "ATLMinimizesCRunTimeLibraryUsage", "FALSE"
389 }
390 );
391
392
393
394 tagV("Tool", cfg.getV("CompilerFlags"));
395
396 tag("Tool",
397 new String[] {
398 "Name", "VCCustomBuildTool"
399 }
400 );
401
402 tagV("Tool", cfg.getV("LinkerFlags"));
403
404 tag("Tool",
405 new String[] {
406 "Name", "VCPostBuildEventTool"
407 }
408 );
409
410 tag("Tool",
411 new String[] {
412 "Name", "VCPreBuildEventTool"
413 }
414 );
415
416 tag("Tool",
417 new String[] {
418 "Name", "VCPreLinkEventTool",
419 "Description", BuildConfig.getFieldString(null, "PrelinkDescription"),
420 "CommandLine", cfg.expandFormat(BuildConfig.getFieldString(null, "PrelinkCommand").replace('\t', '\n'))
421 }
422 );
423
424 tag("Tool",
425 new String[] {
426 "Name", "VCResourceCompilerTool",
427 // XXX???
428 "PreprocessorDefinitions", "NDEBUG",
429 "Culture", "1033"
430 }
431 );
432 tag("Tool",
433 new String[] {
434 "Name", "VCWebServiceProxyGeneratorTool"
435 }
436 );
437
438 tag ("Tool",
439 new String[] {
440 "Name", "VCXMLDataGeneratorTool"
441 }
442 );
443
444 tag("Tool",
445 new String[] {
446 "Name", "VCWebDeploymentTool"
447 }
448 );
449 tag("Tool",
450 new String[] {
451 "Name", "VCManagedWrapperGeneratorTool"
452 }
453 );
454 tag("Tool",
455 new String[] {
456 "Name", "VCAuxiliaryManagedWrapperGeneratorTool"
457 }
458 );
459
460 tag("Tool",
461 new String[] {
462 "Name", "VCMIDLTool",
463 "PreprocessorDefinitions", "NDEBUG",
464 "MkTypLibCompatible", "TRUE",
465 "SuppressStartupBanner", "TRUE",
466 "TargetEnvironment", "1",
467 "TypeLibraryName", cfg.get("OutputDir") + Util.sep + "vm.tlb",
468 "HeaderFileName", ""
469 }
470 );
471
472 endTag("Configuration");
473 }
474
475 int indent;
476
477 private void startTagPrim(String name,
478 String[] attrs,
479 boolean close) {
480 doIndent();
481 printWriter.print("<"+name);
482 indent++;
483
484 if (attrs != null) {
485 printWriter.println();
486 for (int i=0; i<attrs.length; i+=2) {
487 doIndent();
488 printWriter.println(" " + attrs[i]+"=\""+attrs[i+1]+"\"");
489 }
490 }
491
492 if (close) {
493 indent--;
494 //doIndent();
495 printWriter.println("/>");
496 } else {
497 //doIndent();
498 printWriter.println(">");
499 }
500 }
501
502 void startTag(String name, String[] attrs) {
503 startTagPrim(name, attrs, false);
504 }
505
506 void startTagV(String name, Vector attrs) {
507 String s[] = new String [attrs.size()];
508 for (int i=0; i<attrs.size(); i++) {
509 s[i] = (String)attrs.elementAt(i);
510 }
511 startTagPrim(name, s, false);
512 }
513
514 void endTag(String name) {
515 indent--;
516 doIndent();
517 printWriter.println("</"+name+">");
518 }
519
520 void tag(String name, String[] attrs) {
521 startTagPrim(name, attrs, true);
522 }
523
524 void tagV(String name, Vector attrs) {
525 String s[] = new String [attrs.size()];
526 for (int i=0; i<attrs.size(); i++) {
527 s[i] = (String)attrs.elementAt(i);
528 }
529 startTagPrim(name, s, true);
530 }
531
532
533 void doIndent() {
534 for (int i=0; i<indent; i++) {
535 printWriter.print(" ");
536 }
537 }
538
539 protected String getProjectExt() {
540 return ".vcproj";
541 }
542 }
543
544 class CompilerInterfaceVC7 extends CompilerInterface {
545 Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir) {
546 Vector rv = new Vector();
547
548 // advanced M$ IDE (2003) can only recognize name if it's first or
549 // second attribute in the tag - go guess
550 addAttr(rv, "Name", "VCCLCompilerTool");
551 addAttr(rv, "AdditionalIncludeDirectories", Util.join(",", includes));
552 addAttr(rv, "PreprocessorDefinitions", Util.join(";", defines).replace("\"","&quot;"));
553 addAttr(rv, "UsePrecompiledHeader", "3");
554 addAttr(rv, "PrecompiledHeaderThrough", "incls"+Util.sep+"_precompiled.incl");
555 addAttr(rv, "PrecompiledHeaderFile", outDir+Util.sep+"vm.pch");
556 addAttr(rv, "AssemblerListingLocation", outDir);
557 addAttr(rv, "ObjectFile", outDir+Util.sep);
558 addAttr(rv, "ProgramDataBaseFileName", outDir+Util.sep+"vm.pdb");
559 addAttr(rv, "SuppressStartupBanner", "TRUE");
560 addAttr(rv, "CompileAs", "0");
561 addAttr(rv, "WarningLevel", "3");
562 addAttr(rv, "WarnAsError", "TRUE");
563 addAttr(rv, "BufferSecurityCheck", "FALSE");
564 addAttr(rv, "ExceptionHandling", "FALSE");
565
566 return rv;
567 }
568
569 Vector getBaseLinkerFlags(String outDir, String outDll) {
570 Vector rv = new Vector();
571
572 addAttr(rv, "Name", "VCLinkerTool");
573 addAttr(rv, "AdditionalOptions",
574 "/export:JNI_GetDefaultJavaVMInitArgs " +
575 "/export:JNI_CreateJavaVM " +
576 "/export:JNI_GetCreatedJavaVMs "+
577 "/export:jio_snprintf /export:jio_printf "+
578 "/export:jio_fprintf /export:jio_vfprintf "+
579 "/export:jio_vsnprintf ");
580 addAttr(rv, "AdditionalDependencies", "Wsock32.lib winmm.lib");
581 addAttr(rv, "OutputFile", outDll);
582 addAttr(rv, "LinkIncremental", "1");
583 addAttr(rv, "SuppressStartupBanner", "TRUE");
584 addAttr(rv, "ModuleDefinitionFile", outDir+Util.sep+"vm.def");
585 addAttr(rv, "ProgramDatabaseFile", outDir+Util.sep+"vm.pdb");
586 addAttr(rv, "SubSystem", "2");
587 addAttr(rv, "BaseAddress", "0x8000000");
588 addAttr(rv, "ImportLibrary", outDir+Util.sep+"jvm.lib");
589 addAttr(rv, "TargetMachine", "1");
590
591 return rv;
592 }
593
594 Vector getDebugCompilerFlags(String opt) {
595 Vector rv = new Vector();
596
597 addAttr(rv, "Optimization", opt);
598 addAttr(rv, "OptimizeForProcessor", "1");
599 addAttr(rv, "DebugInformationFormat", "3");
600 addAttr(rv, "RuntimeLibrary", "2");
601 addAttr(rv, "BrowseInformation", "1");
602 addAttr(rv, "BrowseInformationFile", "$(IntDir)" + Util.sep);
603
604 return rv;
605 }
606
607 Vector getDebugLinkerFlags() {
608 Vector rv = new Vector();
609
610 addAttr(rv, "GenerateDebugInformation", "TRUE");
611
612 return rv;
613 }
614
615 Vector getProductCompilerFlags() {
616 Vector rv = new Vector();
617
618 addAttr(rv, "Optimization", "2");
619 addAttr(rv, "InlineFunctionExpansion", "1");
620 addAttr(rv, "StringPooling", "TRUE");
621 addAttr(rv, "RuntimeLibrary", "2");
622 addAttr(rv, "EnableFunctionLevelLinking", "TRUE");
623
624 return rv;
625 }
626
627 Vector getProductLinkerFlags() {
628 Vector rv = new Vector();
629
630 addAttr(rv, "OptimizeReferences", "2");
631 addAttr(rv, "EnableCOMDATFolding", "2");
632
633 return rv;
634 }
635
636 String getOptFlag() {
637 return "2";
638 }
639
640 String getNoOptFlag() {
641 return "0";
642 }
643
644 String makeCfgName(String flavourBuild) {
645 return flavourBuild + "|" + Util.os;
646 }
647 }