Mercurial > hg > truffle
annotate src/share/tools/ProjectCreator/BuildConfig.java @ 2184:5d801e6b9a80
Imported build system changes from other repository.
author | Thomas Wuerthinger <thomas.wuerthinger@gmail.com> |
---|---|
date | Mon, 21 Feb 2011 19:17:10 +0100 |
parents | 06f017f7daa7 |
children | 2ab52cda08e5 |
rev | line source |
---|---|
0 | 1 /* |
1972 | 2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 import java.io.File; | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
26 import java.util.Enumeration; |
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
27 import java.util.Hashtable; |
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
28 import java.util.Iterator; |
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
29 import java.util.Vector; |
0 | 30 |
31 class BuildConfig { | |
32 Hashtable vars; | |
33 Vector basicNames, basicPaths; | |
34 String[] context; | |
35 | |
36 static CompilerInterface ci; | |
37 static CompilerInterface getCI() { | |
38 if (ci == null) { | |
39 String comp = (String)getField(null, "CompilerVersion"); | |
40 try { | |
41 ci = (CompilerInterface)Class.forName("CompilerInterface" + comp).newInstance(); | |
42 } catch (Exception cnfe) { | |
43 System.err.println("Cannot find support for compiler " + comp); | |
44 throw new RuntimeException(cnfe.toString()); | |
45 } | |
46 } | |
47 return ci; | |
48 } | |
49 | |
50 protected void initNames(String flavour, String build, String outDll) { | |
51 if (vars == null) vars = new Hashtable(); | |
52 | |
53 String flavourBuild = flavour + "_" + build; | |
1972 | 54 System.out.println(); |
55 System.out.println(flavourBuild); | |
56 | |
0 | 57 put("Name", getCI().makeCfgName(flavourBuild)); |
58 put("Flavour", flavour); | |
59 put("Build", build); | |
60 | |
61 // ones mentioned above were needed to expand format | |
62 String buildBase = expandFormat(getFieldString(null, "BuildBase")); | |
63 String sourceBase = getFieldString(null, "SourceBase"); | |
2184
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
64 String outDir = sourceBase + Util.sep + "java"; |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
65 if (Util.os().equals("x64")) { |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
66 outDir += "64"; |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
67 } |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
68 if (!build.equals("product")) { |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
69 outDir += Util.sep + "fastdebug"; |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
70 } |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
71 outDir += Util.sep + "jre" + Util.sep + "bin"; |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
72 if (flavour.equals("compiler1")) { |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
73 outDir += Util.sep + "client"; |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
74 } else { |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
75 outDir += Util.sep + "server"; |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
76 } |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
77 buildBase = outDir; |
0 | 78 |
79 put("Id", flavourBuild); | |
80 put("OutputDir", outDir); | |
81 put("SourceBase", sourceBase); | |
82 put("BuildBase", buildBase); | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
83 put("OutputDll", outDir + Util.sep + outDll); |
0 | 84 |
85 context = new String [] {flavourBuild, flavour, build, null}; | |
86 } | |
87 | |
88 protected void init(Vector includes, Vector defines) { | |
89 initDefaultDefines(defines); | |
90 initDefaultCompilerFlags(includes); | |
91 initDefaultLinkerFlags(); | |
1972 | 92 handleDB(); |
0 | 93 } |
94 | |
95 | |
96 protected void initDefaultCompilerFlags(Vector includes) { | |
97 Vector compilerFlags = new Vector(); | |
98 | |
99 compilerFlags.addAll(getCI().getBaseCompilerFlags(getV("Define"), | |
100 includes, | |
101 get("OutputDir"))); | |
102 | |
103 put("CompilerFlags", compilerFlags); | |
104 } | |
105 | |
106 protected void initDefaultLinkerFlags() { | |
107 Vector linkerFlags = new Vector(); | |
108 | |
109 linkerFlags.addAll(getCI().getBaseLinkerFlags( get("OutputDir"), get("OutputDll"))); | |
110 | |
111 put("LinkerFlags", linkerFlags); | |
112 } | |
113 | |
114 DirectoryTree getSourceTree(String sourceBase, String startAt) { | |
115 DirectoryTree tree = new DirectoryTree(); | |
116 | |
117 tree.addSubdirToIgnore("Codemgr_wsdata"); | |
118 tree.addSubdirToIgnore("deleted_files"); | |
119 tree.addSubdirToIgnore("SCCS"); | |
120 tree.setVerbose(true); | |
121 if (startAt != null) { | |
122 tree.readDirectory(sourceBase + File.separator + startAt); | |
123 } else { | |
124 tree.readDirectory(sourceBase); | |
125 } | |
126 | |
127 return tree; | |
128 } | |
129 | |
130 | |
1972 | 131 Vector getPreferredPaths(MacroDefinitions macros) { |
0 | 132 Vector preferredPaths = new Vector(); |
133 // In the case of multiple files with the same name in | |
134 // different subdirectories, prefer the versions specified in | |
135 // the platform file as the "os_family" and "arch" macros. | |
1972 | 136 for (Iterator iter = macros.getMacros(); iter.hasNext(); ) { |
0 | 137 Macro macro = (Macro) iter.next(); |
138 if (macro.name.equals("os_family") || | |
139 macro.name.equals("arch")) { | |
140 preferredPaths.add(macro.contents); | |
141 } | |
142 } | |
143 // Also prefer "opto" over "adlc" for adlcVMDeps.hpp | |
144 preferredPaths.add("opto"); | |
145 | |
146 return preferredPaths; | |
147 } | |
148 | |
149 | |
1972 | 150 void handleDB() { |
0 | 151 WinGammaPlatform platform = (WinGammaPlatform)getField(null, "PlatformObject"); |
152 | |
1972 | 153 File incls = new File(get("OutputDir")+Util.sep+"incls"); |
0 | 154 |
1972 | 155 incls.mkdirs(); |
0 | 156 |
1972 | 157 MacroDefinitions macros = new MacroDefinitions(); |
158 try { | |
159 macros.readFrom(getFieldString(null, "Platform"), false); | |
0 | 160 } catch (Exception e) { |
1972 | 161 throw new RuntimeException(e); |
0 | 162 } |
163 | |
1972 | 164 putSpecificField("AllFilesHash", computeAllFiles(platform, macros)); |
0 | 165 } |
166 | |
167 | |
1972 | 168 private boolean matchesIgnoredPath(String prefixedName) { |
169 Vector rv = new Vector(); | |
170 collectRelevantVectors(rv, "IgnorePath"); | |
171 for (Iterator i = rv.iterator(); i.hasNext(); ) { | |
172 String pathPart = (String) i.next(); | |
173 if (prefixedName.contains(Util.normalize(pathPart))) { | |
174 return true; | |
175 } | |
176 } | |
177 return false; | |
178 } | |
179 | |
0 | 180 void addAll(Iterator i, Hashtable hash, |
181 WinGammaPlatform platform, DirectoryTree tree, | |
182 Vector preferredPaths, Vector filesNotFound, Vector filesDuplicate) { | |
183 for (; i.hasNext(); ) { | |
184 String fileName = (String) i.next(); | |
185 if (lookupHashFieldInContext("IgnoreFile", fileName) == null) { | |
186 String prefixedName = platform.envVarPrefixedFileName(fileName, | |
187 0, /* ignored */ | |
188 tree, | |
189 preferredPaths, | |
190 filesNotFound, | |
191 filesDuplicate); | |
192 if (prefixedName != null) { | |
1972 | 193 prefixedName = Util.normalize(prefixedName); |
194 if (!matchesIgnoredPath(prefixedName)) { | |
195 addTo(hash, prefixedName, fileName); | |
196 } | |
0 | 197 } |
198 } | |
199 } | |
200 } | |
201 | |
202 void addTo(Hashtable ht, String key, String value) { | |
203 ht.put(expandFormat(key), expandFormat(value)); | |
204 } | |
205 | |
1972 | 206 Hashtable computeAllFiles(WinGammaPlatform platform, MacroDefinitions macros) { |
0 | 207 Hashtable rv = new Hashtable(); |
208 DirectoryTree tree = getSourceTree(get("SourceBase"), getFieldString(null, "StartAt")); | |
1972 | 209 Vector preferredPaths = getPreferredPaths(macros); |
0 | 210 |
211 // Hold errors until end | |
212 Vector filesNotFound = new Vector(); | |
213 Vector filesDuplicate = new Vector(); | |
214 | |
1972 | 215 Vector includedFiles = new Vector(); |
0 | 216 |
217 // find all files | |
1972 | 218 Vector dirs = getSourceIncludes(); |
219 for (Iterator i = dirs.iterator(); i.hasNext(); ) { | |
220 String dir = (String)i.next(); | |
221 DirectoryTree subtree = getSourceTree(dir, null); | |
222 for (Iterator fi = subtree.getFileIterator(); fi.hasNext(); ) { | |
223 String name = ((File)fi.next()).getName(); | |
224 includedFiles.add(name); | |
225 } | |
0 | 226 } |
1972 | 227 addAll(includedFiles.iterator(), rv, |
0 | 228 platform, tree, |
229 preferredPaths, filesNotFound, filesDuplicate); | |
230 | |
231 Vector addFiles = new Vector(); | |
232 collectRelevantVectors(addFiles, "AdditionalFile"); | |
233 addAll(addFiles.iterator(), rv, | |
234 platform, tree, | |
235 preferredPaths, filesNotFound, filesDuplicate); | |
236 | |
237 collectRelevantHashes(rv, "AdditionalGeneratedFile"); | |
238 | |
239 if ((filesNotFound.size() != 0) || | |
240 (filesDuplicate.size() != 0)) { | |
241 System.err.println("Error: some files were not found or " + | |
242 "appeared in multiple subdirectories of " + | |
243 "directory " + get("SourceBase") + " and could not " + | |
244 "be resolved with the os_family and arch " + | |
245 "macros in the platform file."); | |
246 if (filesNotFound.size() != 0) { | |
247 System.err.println("Files not found:"); | |
248 for (Iterator iter = filesNotFound.iterator(); | |
249 iter.hasNext(); ) { | |
250 System.err.println(" " + (String) iter.next()); | |
251 } | |
252 } | |
253 if (filesDuplicate.size() != 0) { | |
254 System.err.println("Duplicate files:"); | |
255 for (Iterator iter = filesDuplicate.iterator(); | |
256 iter.hasNext(); ) { | |
257 System.err.println(" " + (String) iter.next()); | |
258 } | |
259 } | |
260 throw new RuntimeException(); | |
261 } | |
262 | |
263 return rv; | |
264 } | |
265 | |
266 void initDefaultDefines(Vector defines) { | |
267 Vector sysDefines = new Vector(); | |
2184
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
268 |
1408
0ba67bb5392c
added c1x build directory, added MSVC Win64 project support
lstadler
parents:
844
diff
changeset
|
269 if( Util.os().equals("Win32")) { |
2184
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
270 sysDefines.add("WIN32"); |
1408
0ba67bb5392c
added c1x build directory, added MSVC Win64 project support
lstadler
parents:
844
diff
changeset
|
271 sysDefines.add("HOTSPOT_LIB_ARCH=\\\"i386\\\""); |
0ba67bb5392c
added c1x build directory, added MSVC Win64 project support
lstadler
parents:
844
diff
changeset
|
272 } else { |
2184
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
273 sysDefines.add("_AMD64_"); |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
274 sysDefines.add("AMD64"); |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
275 sysDefines.add("_WIN64"); |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
276 sysDefines.add("_LP64"); |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
277 if (System.getenv("MSC_VER") != null) |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
278 sysDefines.add("MSC_VER=" + System.getenv("MSC_VER")); |
1408
0ba67bb5392c
added c1x build directory, added MSVC Win64 project support
lstadler
parents:
844
diff
changeset
|
279 sysDefines.add("HOTSPOT_LIB_ARCH=\\\"amd64\\\""); |
0ba67bb5392c
added c1x build directory, added MSVC Win64 project support
lstadler
parents:
844
diff
changeset
|
280 } |
2184
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
281 |
0 | 282 sysDefines.add("_WINDOWS"); |
2184
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
283 sysDefines.add("HOTSPOT_BUILD_USER=\\\""+System.getProperty("user.name")+"\\\""); |
0 | 284 sysDefines.add("HOTSPOT_BUILD_TARGET=\\\""+get("Build")+"\\\""); |
285 sysDefines.add("_JNI_IMPLEMENTATION_"); | |
2184
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
286 sysDefines.add("HOTSPOT_LIB_ARCH=\\\"i386\\\""); |
0 | 287 |
288 sysDefines.addAll(defines); | |
289 | |
290 put("Define", sysDefines); | |
291 } | |
292 | |
293 String get(String key) { | |
294 return (String)vars.get(key); | |
295 } | |
296 | |
297 Vector getV(String key) { | |
298 return (Vector)vars.get(key); | |
299 } | |
300 | |
301 Object getO(String key) { | |
302 return vars.get(key); | |
303 } | |
304 | |
305 Hashtable getH(String key) { | |
306 return (Hashtable)vars.get(key); | |
307 } | |
308 | |
309 Object getFieldInContext(String field) { | |
310 for (int i=0; i<context.length; i++) { | |
311 Object rv = getField(context[i], field); | |
312 if (rv != null) { | |
313 return rv; | |
314 } | |
315 } | |
316 return null; | |
317 } | |
318 | |
319 Object lookupHashFieldInContext(String field, String key) { | |
320 for (int i=0; i<context.length; i++) { | |
321 Hashtable ht = (Hashtable)getField(context[i], field); | |
322 if (ht != null) { | |
323 Object rv = ht.get(key); | |
324 if (rv != null) { | |
325 return rv; | |
326 } | |
327 } | |
328 } | |
329 return null; | |
330 } | |
331 | |
332 void put(String key, String value) { | |
333 vars.put(key, value); | |
334 } | |
335 | |
336 void put(String key, Vector vvalue) { | |
337 vars.put(key, vvalue); | |
338 } | |
339 | |
340 void add(String key, Vector vvalue) { | |
341 getV(key).addAll(vvalue); | |
342 } | |
343 | |
344 String flavour() { | |
345 return get("Flavour"); | |
346 } | |
347 | |
348 String build() { | |
349 return get("Build"); | |
350 } | |
351 | |
2184
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
352 String outputDir() { |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
353 return get("OutputDir"); |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
354 } |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
355 |
0 | 356 Object getSpecificField(String field) { |
357 return getField(get("Id"), field); | |
358 } | |
359 | |
360 void putSpecificField(String field, Object value) { | |
361 putField(get("Id"), field, value); | |
362 } | |
363 | |
364 void collectRelevantVectors(Vector rv, String field) { | |
365 for (int i = 0; i < context.length; i++) { | |
366 Vector v = getFieldVector(context[i], field); | |
367 if (v != null) { | |
368 for (Iterator j=v.iterator(); j.hasNext(); ) { | |
369 String val = (String)j.next(); | |
370 rv.add(expandFormat(val)); | |
371 } | |
372 } | |
373 } | |
374 } | |
375 | |
376 void collectRelevantHashes(Hashtable rv, String field) { | |
377 for (int i = 0; i < context.length; i++) { | |
378 Hashtable v = (Hashtable)getField(context[i], field); | |
379 if (v != null) { | |
380 for (Enumeration e=v.keys(); e.hasMoreElements(); ) { | |
381 String key = (String)e.nextElement(); | |
382 String val = (String)v.get(key); | |
383 addTo(rv, key, val); | |
384 } | |
385 } | |
386 } | |
387 } | |
388 | |
389 | |
390 Vector getDefines() { | |
391 Vector rv = new Vector(); | |
392 collectRelevantVectors(rv, "Define"); | |
393 return rv; | |
394 } | |
395 | |
396 Vector getIncludes() { | |
397 Vector rv = new Vector(); | |
398 | |
399 collectRelevantVectors(rv, "AbsoluteInclude"); | |
400 | |
1972 | 401 rv.addAll(getSourceIncludes()); |
402 | |
403 return rv; | |
404 } | |
405 | |
406 private Vector getSourceIncludes() { | |
407 Vector rv = new Vector(); | |
0 | 408 Vector ri = new Vector(); |
409 String sourceBase = getFieldString(null, "SourceBase"); | |
410 collectRelevantVectors(ri, "RelativeInclude"); | |
411 for (Iterator i = ri.iterator(); i.hasNext(); ) { | |
412 String f = (String)i.next(); | |
413 rv.add(sourceBase + Util.sep + f); | |
414 } | |
415 return rv; | |
416 } | |
417 | |
418 static Hashtable cfgData = new Hashtable(); | |
419 static Hashtable globalData = new Hashtable(); | |
420 | |
421 static boolean appliesToTieredBuild(String cfg) { | |
422 return (cfg != null && | |
423 (cfg.startsWith("compiler1") || | |
424 cfg.startsWith("compiler2"))); | |
425 } | |
426 | |
1972 | 427 // Filters out the IgnoreFile and IgnorePaths since they are |
428 // handled specially for tiered builds. | |
0 | 429 static boolean appliesToTieredBuild(String cfg, String key) { |
1972 | 430 return (appliesToTieredBuild(cfg))&& (key != null && !key.startsWith("Ignore")); |
0 | 431 } |
432 | |
433 static String getTieredBuildCfg(String cfg) { | |
434 assert appliesToTieredBuild(cfg) : "illegal configuration " + cfg; | |
435 return "tiered" + cfg.substring(9); | |
436 } | |
437 | |
438 static Object getField(String cfg, String field) { | |
439 if (cfg == null) { | |
440 return globalData.get(field); | |
441 } | |
442 | |
443 Hashtable ht = (Hashtable)cfgData.get(cfg); | |
444 return ht == null ? null : ht.get(field); | |
445 } | |
446 | |
447 static String getFieldString(String cfg, String field) { | |
448 return (String)getField(cfg, field); | |
449 } | |
450 | |
451 static Vector getFieldVector(String cfg, String field) { | |
452 return (Vector)getField(cfg, field); | |
453 } | |
454 | |
455 static void putField(String cfg, String field, Object value) { | |
456 putFieldImpl(cfg, field, value); | |
457 if (appliesToTieredBuild(cfg, field)) { | |
458 putFieldImpl(getTieredBuildCfg(cfg), field, value); | |
459 } | |
460 } | |
461 | |
462 private static void putFieldImpl(String cfg, String field, Object value) { | |
463 if (cfg == null) { | |
464 globalData.put(field, value); | |
465 return; | |
466 } | |
467 | |
468 Hashtable ht = (Hashtable)cfgData.get(cfg); | |
469 if (ht == null) { | |
470 ht = new Hashtable(); | |
471 cfgData.put(cfg, ht); | |
472 } | |
473 | |
474 ht.put(field, value); | |
475 } | |
476 | |
477 static Object getFieldHash(String cfg, String field, String name) { | |
478 Hashtable ht = (Hashtable)getField(cfg, field); | |
479 | |
480 return ht == null ? null : ht.get(name); | |
481 } | |
482 | |
483 static void putFieldHash(String cfg, String field, String name, Object val) { | |
484 putFieldHashImpl(cfg, field, name, val); | |
1972 | 485 if (appliesToTieredBuild(cfg, field)) { |
0 | 486 putFieldHashImpl(getTieredBuildCfg(cfg), field, name, val); |
487 } | |
488 } | |
489 | |
490 private static void putFieldHashImpl(String cfg, String field, String name, Object val) { | |
491 Hashtable ht = (Hashtable)getField(cfg, field); | |
492 | |
493 if (ht == null) { | |
494 ht = new Hashtable(); | |
495 putFieldImpl(cfg, field, ht); | |
496 } | |
497 | |
498 ht.put(name, val); | |
499 } | |
500 | |
501 static void addFieldVector(String cfg, String field, String element) { | |
502 addFieldVectorImpl(cfg, field, element); | |
1972 | 503 if (appliesToTieredBuild(cfg, field)) { |
0 | 504 addFieldVectorImpl(getTieredBuildCfg(cfg), field, element); |
505 } | |
506 } | |
507 | |
508 private static void addFieldVectorImpl(String cfg, String field, String element) { | |
509 Vector v = (Vector)getField(cfg, field); | |
510 | |
511 if (v == null) { | |
512 v = new Vector(); | |
513 putFieldImpl(cfg, field, v); | |
514 } | |
515 | |
516 v.add(element); | |
517 } | |
518 | |
519 String expandFormat(String format) { | |
520 if (format == null) { | |
521 return null; | |
522 } | |
523 | |
524 if (format.indexOf('%') == -1) { | |
525 return format; | |
526 } | |
527 | |
528 StringBuffer sb = new StringBuffer(); | |
529 int len = format.length(); | |
530 for (int i=0; i<len; i++) { | |
531 char ch = format.charAt(i); | |
532 if (ch == '%') { | |
533 char ch1 = format.charAt(i+1); | |
534 switch (ch1) { | |
535 case '%': | |
536 sb.append(ch1); | |
537 break; | |
538 case 'b': | |
539 sb.append(build()); | |
540 break; | |
541 case 'f': | |
542 sb.append(flavour()); | |
543 break; | |
2184
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
544 case 'o': |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
545 sb.append(outputDir()); |
5d801e6b9a80
Imported build system changes from other repository.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
2044
diff
changeset
|
546 break; |
0 | 547 default: |
548 sb.append(ch); | |
549 sb.append(ch1); | |
550 } | |
551 i++; | |
552 } else { | |
553 sb.append(ch); | |
554 } | |
555 } | |
556 | |
557 return sb.toString(); | |
558 } | |
559 } | |
560 | |
561 abstract class GenericDebugConfig extends BuildConfig { | |
562 abstract String getOptFlag(); | |
563 | |
564 protected void init(Vector includes, Vector defines) { | |
565 defines.add("_DEBUG"); | |
566 defines.add("ASSERT"); | |
567 | |
568 super.init(includes, defines); | |
569 | |
570 getV("CompilerFlags").addAll(getCI().getDebugCompilerFlags(getOptFlag())); | |
571 getV("LinkerFlags").addAll(getCI().getDebugLinkerFlags()); | |
572 } | |
573 } | |
574 | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
575 abstract class GenericDebugNonKernelConfig extends GenericDebugConfig { |
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
576 protected void init(Vector includes, Vector defines) { |
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
577 super.init(includes, defines); |
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
578 getCI().getAdditionalNonKernelLinkerFlags(getV("LinkerFlags")); |
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
579 } |
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
580 } |
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
581 |
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
582 class C1DebugConfig extends GenericDebugNonKernelConfig { |
0 | 583 String getOptFlag() { |
584 return getCI().getNoOptFlag(); | |
585 } | |
586 | |
587 C1DebugConfig() { | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
588 initNames("compiler1", "debug", "jvm.dll"); |
0 | 589 init(getIncludes(), getDefines()); |
590 } | |
591 } | |
592 | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
593 class C1FastDebugConfig extends GenericDebugNonKernelConfig { |
0 | 594 String getOptFlag() { |
595 return getCI().getOptFlag(); | |
596 } | |
597 | |
598 C1FastDebugConfig() { | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
599 initNames("compiler1", "fastdebug", "jvm.dll"); |
0 | 600 init(getIncludes(), getDefines()); |
601 } | |
602 } | |
603 | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
604 class C2DebugConfig extends GenericDebugNonKernelConfig { |
0 | 605 String getOptFlag() { |
606 return getCI().getNoOptFlag(); | |
607 } | |
608 | |
609 C2DebugConfig() { | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
610 initNames("compiler2", "debug", "jvm.dll"); |
0 | 611 init(getIncludes(), getDefines()); |
612 } | |
613 } | |
614 | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
615 class C2FastDebugConfig extends GenericDebugNonKernelConfig { |
0 | 616 String getOptFlag() { |
617 return getCI().getOptFlag(); | |
618 } | |
619 | |
620 C2FastDebugConfig() { | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
621 initNames("compiler2", "fastdebug", "jvm.dll"); |
0 | 622 init(getIncludes(), getDefines()); |
623 } | |
624 } | |
625 | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
626 class TieredDebugConfig extends GenericDebugNonKernelConfig { |
0 | 627 String getOptFlag() { |
628 return getCI().getNoOptFlag(); | |
629 } | |
630 | |
631 TieredDebugConfig() { | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
632 initNames("tiered", "debug", "jvm.dll"); |
0 | 633 init(getIncludes(), getDefines()); |
634 } | |
635 } | |
636 | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
637 class TieredFastDebugConfig extends GenericDebugNonKernelConfig { |
0 | 638 String getOptFlag() { |
639 return getCI().getOptFlag(); | |
640 } | |
641 | |
642 TieredFastDebugConfig() { | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
643 initNames("tiered", "fastdebug", "jvm.dll"); |
0 | 644 init(getIncludes(), getDefines()); |
645 } | |
646 } | |
647 | |
648 | |
649 abstract class ProductConfig extends BuildConfig { | |
650 protected void init(Vector includes, Vector defines) { | |
651 defines.add("NDEBUG"); | |
652 defines.add("PRODUCT"); | |
653 | |
654 super.init(includes, defines); | |
655 | |
656 getV("CompilerFlags").addAll(getCI().getProductCompilerFlags()); | |
657 getV("LinkerFlags").addAll(getCI().getProductLinkerFlags()); | |
658 } | |
659 } | |
660 | |
661 class C1ProductConfig extends ProductConfig { | |
662 C1ProductConfig() { | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
663 initNames("compiler1", "product", "jvm.dll"); |
0 | 664 init(getIncludes(), getDefines()); |
665 } | |
666 } | |
667 | |
668 class C2ProductConfig extends ProductConfig { | |
669 C2ProductConfig() { | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
670 initNames("compiler2", "product", "jvm.dll"); |
0 | 671 init(getIncludes(), getDefines()); |
672 } | |
673 } | |
674 | |
675 class TieredProductConfig extends ProductConfig { | |
676 TieredProductConfig() { | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
677 initNames("tiered", "product", "jvm.dll"); |
0 | 678 init(getIncludes(), getDefines()); |
679 } | |
680 } | |
681 | |
682 | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
683 class CoreDebugConfig extends GenericDebugNonKernelConfig { |
0 | 684 String getOptFlag() { |
685 return getCI().getNoOptFlag(); | |
686 } | |
687 | |
688 CoreDebugConfig() { | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
689 initNames("core", "debug", "jvm.dll"); |
0 | 690 init(getIncludes(), getDefines()); |
691 } | |
692 } | |
693 | |
694 | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
695 class CoreFastDebugConfig extends GenericDebugNonKernelConfig { |
0 | 696 String getOptFlag() { |
697 return getCI().getOptFlag(); | |
698 } | |
699 | |
700 CoreFastDebugConfig() { | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
701 initNames("core", "fastdebug", "jvm.dll"); |
0 | 702 init(getIncludes(), getDefines()); |
703 } | |
704 } | |
705 | |
706 | |
707 class CoreProductConfig extends ProductConfig { | |
708 CoreProductConfig() { | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
709 initNames("core", "product", "jvm.dll"); |
0 | 710 init(getIncludes(), getDefines()); |
711 } | |
712 } | |
713 | |
714 class KernelDebugConfig extends GenericDebugConfig { | |
715 String getOptFlag() { | |
716 return getCI().getNoOptFlag(); | |
717 } | |
718 | |
719 KernelDebugConfig() { | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
720 initNames("kernel", "debug", "jvm.dll"); |
0 | 721 init(getIncludes(), getDefines()); |
722 } | |
723 } | |
724 | |
725 | |
726 class KernelFastDebugConfig extends GenericDebugConfig { | |
727 String getOptFlag() { | |
728 return getCI().getOptFlag(); | |
729 } | |
730 | |
731 KernelFastDebugConfig() { | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
732 initNames("kernel", "fastdebug", "jvm.dll"); |
0 | 733 init(getIncludes(), getDefines()); |
734 } | |
735 } | |
736 | |
737 | |
738 class KernelProductConfig extends ProductConfig { | |
739 KernelProductConfig() { | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
740 initNames("kernel", "product", "jvm.dll"); |
0 | 741 init(getIncludes(), getDefines()); |
742 } | |
743 } | |
744 abstract class CompilerInterface { | |
745 abstract Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir); | |
746 abstract Vector getBaseLinkerFlags(String outDir, String outDll); | |
747 abstract Vector getDebugCompilerFlags(String opt); | |
748 abstract Vector getDebugLinkerFlags(); | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
749 abstract void getAdditionalNonKernelLinkerFlags(Vector rv); |
0 | 750 abstract Vector getProductCompilerFlags(); |
751 abstract Vector getProductLinkerFlags(); | |
752 abstract String getOptFlag(); | |
753 abstract String getNoOptFlag(); | |
754 abstract String makeCfgName(String flavourBuild); | |
755 | |
756 void addAttr(Vector receiver, String attr, String value) { | |
757 receiver.add(attr); receiver.add(value); | |
758 } | |
2027
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
759 void extAttr(Vector receiver, String attr, String value) { |
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
760 int attr_pos=receiver.indexOf(attr) ; |
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
761 if ( attr_pos == -1) { |
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
762 // If attr IS NOT present in the Vector - add it |
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
763 receiver.add(attr); receiver.add(value); |
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
764 } else { |
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
765 // If attr IS present in the Vector - append value to it |
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
766 receiver.set(attr_pos+1,receiver.get(attr_pos+1)+value); |
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
767 } |
aa6e219afbf1
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
1972
diff
changeset
|
768 } |
0 | 769 } |