Mercurial > hg > truffle
comparison src/share/tools/ProjectCreator/BuildConfig.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 | 33df1aeaebbf 1a9b9cfcef41 |
children | b9a918201d47 |
comparison
equal
deleted
inserted
replaced
6711:ae13cc658b80 | 6948:e522a00b91aa |
---|---|
20 * or visit www.oracle.com if you need additional information or have any | 20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. | 21 * questions. |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 import java.io.File; | |
26 import java.util.Enumeration; | 25 import java.util.Enumeration; |
27 import java.util.Hashtable; | 26 import java.util.Hashtable; |
28 import java.util.Iterator; | |
29 import java.util.Vector; | 27 import java.util.Vector; |
30 | 28 |
31 class BuildConfig { | 29 class BuildConfig { |
30 @SuppressWarnings("rawtypes") | |
32 Hashtable vars; | 31 Hashtable vars; |
33 Vector basicNames, basicPaths; | 32 Vector<String> basicNames, basicPaths; |
34 String[] context; | 33 String[] context; |
35 | 34 |
36 static CompilerInterface ci; | 35 static CompilerInterface ci; |
37 static CompilerInterface getCI() { | 36 static CompilerInterface getCI() { |
38 if (ci == null) { | 37 if (ci == null) { |
45 } | 44 } |
46 } | 45 } |
47 return ci; | 46 return ci; |
48 } | 47 } |
49 | 48 |
49 @SuppressWarnings("rawtypes") | |
50 protected void initNames(String flavour, String build, String outDll) { | 50 protected void initNames(String flavour, String build, String outDll) { |
51 if (vars == null) vars = new Hashtable(); | 51 if (vars == null) vars = new Hashtable(); |
52 | 52 |
53 String flavourBuild = flavour + "_" + build; | 53 String flavourBuild = flavour + "_" + build; |
54 String platformName = getFieldString(null, "PlatformName"); | 54 String platformName = getFieldString(null, "PlatformName"); |
61 put("PlatformName", platformName); | 61 put("PlatformName", platformName); |
62 | 62 |
63 // ones mentioned above were needed to expand format | 63 // ones mentioned above were needed to expand format |
64 String buildBase = expandFormat(getFieldString(null, "BuildBase")); | 64 String buildBase = expandFormat(getFieldString(null, "BuildBase")); |
65 String sourceBase = getFieldString(null, "SourceBase"); | 65 String sourceBase = getFieldString(null, "SourceBase"); |
66 String buildSpace = getFieldString(null, "BuildSpace"); | |
66 String outDir = buildBase; | 67 String outDir = buildBase; |
67 String value = System.getenv("OUT_DIR"); | 68 String value = System.getenv("OUT_DIR"); |
68 if (value != null) { | 69 if (value != null) { |
69 outDir = value; | 70 outDir = value; |
70 } | 71 } |
86 | 87 |
87 put("Id", flavourBuild); | 88 put("Id", flavourBuild); |
88 put("OutputDir", outDir); | 89 put("OutputDir", outDir); |
89 put("SourceBase", sourceBase); | 90 put("SourceBase", sourceBase); |
90 put("BuildBase", buildBase); | 91 put("BuildBase", buildBase); |
92 put("BuildSpace", buildSpace); | |
91 put("OutputDll", outDir + Util.sep + outDll); | 93 put("OutputDll", outDir + Util.sep + outDll); |
92 | 94 |
93 context = new String [] {flavourBuild, flavour, build, null}; | 95 context = new String [] {flavourBuild, flavour, build, null}; |
94 } | 96 } |
95 | 97 |
96 protected void init(Vector includes, Vector defines) { | 98 protected void init(Vector<String> includes, Vector<String> defines) { |
97 initDefaultDefines(defines); | 99 initDefaultDefines(defines); |
98 initDefaultCompilerFlags(includes); | 100 initDefaultCompilerFlags(includes); |
99 initDefaultLinkerFlags(); | 101 initDefaultLinkerFlags(); |
100 handleDB(); | 102 //handleDB(); |
101 } | 103 } |
102 | 104 |
103 | 105 |
104 protected void initDefaultCompilerFlags(Vector includes) { | 106 protected void initDefaultCompilerFlags(Vector<String> includes) { |
105 Vector compilerFlags = new Vector(); | 107 Vector compilerFlags = new Vector(); |
106 | 108 |
107 compilerFlags.addAll(getCI().getBaseCompilerFlags(getV("Define"), | 109 compilerFlags.addAll(getCI().getBaseCompilerFlags(getV("Define"), |
108 includes, | 110 includes, |
109 get("OutputDir"))); | 111 get("OutputDir"))); |
117 linkerFlags.addAll(getCI().getBaseLinkerFlags( get("OutputDir"), get("OutputDll"), get("PlatformName"))); | 119 linkerFlags.addAll(getCI().getBaseLinkerFlags( get("OutputDir"), get("OutputDll"), get("PlatformName"))); |
118 | 120 |
119 put("LinkerFlags", linkerFlags); | 121 put("LinkerFlags", linkerFlags); |
120 } | 122 } |
121 | 123 |
122 DirectoryTree getSourceTree(String sourceBase, String startAt) { | 124 public boolean matchesIgnoredPath(String path) { |
123 DirectoryTree tree = new DirectoryTree(); | 125 Vector<String> rv = new Vector<String>(); |
124 | |
125 tree.addSubdirToIgnore("Codemgr_wsdata"); | |
126 tree.addSubdirToIgnore("deleted_files"); | |
127 tree.addSubdirToIgnore("SCCS"); | |
128 if (startAt != null) { | |
129 tree.readDirectory(sourceBase + File.separator + startAt); | |
130 } else { | |
131 tree.readDirectory(sourceBase); | |
132 } | |
133 | |
134 return tree; | |
135 } | |
136 | |
137 | |
138 Vector getPreferredPaths() { | |
139 Vector preferredPaths = new Vector(); | |
140 | |
141 // In the case of multiple files with the same name in | |
142 // different subdirectories, prefer these versions | |
143 preferredPaths.add("windows"); | |
144 preferredPaths.add("x86"); | |
145 preferredPaths.add("closed"); | |
146 | |
147 // Also prefer "opto" over "adlc" for adlcVMDeps.hpp | |
148 preferredPaths.add("opto"); | |
149 | |
150 return preferredPaths; | |
151 } | |
152 | |
153 | |
154 void handleDB() { | |
155 WinGammaPlatform platform = (WinGammaPlatform)getField(null, "PlatformObject"); | |
156 | |
157 putSpecificField("AllFilesHash", computeAllFiles(platform)); | |
158 } | |
159 | |
160 | |
161 private boolean matchesIgnoredPath(String prefixedName) { | |
162 Vector rv = new Vector(); | |
163 collectRelevantVectors(rv, "IgnorePath"); | 126 collectRelevantVectors(rv, "IgnorePath"); |
164 for (Iterator i = rv.iterator(); i.hasNext(); ) { | 127 for (String pathPart : rv) { |
165 String pathPart = (String) i.next(); | 128 if (path.contains(pathPart)) { |
166 if (prefixedName.contains(Util.normalize(pathPart))) { | |
167 return true; | 129 return true; |
168 } | 130 } |
169 } | 131 } |
170 return false; | 132 return false; |
171 } | 133 } |
172 | 134 |
173 void addAll(Iterator i, Hashtable hash, | 135 public boolean matchesHidePath(String path) { |
174 WinGammaPlatform platform, DirectoryTree tree, | 136 Vector<String> rv = new Vector<String>(); |
175 Vector preferredPaths, Vector filesNotFound, Vector filesDuplicate) { | 137 collectRelevantVectors(rv, "HidePath"); |
176 for (; i.hasNext(); ) { | 138 for (String pathPart : rv) { |
177 String fileName = (String) i.next(); | 139 if (path.contains(Util.normalize(pathPart))) { |
178 if (lookupHashFieldInContext("IgnoreFile", fileName) == null) { | 140 return true; |
179 String prefixedName = platform.envVarPrefixedFileName(fileName, | 141 } |
180 0, /* ignored */ | 142 } |
181 tree, | 143 return false; |
182 preferredPaths, | 144 } |
183 filesNotFound, | 145 |
184 filesDuplicate); | 146 public Vector<String> matchesAdditionalGeneratedPath(String fullPath) { |
185 if (prefixedName != null) { | 147 Vector<String> rv = new Vector<String>(); |
186 prefixedName = Util.normalize(prefixedName); | 148 Hashtable<String, String> v = (Hashtable<String, String>)BuildConfig.getField(this.toString(), "AdditionalGeneratedFile"); |
187 if (!matchesIgnoredPath(prefixedName)) { | 149 if (v != null) { |
188 addTo(hash, prefixedName, fileName); | 150 for (Enumeration<String> e=v.keys(); e.hasMoreElements(); ) { |
189 } | 151 String key = e.nextElement(); |
152 String val = v.get(key); | |
153 | |
154 if (fullPath.endsWith(expandFormat(key))) { | |
155 rv.add(expandFormat(val)); | |
190 } | 156 } |
191 } | 157 } |
192 } | 158 } |
159 return rv; | |
193 } | 160 } |
194 | 161 |
195 void addTo(Hashtable ht, String key, String value) { | 162 void addTo(Hashtable ht, String key, String value) { |
196 ht.put(expandFormat(key), expandFormat(value)); | 163 ht.put(expandFormat(key), expandFormat(value)); |
197 } | |
198 | |
199 Hashtable computeAllFiles(WinGammaPlatform platform) { | |
200 Hashtable rv = new Hashtable(); | |
201 DirectoryTree tree = getSourceTree(get("SourceBase"), getFieldString(null, "StartAt")); | |
202 Vector preferredPaths = getPreferredPaths(); | |
203 | |
204 // Hold errors until end | |
205 Vector filesNotFound = new Vector(); | |
206 Vector filesDuplicate = new Vector(); | |
207 | |
208 Vector includedFiles = new Vector(); | |
209 | |
210 // find all files | |
211 Vector dirs = getSourceIncludes(); | |
212 for (Iterator i = dirs.iterator(); i.hasNext(); ) { | |
213 String dir = (String)i.next(); | |
214 DirectoryTree subtree = getSourceTree(dir, null); | |
215 for (Iterator fi = subtree.getFileIterator(); fi.hasNext(); ) { | |
216 String name = ((File)fi.next()).getName(); | |
217 includedFiles.add(name); | |
218 } | |
219 } | |
220 addAll(includedFiles.iterator(), rv, | |
221 platform, tree, | |
222 preferredPaths, filesNotFound, filesDuplicate); | |
223 | |
224 Vector addFiles = new Vector(); | |
225 collectRelevantVectors(addFiles, "AdditionalFile"); | |
226 addAll(addFiles.iterator(), rv, | |
227 platform, tree, | |
228 preferredPaths, filesNotFound, filesDuplicate); | |
229 | |
230 collectRelevantHashes(rv, "AdditionalGeneratedFile"); | |
231 | |
232 if ((filesNotFound.size() != 0) || | |
233 (filesDuplicate.size() != 0)) { | |
234 System.err.println("Error: some files were not found or " + | |
235 "appeared in multiple subdirectories of " + | |
236 "directory " + get("SourceBase") + " and could not " + | |
237 "be resolved with os_family and arch."); | |
238 if (filesNotFound.size() != 0) { | |
239 System.err.println("Files not found:"); | |
240 for (Iterator iter = filesNotFound.iterator(); | |
241 iter.hasNext(); ) { | |
242 System.err.println(" " + (String) iter.next()); | |
243 } | |
244 } | |
245 if (filesDuplicate.size() != 0) { | |
246 System.err.println("Duplicate files:"); | |
247 for (Iterator iter = filesDuplicate.iterator(); | |
248 iter.hasNext(); ) { | |
249 System.err.println(" " + (String) iter.next()); | |
250 } | |
251 } | |
252 throw new RuntimeException(); | |
253 } | |
254 | |
255 return rv; | |
256 } | 164 } |
257 | 165 |
258 void initDefaultDefines(Vector defines) { | 166 void initDefaultDefines(Vector defines) { |
259 Vector sysDefines = new Vector(); | 167 Vector sysDefines = new Vector(); |
260 | 168 |
356 void putSpecificField(String field, Object value) { | 264 void putSpecificField(String field, Object value) { |
357 putField(get("Id"), field, value); | 265 putField(get("Id"), field, value); |
358 } | 266 } |
359 | 267 |
360 void collectRelevantVectors(Vector rv, String field) { | 268 void collectRelevantVectors(Vector rv, String field) { |
361 for (int i = 0; i < context.length; i++) { | 269 for (String ctx : context) { |
362 Vector v = getFieldVector(context[i], field); | 270 Vector<String> v = getFieldVector(ctx, field); |
363 if (v != null) { | 271 if (v != null) { |
364 for (Iterator j=v.iterator(); j.hasNext(); ) { | 272 for (String val : v) { |
365 String val = (String)j.next(); | 273 rv.add(expandFormat(val).replace('/', '\\')); |
366 rv.add(expandFormat(val)); | |
367 } | 274 } |
368 } | 275 } |
369 } | 276 } |
370 } | 277 } |
371 | 278 |
372 void collectRelevantHashes(Hashtable rv, String field) { | 279 void collectRelevantHashes(Hashtable rv, String field) { |
373 for (int i = 0; i < context.length; i++) { | 280 for (String ctx : context) { |
374 Hashtable v = (Hashtable)getField(context[i], field); | 281 Hashtable v = (Hashtable)getField(ctx, field); |
375 if (v != null) { | 282 if (v != null) { |
376 for (Enumeration e=v.keys(); e.hasMoreElements(); ) { | 283 for (Enumeration e=v.keys(); e.hasMoreElements(); ) { |
377 String key = (String)e.nextElement(); | 284 String key = (String)e.nextElement(); |
378 String val = (String)v.get(key); | 285 String val = (String)v.get(key); |
379 addTo(rv, key, val); | 286 addTo(rv, key, val); |
389 return rv; | 296 return rv; |
390 } | 297 } |
391 | 298 |
392 Vector getIncludes() { | 299 Vector getIncludes() { |
393 Vector rv = new Vector(); | 300 Vector rv = new Vector(); |
394 | |
395 collectRelevantVectors(rv, "AbsoluteInclude"); | 301 collectRelevantVectors(rv, "AbsoluteInclude"); |
396 | |
397 rv.addAll(getSourceIncludes()); | 302 rv.addAll(getSourceIncludes()); |
398 | |
399 return rv; | 303 return rv; |
400 } | 304 } |
401 | 305 |
402 private Vector getSourceIncludes() { | 306 private Vector getSourceIncludes() { |
403 Vector rv = new Vector(); | 307 Vector<String> rv = new Vector<String>(); |
404 Vector ri = new Vector(); | 308 Vector<String> ri = new Vector<String>(); |
405 String sourceBase = getFieldString(null, "SourceBase"); | 309 String sourceBase = getFieldString(null, "SourceBase"); |
406 collectRelevantVectors(ri, "RelativeInclude"); | 310 collectRelevantVectors(ri, "RelativeInclude"); |
407 for (Iterator i = ri.iterator(); i.hasNext(); ) { | 311 for (String f : ri) { |
408 String f = (String)i.next(); | |
409 rv.add(sourceBase + Util.sep + f); | 312 rv.add(sourceBase + Util.sep + f); |
410 } | 313 } |
411 return rv; | 314 return rv; |
412 } | 315 } |
413 | 316 |
661 initNames("tiered", "fastdebug", "jvm.dll"); | 564 initNames("tiered", "fastdebug", "jvm.dll"); |
662 init(getIncludes(), getDefines()); | 565 init(getIncludes(), getDefines()); |
663 } | 566 } |
664 } | 567 } |
665 | 568 |
666 | |
667 abstract class ProductConfig extends BuildConfig { | 569 abstract class ProductConfig extends BuildConfig { |
668 protected void init(Vector includes, Vector defines) { | 570 protected void init(Vector includes, Vector defines) { |
669 defines.add("NDEBUG"); | 571 defines.add("NDEBUG"); |
670 defines.add("PRODUCT"); | 572 defines.add("PRODUCT"); |
671 | 573 |
702 initNames("tiered", "product", "jvm.dll"); | 604 initNames("tiered", "product", "jvm.dll"); |
703 init(getIncludes(), getDefines()); | 605 init(getIncludes(), getDefines()); |
704 } | 606 } |
705 } | 607 } |
706 | 608 |
707 | |
708 class CoreDebugConfig extends GenericDebugNonKernelConfig { | 609 class CoreDebugConfig extends GenericDebugNonKernelConfig { |
709 String getOptFlag() { | 610 String getOptFlag() { |
710 return getCI().getNoOptFlag(); | 611 return getCI().getNoOptFlag(); |
711 } | 612 } |
712 | 613 |
714 initNames("core", "debug", "jvm.dll"); | 615 initNames("core", "debug", "jvm.dll"); |
715 init(getIncludes(), getDefines()); | 616 init(getIncludes(), getDefines()); |
716 } | 617 } |
717 } | 618 } |
718 | 619 |
719 | |
720 class CoreFastDebugConfig extends GenericDebugNonKernelConfig { | 620 class CoreFastDebugConfig extends GenericDebugNonKernelConfig { |
721 String getOptFlag() { | 621 String getOptFlag() { |
722 return getCI().getOptFlag(); | 622 return getCI().getOptFlag(); |
723 } | 623 } |
724 | 624 |
725 CoreFastDebugConfig() { | 625 CoreFastDebugConfig() { |
726 initNames("core", "fastdebug", "jvm.dll"); | 626 initNames("core", "fastdebug", "jvm.dll"); |
727 init(getIncludes(), getDefines()); | 627 init(getIncludes(), getDefines()); |
728 } | 628 } |
729 } | 629 } |
730 | |
731 | 630 |
732 class CoreProductConfig extends ProductConfig { | 631 class CoreProductConfig extends ProductConfig { |
733 CoreProductConfig() { | 632 CoreProductConfig() { |
734 initNames("core", "product", "jvm.dll"); | 633 initNames("core", "product", "jvm.dll"); |
735 init(getIncludes(), getDefines()); | 634 init(getIncludes(), getDefines()); |
764 KernelProductConfig() { | 663 KernelProductConfig() { |
765 initNames("kernel", "product", "jvm.dll"); | 664 initNames("kernel", "product", "jvm.dll"); |
766 init(getIncludes(), getDefines()); | 665 init(getIncludes(), getDefines()); |
767 } | 666 } |
768 } | 667 } |
668 | |
769 abstract class CompilerInterface { | 669 abstract class CompilerInterface { |
770 abstract Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir); | 670 abstract Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir); |
771 abstract Vector getBaseLinkerFlags(String outDir, String outDll, String platformName); | 671 abstract Vector getBaseLinkerFlags(String outDir, String outDll, String platformName); |
772 abstract Vector getDebugCompilerFlags(String opt); | 672 abstract Vector getDebugCompilerFlags(String opt); |
773 abstract Vector getDebugLinkerFlags(); | 673 abstract Vector getDebugLinkerFlags(); |