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