Mercurial > hg > graal-jvmci-8
comparison src/share/tools/ProjectCreator/WinGammaPlatform.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 |
---|---|
27 import java.io.PrintWriter; | 27 import java.io.PrintWriter; |
28 import java.util.Enumeration; | 28 import java.util.Enumeration; |
29 import java.util.Hashtable; | 29 import java.util.Hashtable; |
30 import java.util.Iterator; | 30 import java.util.Iterator; |
31 import java.util.List; | 31 import java.util.List; |
32 import java.util.Stack; | |
32 import java.util.TreeSet; | 33 import java.util.TreeSet; |
33 import java.util.Vector; | 34 import java.util.Vector; |
34 | 35 |
35 abstract class HsArgHandler extends ArgHandler { | 36 abstract class HsArgHandler extends ArgHandler { |
36 static final int STRING = 1; | 37 static final int STRING = 1; |
216 } | 217 } |
217 | 218 |
218 return false; | 219 return false; |
219 } | 220 } |
220 | 221 |
221 /* This returns a String containing the full path to the passed | |
222 file name, or null if an error occurred. If the file was not | |
223 found or was a duplicate and couldn't be resolved using the | |
224 preferred paths, the file name is added to the appropriate | |
225 Vector of Strings. */ | |
226 private String findFileInDirectory(String fileName, | |
227 DirectoryTree directory, | |
228 Vector preferredPaths, | |
229 Vector filesNotFound, | |
230 Vector filesDuplicate) { | |
231 List locationsInTree = directory.findFile(fileName); | |
232 int rootNameLength = directory.getRootNodeName().length(); | |
233 String name = null; | |
234 if ((locationsInTree == null) || | |
235 (locationsInTree.size() == 0)) { | |
236 filesNotFound.add(fileName); | |
237 } else if (locationsInTree.size() > 1) { | |
238 // Iterate through them, trying to find one with a | |
239 // preferred path | |
240 search: | |
241 { | |
242 for (Iterator locIter = locationsInTree.iterator(); | |
243 locIter.hasNext(); ) { | |
244 DirectoryTreeNode node = | |
245 (DirectoryTreeNode) locIter.next(); | |
246 String tmpName = node.getName(); | |
247 for (Iterator prefIter = preferredPaths.iterator(); | |
248 prefIter.hasNext(); ) { | |
249 // We need to make sure the preferred path is | |
250 // found from the file path not including the root node name. | |
251 if (tmpName.indexOf((String)prefIter.next(), | |
252 rootNameLength) != -1) { | |
253 name = tmpName; | |
254 break search; | |
255 } | |
256 } | |
257 } | |
258 } | |
259 | |
260 if (name == null) { | |
261 filesDuplicate.add(fileName); | |
262 } | |
263 } else { | |
264 name = ((DirectoryTreeNode) locationsInTree.get(0)).getName(); | |
265 } | |
266 | |
267 return name; | |
268 } | |
269 | |
270 protected String envVarPrefixedFileName(String fileName, | |
271 int sourceBaseLen, | |
272 DirectoryTree tree, | |
273 Vector preferredPaths, | |
274 Vector filesNotFound, | |
275 Vector filesDuplicate) { | |
276 String fullName = findFileInDirectory(fileName, | |
277 tree, | |
278 preferredPaths, | |
279 filesNotFound, | |
280 filesDuplicate); | |
281 return fullName; | |
282 } | |
283 | |
284 String getProjectName(String fullPath, String extension) | 222 String getProjectName(String fullPath, String extension) |
285 throws IllegalArgumentException, IOException { | 223 throws IllegalArgumentException, IOException { |
286 File file = new File(fullPath).getCanonicalFile(); | 224 File file = new File(fullPath).getCanonicalFile(); |
287 fullPath = file.getCanonicalPath(); | 225 fullPath = file.getCanonicalPath(); |
288 String parent = file.getParent(); | 226 String parent = file.getParent(); |
367 "BuildBase", | 305 "BuildBase", |
368 " (Did you set the HotSpotBuildSpace environment variable?)", | 306 " (Did you set the HotSpotBuildSpace environment variable?)", |
369 HsArgHandler.STRING | 307 HsArgHandler.STRING |
370 ), | 308 ), |
371 | 309 |
310 new HsArgRule("-buildSpace", | |
311 "BuildSpace", | |
312 null, | |
313 HsArgHandler.STRING | |
314 ), | |
315 | |
372 new HsArgRule("-platformName", | 316 new HsArgRule("-platformName", |
373 "PlatformName", | 317 "PlatformName", |
374 null, | 318 null, |
375 HsArgHandler.STRING | 319 HsArgHandler.STRING |
376 ), | 320 ), |
399 HsArgHandler.VECTOR | 343 HsArgHandler.VECTOR |
400 ), | 344 ), |
401 | 345 |
402 new HsArgRule("-relativeInclude", | 346 new HsArgRule("-relativeInclude", |
403 "RelativeInclude", | 347 "RelativeInclude", |
348 null, | |
349 HsArgHandler.VECTOR | |
350 ), | |
351 | |
352 new HsArgRule("-absoluteSrcInclude", | |
353 "AbsoluteSrcInclude", | |
354 null, | |
355 HsArgHandler.VECTOR | |
356 ), | |
357 | |
358 new HsArgRule("-relativeSrcInclude", | |
359 "RelativeSrcInclude", | |
404 null, | 360 null, |
405 HsArgHandler.VECTOR | 361 HsArgHandler.VECTOR |
406 ), | 362 ), |
407 | 363 |
408 new HsArgRule("-define", | 364 new HsArgRule("-define", |
492 "IgnorePath", | 448 "IgnorePath", |
493 null, | 449 null, |
494 HsArgHandler.VECTOR | 450 HsArgHandler.VECTOR |
495 ), | 451 ), |
496 | 452 |
453 new HsArgRule("-hidePath", | |
454 "HidePath", | |
455 null, | |
456 HsArgHandler.VECTOR | |
457 ), | |
458 | |
497 new HsArgRule("-additionalFile", | 459 new HsArgRule("-additionalFile", |
498 "AdditionalFile", | 460 "AdditionalFile", |
499 null, | 461 null, |
500 HsArgHandler.VECTOR | 462 HsArgHandler.VECTOR |
501 ), | 463 ), |
609 } | 571 } |
610 | 572 |
611 return allConfigs; | 573 return allConfigs; |
612 } | 574 } |
613 | 575 |
614 class FileAttribute { | |
615 int numConfigs; | |
616 Vector configs; | |
617 String shortName; | |
618 boolean noPch, pchRoot; | |
619 | |
620 FileAttribute(String shortName, BuildConfig cfg, int numConfigs) { | |
621 this.shortName = shortName; | |
622 this.noPch = (cfg.lookupHashFieldInContext("DisablePch", shortName) != null); | |
623 this.pchRoot = shortName.equals(BuildConfig.getFieldString(null, "UseToGeneratePch")); | |
624 this.numConfigs = numConfigs; | |
625 | |
626 configs = new Vector(); | |
627 add(cfg.get("Name")); | |
628 } | |
629 | |
630 void add(String confName) { | |
631 configs.add(confName); | |
632 | |
633 // if presented in all configs | |
634 if (configs.size() == numConfigs) { | |
635 configs = null; | |
636 } | |
637 } | |
638 } | |
639 | |
640 class FileInfo implements Comparable { | |
641 String full; | |
642 FileAttribute attr; | |
643 | |
644 FileInfo(String full, FileAttribute attr) { | |
645 this.full = full; | |
646 this.attr = attr; | |
647 } | |
648 | |
649 public int compareTo(Object o) { | |
650 FileInfo oo = (FileInfo)o; | |
651 return full.compareTo(oo.full); | |
652 } | |
653 | |
654 boolean isHeader() { | |
655 return attr.shortName.endsWith(".h") || attr.shortName.endsWith(".hpp"); | |
656 } | |
657 | |
658 boolean isCpp() { | |
659 return attr.shortName.endsWith(".cpp"); | |
660 } | |
661 } | |
662 | |
663 | |
664 TreeSet sortFiles(Hashtable allFiles) { | |
665 TreeSet rv = new TreeSet(); | |
666 Enumeration e = allFiles.keys(); | |
667 while (e.hasMoreElements()) { | |
668 String fullPath = (String)e.nextElement(); | |
669 rv.add(new FileInfo(fullPath, (FileAttribute)allFiles.get(fullPath))); | |
670 } | |
671 return rv; | |
672 } | |
673 | |
674 Hashtable computeAttributedFiles(Vector allConfigs) { | |
675 Hashtable ht = new Hashtable(); | |
676 int numConfigs = allConfigs.size(); | |
677 | |
678 for (Iterator i = allConfigs.iterator(); i.hasNext(); ) { | |
679 BuildConfig bc = (BuildConfig)i.next(); | |
680 Hashtable confFiles = (Hashtable)bc.getSpecificField("AllFilesHash"); | |
681 String confName = bc.get("Name"); | |
682 | |
683 for (Enumeration e=confFiles.keys(); e.hasMoreElements(); ) { | |
684 String filePath = (String)e.nextElement(); | |
685 FileAttribute fa = (FileAttribute)ht.get(filePath); | |
686 | |
687 if (fa == null) { | |
688 fa = new FileAttribute((String)confFiles.get(filePath), bc, numConfigs); | |
689 ht.put(filePath, fa); | |
690 } else { | |
691 fa.add(confName); | |
692 } | |
693 } | |
694 } | |
695 | |
696 return ht; | |
697 } | |
698 | |
699 Hashtable computeAttributedFiles(BuildConfig bc) { | |
700 Hashtable ht = new Hashtable(); | |
701 Hashtable confFiles = (Hashtable)bc.getSpecificField("AllFilesHash"); | |
702 | |
703 for (Enumeration e = confFiles.keys(); e.hasMoreElements(); ) { | |
704 String filePath = (String)e.nextElement(); | |
705 ht.put(filePath, new FileAttribute((String)confFiles.get(filePath), bc, 1)); | |
706 } | |
707 | |
708 return ht; | |
709 } | |
710 | |
711 PrintWriter printWriter; | 576 PrintWriter printWriter; |
712 | 577 |
713 public void writeProjectFile(String projectFileName, String projectName, | 578 public void writeProjectFile(String projectFileName, String projectName, |
714 Vector<BuildConfig> allConfigs) throws IOException { | 579 Vector<BuildConfig> allConfigs) throws IOException { |
715 throw new RuntimeException("use compiler version specific version"); | 580 throw new RuntimeException("use compiler version specific version"); |
716 } | 581 } |
582 | |
583 int indent; | |
584 private Stack<String> tagStack = new Stack<String>(); | |
585 | |
586 private void startTagPrim(String name, String[] attrs, boolean close) { | |
587 startTagPrim(name, attrs, close, true); | |
588 } | |
589 | |
590 private void startTagPrim(String name, String[] attrs, boolean close, | |
591 boolean newline) { | |
592 doIndent(); | |
593 printWriter.print("<" + name); | |
594 indent++; | |
595 | |
596 if (attrs != null && attrs.length > 0) { | |
597 for (int i = 0; i < attrs.length; i += 2) { | |
598 printWriter.print(" " + attrs[i] + "=\"" + attrs[i + 1] + "\""); | |
599 if (i < attrs.length - 2) { | |
600 } | |
601 } | |
602 } | |
603 | |
604 if (close) { | |
605 indent--; | |
606 printWriter.print(" />"); | |
607 } else { | |
608 // TODO push tag name, and change endTag to pop and print. | |
609 tagStack.push(name); | |
610 printWriter.print(">"); | |
611 } | |
612 if (newline) { | |
613 printWriter.println(); | |
614 } | |
615 } | |
616 | |
617 void startTag(String name, String... attrs) { | |
618 startTagPrim(name, attrs, false); | |
619 } | |
620 | |
621 void startTagV(String name, Vector attrs) { | |
622 String s[] = new String[attrs.size()]; | |
623 for (int i = 0; i < attrs.size(); i++) { | |
624 s[i] = (String) attrs.elementAt(i); | |
625 } | |
626 startTagPrim(name, s, false); | |
627 } | |
628 | |
629 void endTag() { | |
630 String name = tagStack.pop(); | |
631 indent--; | |
632 doIndent(); | |
633 printWriter.println("</" + name + ">"); | |
634 } | |
635 | |
636 private void endTagNoIndent() { | |
637 String name = tagStack.pop(); | |
638 indent--; | |
639 printWriter.println("</" + name + ">"); | |
640 } | |
641 | |
642 void tag(String name, String... attrs) { | |
643 startTagPrim(name, attrs, true); | |
644 } | |
645 | |
646 void tagData(String name, String data) { | |
647 startTagPrim(name, null, false, false); | |
648 printWriter.print(data); | |
649 endTagNoIndent(); | |
650 } | |
651 | |
652 void tagData(String name, String data, String... attrs) { | |
653 startTagPrim(name, attrs, false, false); | |
654 printWriter.print(data); | |
655 endTagNoIndent(); | |
656 } | |
657 | |
658 void tagV(String name, Vector attrs) { | |
659 String s[] = new String[attrs.size()]; | |
660 for (int i = 0; i < attrs.size(); i++) { | |
661 s[i] = (String) attrs.elementAt(i); | |
662 } | |
663 startTagPrim(name, s, true); | |
664 } | |
665 | |
666 void doIndent() { | |
667 for (int i = 0; i < indent; i++) { | |
668 printWriter.print(" "); | |
669 } | |
670 } | |
671 | |
672 | |
717 } | 673 } |