Mercurial > hg > graal-compiler
comparison src/share/tools/ProjectCreator/WinGammaPlatform.java @ 6948:e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 12 Nov 2012 23:14:12 +0100 |
parents | 76841bdd5f3e b9a9ed0f8eeb |
children | b9a918201d47 |
comparison
equal
deleted
inserted
replaced
6711:ae13cc658b80 | 6948:e522a00b91aa |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
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 ), |
613 } | 575 } |
614 | 576 |
615 return allConfigs; | 577 return allConfigs; |
616 } | 578 } |
617 | 579 |
618 class FileAttribute { | |
619 int numConfigs; | |
620 Vector configs; | |
621 String shortName; | |
622 boolean noPch, pchRoot; | |
623 | |
624 FileAttribute(String shortName, BuildConfig cfg, int numConfigs) { | |
625 this.shortName = shortName; | |
626 this.noPch = (cfg.lookupHashFieldInContext("DisablePch", shortName) != null); | |
627 this.pchRoot = shortName.equals(BuildConfig.getFieldString(null, "UseToGeneratePch")); | |
628 this.numConfigs = numConfigs; | |
629 | |
630 configs = new Vector(); | |
631 add(cfg.get("Name")); | |
632 } | |
633 | |
634 void add(String confName) { | |
635 configs.add(confName); | |
636 | |
637 // if presented in all configs | |
638 if (configs.size() == numConfigs) { | |
639 configs = null; | |
640 } | |
641 } | |
642 } | |
643 | |
644 class FileInfo implements Comparable { | |
645 String full; | |
646 FileAttribute attr; | |
647 | |
648 FileInfo(String full, FileAttribute attr) { | |
649 this.full = full; | |
650 this.attr = attr; | |
651 } | |
652 | |
653 public int compareTo(Object o) { | |
654 FileInfo oo = (FileInfo)o; | |
655 return full.compareTo(oo.full); | |
656 } | |
657 | |
658 boolean isHeader() { | |
659 return attr.shortName.endsWith(".h") || attr.shortName.endsWith(".hpp"); | |
660 } | |
661 | |
662 boolean isCpp() { | |
663 return attr.shortName.endsWith(".cpp"); | |
664 } | |
665 } | |
666 | |
667 | |
668 TreeSet sortFiles(Hashtable allFiles) { | |
669 TreeSet rv = new TreeSet(); | |
670 Enumeration e = allFiles.keys(); | |
671 while (e.hasMoreElements()) { | |
672 String fullPath = (String)e.nextElement(); | |
673 rv.add(new FileInfo(fullPath, (FileAttribute)allFiles.get(fullPath))); | |
674 } | |
675 return rv; | |
676 } | |
677 | |
678 Hashtable computeAttributedFiles(Vector allConfigs) { | |
679 Hashtable ht = new Hashtable(); | |
680 int numConfigs = allConfigs.size(); | |
681 | |
682 for (Iterator i = allConfigs.iterator(); i.hasNext(); ) { | |
683 BuildConfig bc = (BuildConfig)i.next(); | |
684 Hashtable confFiles = (Hashtable)bc.getSpecificField("AllFilesHash"); | |
685 String confName = bc.get("Name"); | |
686 | |
687 for (Enumeration e=confFiles.keys(); e.hasMoreElements(); ) { | |
688 String filePath = (String)e.nextElement(); | |
689 FileAttribute fa = (FileAttribute)ht.get(filePath); | |
690 | |
691 if (fa == null) { | |
692 fa = new FileAttribute((String)confFiles.get(filePath), bc, numConfigs); | |
693 ht.put(filePath, fa); | |
694 } else { | |
695 fa.add(confName); | |
696 } | |
697 } | |
698 } | |
699 | |
700 return ht; | |
701 } | |
702 | |
703 Hashtable computeAttributedFiles(BuildConfig bc) { | |
704 Hashtable ht = new Hashtable(); | |
705 Hashtable confFiles = (Hashtable)bc.getSpecificField("AllFilesHash"); | |
706 | |
707 for (Enumeration e = confFiles.keys(); e.hasMoreElements(); ) { | |
708 String filePath = (String)e.nextElement(); | |
709 ht.put(filePath, new FileAttribute((String)confFiles.get(filePath), bc, 1)); | |
710 } | |
711 | |
712 return ht; | |
713 } | |
714 | |
715 PrintWriter printWriter; | 580 PrintWriter printWriter; |
716 | 581 |
717 public void writeProjectFile(String projectFileName, String projectName, | 582 public void writeProjectFile(String projectFileName, String projectName, |
718 Vector<BuildConfig> allConfigs) throws IOException { | 583 Vector<BuildConfig> allConfigs) throws IOException { |
719 throw new RuntimeException("use compiler version specific version"); | 584 throw new RuntimeException("use compiler version specific version"); |
720 } | 585 } |
586 | |
587 int indent; | |
588 private Stack<String> tagStack = new Stack<String>(); | |
589 | |
590 private void startTagPrim(String name, String[] attrs, boolean close) { | |
591 startTagPrim(name, attrs, close, true); | |
592 } | |
593 | |
594 private void startTagPrim(String name, String[] attrs, boolean close, | |
595 boolean newline) { | |
596 doIndent(); | |
597 printWriter.print("<" + name); | |
598 indent++; | |
599 | |
600 if (attrs != null && attrs.length > 0) { | |
601 for (int i = 0; i < attrs.length; i += 2) { | |
602 printWriter.print(" " + attrs[i] + "=\"" + attrs[i + 1] + "\""); | |
603 if (i < attrs.length - 2) { | |
604 } | |
605 } | |
606 } | |
607 | |
608 if (close) { | |
609 indent--; | |
610 printWriter.print(" />"); | |
611 } else { | |
612 // TODO push tag name, and change endTag to pop and print. | |
613 tagStack.push(name); | |
614 printWriter.print(">"); | |
615 } | |
616 if (newline) { | |
617 printWriter.println(); | |
618 } | |
619 } | |
620 | |
621 void startTag(String name, String... attrs) { | |
622 startTagPrim(name, attrs, false); | |
623 } | |
624 | |
625 void startTagV(String name, Vector attrs) { | |
626 String s[] = new String[attrs.size()]; | |
627 for (int i = 0; i < attrs.size(); i++) { | |
628 s[i] = (String) attrs.elementAt(i); | |
629 } | |
630 startTagPrim(name, s, false); | |
631 } | |
632 | |
633 void endTag() { | |
634 String name = tagStack.pop(); | |
635 indent--; | |
636 doIndent(); | |
637 printWriter.println("</" + name + ">"); | |
638 } | |
639 | |
640 private void endTagNoIndent() { | |
641 String name = tagStack.pop(); | |
642 indent--; | |
643 printWriter.println("</" + name + ">"); | |
644 } | |
645 | |
646 void tag(String name, String... attrs) { | |
647 startTagPrim(name, attrs, true); | |
648 } | |
649 | |
650 void tagData(String name, String data) { | |
651 startTagPrim(name, null, false, false); | |
652 printWriter.print(data); | |
653 endTagNoIndent(); | |
654 } | |
655 | |
656 void tagData(String name, String data, String... attrs) { | |
657 startTagPrim(name, attrs, false, false); | |
658 printWriter.print(data); | |
659 endTagNoIndent(); | |
660 } | |
661 | |
662 void tagV(String name, Vector attrs) { | |
663 String s[] = new String[attrs.size()]; | |
664 for (int i = 0; i < attrs.size(); i++) { | |
665 s[i] = (String) attrs.elementAt(i); | |
666 } | |
667 startTagPrim(name, s, true); | |
668 } | |
669 | |
670 void doIndent() { | |
671 for (int i = 0; i < indent; i++) { | |
672 printWriter.print(" "); | |
673 } | |
674 } | |
675 | |
676 | |
721 } | 677 } |