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