Mercurial > hg > truffle
comparison src/share/tools/ProjectCreator/WinGammaPlatformVC7.java @ 2393:74e790c48cd4
7031571: Generate native VS2010 project files
Reviewed-by: hosterda, stefank, brutisso
author | sla |
---|---|
date | Mon, 28 Mar 2011 12:48:08 +0200 |
parents | 15d6977f04b0 |
children | 0654ee04b214 1a9b9cfcef41 |
comparison
equal
deleted
inserted
replaced
2388:006b3750a4d4 | 2393:74e790c48cd4 |
---|---|
33 public class WinGammaPlatformVC7 extends WinGammaPlatform { | 33 public class WinGammaPlatformVC7 extends WinGammaPlatform { |
34 | 34 |
35 String projectVersion() {return "7.10";}; | 35 String projectVersion() {return "7.10";}; |
36 | 36 |
37 public void writeProjectFile(String projectFileName, String projectName, | 37 public void writeProjectFile(String projectFileName, String projectName, |
38 Vector allConfigs) throws IOException { | 38 Vector<BuildConfig> allConfigs) throws IOException { |
39 System.out.println(); | 39 System.out.println(); |
40 System.out.println(" Writing .vcproj file: "+projectFileName); | 40 System.out.println(" Writing .vcproj file: "+projectFileName); |
41 // If we got this far without an error, we're safe to actually | 41 // If we got this far without an error, we're safe to actually |
42 // write the .vcproj file | 42 // write the .vcproj file |
43 printWriter = new PrintWriter(new FileWriter(projectFileName)); | 43 printWriter = new PrintWriter(new FileWriter(projectFileName)); |
52 "ProjectGUID", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}", | 52 "ProjectGUID", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}", |
53 "SccProjectName", "", | 53 "SccProjectName", "", |
54 "SccLocalPath", "" | 54 "SccLocalPath", "" |
55 } | 55 } |
56 ); | 56 ); |
57 startTag("Platforms", null); | 57 startTag("Platforms"); |
58 tag("Platform", new String[] {"Name", (String) BuildConfig.getField(null, "PlatformName")}); | 58 tag("Platform", new String[] {"Name", (String) BuildConfig.getField(null, "PlatformName")}); |
59 endTag("Platforms"); | 59 endTag("Platforms"); |
60 | 60 |
61 startTag("Configurations", null); | 61 startTag("Configurations"); |
62 | 62 |
63 for (Iterator i = allConfigs.iterator(); i.hasNext(); ) { | 63 for (Iterator i = allConfigs.iterator(); i.hasNext(); ) { |
64 writeConfiguration((BuildConfig)i.next()); | 64 writeConfiguration((BuildConfig)i.next()); |
65 } | 65 } |
66 | 66 |
67 endTag("Configurations"); | 67 endTag("Configurations"); |
68 | 68 |
69 tag("References", null); | 69 tag("References"); |
70 | 70 |
71 writeFiles(allConfigs); | 71 writeFiles(allConfigs); |
72 | 72 |
73 tag("Globals", null); | 73 tag("Globals"); |
74 | 74 |
75 endTag("VisualStudioProject"); | 75 endTag("VisualStudioProject"); |
76 printWriter.close(); | 76 printWriter.close(); |
77 | 77 |
78 System.out.println(" Done."); | 78 System.out.println(" Done."); |
188 private WinGammaPlatformVC7 getOuterType() { | 188 private WinGammaPlatformVC7 getOuterType() { |
189 return WinGammaPlatformVC7.this; | 189 return WinGammaPlatformVC7.this; |
190 } | 190 } |
191 } | 191 } |
192 | 192 |
193 class TypeFilter extends NameFilter { | |
194 String[] exts; | |
195 | |
196 TypeFilter(String fname, String[] exts) { | |
197 this.fname = fname; | |
198 this.exts = exts; | |
199 } | |
200 | |
201 boolean match(FileInfo fi) { | |
202 for (int i=0; i<exts.length; i++) { | |
203 if (fi.full.endsWith(exts[i])) { | |
204 return true; | |
205 } | |
206 } | |
207 return false; | |
208 } | |
209 | |
210 String filterString() { | |
211 return Util.join(";", exts); | |
212 } | |
213 } | |
214 | |
215 class TerminatorFilter extends NameFilter { | 193 class TerminatorFilter extends NameFilter { |
216 TerminatorFilter(String fname) { | 194 TerminatorFilter(String fname) { |
217 this.fname = fname; | 195 this.fname = fname; |
218 | 196 |
219 } | 197 } |
297 // here we define filters, which define layout of what can be seen in 'Solution View' of MSVC | 275 // here we define filters, which define layout of what can be seen in 'Solution View' of MSVC |
298 // Basically there are two types of entities - container filters and real filters | 276 // Basically there are two types of entities - container filters and real filters |
299 // - container filter just provides a container to group together real filters | 277 // - container filter just provides a container to group together real filters |
300 // - real filter can select elements from the set according to some rule, put it into XML | 278 // - real filter can select elements from the set according to some rule, put it into XML |
301 // and remove from the list | 279 // and remove from the list |
302 Vector makeFilters(TreeSet<FileInfo> files) { | 280 Vector<NameFilter> makeFilters(TreeSet<FileInfo> files) { |
303 Vector rv = new Vector(); | 281 Vector<NameFilter> rv = new Vector<NameFilter>(); |
304 String sbase = Util.normalize(BuildConfig.getFieldString(null, "SourceBase")+"/src/"); | 282 String sbase = Util.normalize(BuildConfig.getFieldString(null, "SourceBase")+"/src/"); |
305 | 283 |
306 String currentDir = ""; | 284 String currentDir = ""; |
307 DirectoryFilter container = null; | 285 DirectoryFilter container = null; |
308 for(FileInfo fileInfo : files) { | 286 for(FileInfo fileInfo : files) { |
368 rv.add(generated); | 346 rv.add(generated); |
369 | 347 |
370 rv.add(new SpecificNameFilter("Precompiled Header", new String[] {"precompiled.hpp"})); | 348 rv.add(new SpecificNameFilter("Precompiled Header", new String[] {"precompiled.hpp"})); |
371 | 349 |
372 // this one is to catch files not caught by other filters | 350 // this one is to catch files not caught by other filters |
373 //rv.add(new TypeFilter("Header Files", new String[] {"h", "hpp", "hxx", "hm", "inl", "fi", "fd"})); | |
374 rv.add(new TerminatorFilter("Source Files")); | 351 rv.add(new TerminatorFilter("Source Files")); |
375 | 352 |
376 return rv; | 353 return rv; |
377 } | 354 } |
378 | 355 |
379 void writeFiles(Vector allConfigs) { | 356 void writeFiles(Vector<BuildConfig> allConfigs) { |
380 | 357 |
381 Hashtable allFiles = computeAttributedFiles(allConfigs); | 358 Hashtable allFiles = computeAttributedFiles(allConfigs); |
382 | 359 |
383 Vector allConfigNames = new Vector(); | 360 Vector allConfigNames = new Vector(); |
384 for (Iterator i = allConfigs.iterator(); i.hasNext(); ) { | 361 for (Iterator i = allConfigs.iterator(); i.hasNext(); ) { |
385 allConfigNames.add(((BuildConfig)i.next()).get("Name")); | 362 allConfigNames.add(((BuildConfig)i.next()).get("Name")); |
386 } | 363 } |
387 | 364 |
388 TreeSet sortedFiles = sortFiles(allFiles); | 365 TreeSet sortedFiles = sortFiles(allFiles); |
389 | 366 |
390 startTag("Files", null); | 367 startTag("Files"); |
391 | 368 |
392 for (Iterator i = makeFilters(sortedFiles).iterator(); i.hasNext(); ) { | 369 for (Iterator i = makeFilters(sortedFiles).iterator(); i.hasNext(); ) { |
393 doWriteFiles(sortedFiles, allConfigNames, (NameFilter)i.next()); | 370 doWriteFiles(sortedFiles, allConfigNames, (NameFilter)i.next()); |
394 } | 371 } |
395 | 372 |
554 } | 531 } |
555 | 532 |
556 int indent; | 533 int indent; |
557 | 534 |
558 private void startTagPrim(String name, | 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, | |
559 String[] attrs, | 542 String[] attrs, |
560 boolean close) { | 543 boolean close, |
544 boolean newline) { | |
561 doIndent(); | 545 doIndent(); |
562 printWriter.print("<"+name); | 546 printWriter.print("<"+name); |
563 indent++; | 547 indent++; |
564 | 548 |
565 if (attrs != null) { | 549 if (attrs != null && attrs.length > 0) { |
566 printWriter.println(); | |
567 for (int i=0; i<attrs.length; i+=2) { | 550 for (int i=0; i<attrs.length; i+=2) { |
568 doIndent(); | |
569 printWriter.print(" " + attrs[i]+"=\""+attrs[i+1]+"\""); | 551 printWriter.print(" " + attrs[i]+"=\""+attrs[i+1]+"\""); |
570 if (i < attrs.length - 2) { | 552 if (i < attrs.length - 2) { |
571 printWriter.println(); | |
572 } | 553 } |
573 } | 554 } |
574 } | 555 } |
575 | 556 |
576 if (close) { | 557 if (close) { |
577 indent--; | 558 indent--; |
578 //doIndent(); | 559 printWriter.print(" />"); |
579 printWriter.println("/>"); | |
580 } else { | 560 } else { |
581 //doIndent(); | 561 printWriter.print(">"); |
582 printWriter.println(">"); | 562 } |
583 } | 563 if(newline) { |
584 } | 564 printWriter.println(); |
585 | 565 } |
586 void startTag(String name, String[] attrs) { | 566 } |
567 | |
568 void startTag(String name, String... attrs) { | |
587 startTagPrim(name, attrs, false); | 569 startTagPrim(name, attrs, false); |
588 } | 570 } |
589 | 571 |
590 void startTagV(String name, Vector attrs) { | 572 void startTagV(String name, Vector attrs) { |
591 String s[] = new String [attrs.size()]; | 573 String s[] = new String [attrs.size()]; |
599 indent--; | 581 indent--; |
600 doIndent(); | 582 doIndent(); |
601 printWriter.println("</"+name+">"); | 583 printWriter.println("</"+name+">"); |
602 } | 584 } |
603 | 585 |
604 void tag(String name, String[] attrs) { | 586 void tag(String name, String... attrs) { |
605 startTagPrim(name, attrs, true); | 587 startTagPrim(name, attrs, true); |
606 } | 588 } |
607 | 589 |
608 void tagV(String name, Vector attrs) { | 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) { | |
609 String s[] = new String [attrs.size()]; | 605 String s[] = new String [attrs.size()]; |
610 for (int i=0; i<attrs.size(); i++) { | 606 for (int i=0; i<attrs.size(); i++) { |
611 s[i] = (String)attrs.elementAt(i); | 607 s[i] = (String)attrs.elementAt(i); |
612 } | 608 } |
613 startTagPrim(name, s, true); | 609 startTagPrim(name, s, true); |
614 } | 610 } |
615 | 611 |
616 | 612 |
617 void doIndent() { | 613 void doIndent() { |
618 for (int i=0; i<indent; i++) { | 614 for (int i=0; i<indent; i++) { |
619 printWriter.print(" "); | 615 printWriter.print(" "); |
620 } | 616 } |
621 } | 617 } |
622 | 618 |
623 protected String getProjectExt() { | 619 protected String getProjectExt() { |
624 return ".vcproj"; | 620 return ".vcproj"; |