annotate src/share/tools/ProjectCreator/WinGammaPlatform.java @ 1972:f95d63e2154a

6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
author stefank
date Tue, 23 Nov 2010 13:22:55 -0800
parents src/share/tools/MakeDeps/WinGammaPlatform.java@c18cbe5936b8
children aa6e219afbf1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
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: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
26 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 abstract class HsArgHandler extends ArgHandler {
a61af66fc99e Initial load
duke
parents:
diff changeset
29 static final int STRING = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 static final int VECTOR = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 static final int HASH = 3;
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 boolean nextNotKey(ArgIterator it) {
a61af66fc99e Initial load
duke
parents:
diff changeset
34 if (it.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
35 String s = it.get();
a61af66fc99e Initial load
duke
parents:
diff changeset
36 return (s.length() == 0) || (s.charAt(0) != '-');
a61af66fc99e Initial load
duke
parents:
diff changeset
37 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
38 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 }
a61af66fc99e Initial load
duke
parents:
diff changeset
40 }
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 void empty(String key, String message) {
a61af66fc99e Initial load
duke
parents:
diff changeset
43 if (key != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 System.err.println("** Error: empty " + key);
a61af66fc99e Initial load
duke
parents:
diff changeset
45 }
a61af66fc99e Initial load
duke
parents:
diff changeset
46 if (message != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 System.err.println(message);
a61af66fc99e Initial load
duke
parents:
diff changeset
48 }
a61af66fc99e Initial load
duke
parents:
diff changeset
49 WinGammaPlatform.usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
50 }
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 static String getCfg(String val) {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 int under = val.indexOf('_');
a61af66fc99e Initial load
duke
parents:
diff changeset
54 int len = val.length();
a61af66fc99e Initial load
duke
parents:
diff changeset
55 if (under != -1 && under < len - 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 return val.substring(under+1, len);
a61af66fc99e Initial load
duke
parents:
diff changeset
57 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
59 }
a61af66fc99e Initial load
duke
parents:
diff changeset
60 }
a61af66fc99e Initial load
duke
parents:
diff changeset
61 }
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 class ArgRuleSpecific extends ArgRule {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 ArgRuleSpecific(String arg, ArgHandler handler) {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 super(arg, handler);
a61af66fc99e Initial load
duke
parents:
diff changeset
66 }
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 boolean match(String rulePattern, String arg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
69 return rulePattern.startsWith(arg);
a61af66fc99e Initial load
duke
parents:
diff changeset
70 }
a61af66fc99e Initial load
duke
parents:
diff changeset
71 }
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 class SpecificHsArgHandler extends HsArgHandler {
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 String message, argKey, valKey;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 int type;
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 public void handle(ArgIterator it) {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 String cfg = getCfg(it.get());
a61af66fc99e Initial load
duke
parents:
diff changeset
81 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
82 String val = it.get();
a61af66fc99e Initial load
duke
parents:
diff changeset
83 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 case VECTOR:
a61af66fc99e Initial load
duke
parents:
diff changeset
85 BuildConfig.addFieldVector(cfg, valKey, val);
a61af66fc99e Initial load
duke
parents:
diff changeset
86 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 case HASH:
a61af66fc99e Initial load
duke
parents:
diff changeset
88 BuildConfig.putFieldHash(cfg, valKey, val, "1");
a61af66fc99e Initial load
duke
parents:
diff changeset
89 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 case STRING:
a61af66fc99e Initial load
duke
parents:
diff changeset
91 BuildConfig.putField(cfg, valKey, val);
a61af66fc99e Initial load
duke
parents:
diff changeset
92 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
93 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
94 empty(valKey, "Unknown type: "+type);
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }
a61af66fc99e Initial load
duke
parents:
diff changeset
96 it.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 empty(argKey, message);
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
101 }
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 SpecificHsArgHandler(String argKey, String valKey, String message, int type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 this.argKey = argKey;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 this.valKey = valKey;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 this.message = message;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 this.type = type;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 class HsArgRule extends ArgRuleSpecific {
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 HsArgRule(String argKey, String valKey, String message, int type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 super(argKey, new SpecificHsArgHandler(argKey, valKey, message, type));
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
120 public abstract class WinGammaPlatform {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 public boolean fileNameStringEquality(String s1, String s2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 return s1.equalsIgnoreCase(s2);
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 static void usage() throws IllegalArgumentException {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 System.err.println("WinGammaPlatform platform-specific options:");
a61af66fc99e Initial load
duke
parents:
diff changeset
128 System.err.println(" -sourceBase <path to directory (workspace) " +
a61af66fc99e Initial load
duke
parents:
diff changeset
129 "containing source files; no trailing slash>");
a61af66fc99e Initial load
duke
parents:
diff changeset
130 System.err.println(" -projectFileName <full pathname to which project file " +
a61af66fc99e Initial load
duke
parents:
diff changeset
131 "will be written; all parent directories must " +
a61af66fc99e Initial load
duke
parents:
diff changeset
132 "already exist>");
a61af66fc99e Initial load
duke
parents:
diff changeset
133 System.err.println(" If any of the above are specified, "+
a61af66fc99e Initial load
duke
parents:
diff changeset
134 "they must all be.");
a61af66fc99e Initial load
duke
parents:
diff changeset
135 System.err.println(" Additional, optional arguments, which can be " +
a61af66fc99e Initial load
duke
parents:
diff changeset
136 "specified multiple times:");
a61af66fc99e Initial load
duke
parents:
diff changeset
137 System.err.println(" -absoluteInclude <string containing absolute " +
a61af66fc99e Initial load
duke
parents:
diff changeset
138 "path to include directory>");
a61af66fc99e Initial load
duke
parents:
diff changeset
139 System.err.println(" -relativeInclude <string containing include " +
a61af66fc99e Initial load
duke
parents:
diff changeset
140 "directory relative to -sourceBase>");
a61af66fc99e Initial load
duke
parents:
diff changeset
141 System.err.println(" -define <preprocessor flag to be #defined " +
a61af66fc99e Initial load
duke
parents:
diff changeset
142 "(note: doesn't yet support " +
a61af66fc99e Initial load
duke
parents:
diff changeset
143 "#define (flag) (value))>");
a61af66fc99e Initial load
duke
parents:
diff changeset
144 System.err.println(" -startAt <subdir of sourceBase>");
a61af66fc99e Initial load
duke
parents:
diff changeset
145 System.err.println(" -additionalFile <file not in database but " +
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
146 "which should show up in project file>");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
147 System.err.println(" -additionalGeneratedFile <absolute path to " +
a61af66fc99e Initial load
duke
parents:
diff changeset
148 "directory containing file; no trailing slash> " +
a61af66fc99e Initial load
duke
parents:
diff changeset
149 "<name of file generated later in the build process>");
a61af66fc99e Initial load
duke
parents:
diff changeset
150 throw new IllegalArgumentException();
a61af66fc99e Initial load
duke
parents:
diff changeset
151 }
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 public void addPerFileLine(Hashtable table,
a61af66fc99e Initial load
duke
parents:
diff changeset
155 String fileName,
a61af66fc99e Initial load
duke
parents:
diff changeset
156 String line) {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 Vector v = (Vector) table.get(fileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
158 if (v != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 v.add(line);
a61af66fc99e Initial load
duke
parents:
diff changeset
160 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
161 v = new Vector();
a61af66fc99e Initial load
duke
parents:
diff changeset
162 v.add(line);
a61af66fc99e Initial load
duke
parents:
diff changeset
163 table.put(fileName, v);
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 protected static class PerFileCondData {
a61af66fc99e Initial load
duke
parents:
diff changeset
168 public String releaseString;
a61af66fc99e Initial load
duke
parents:
diff changeset
169 public String debugString;
a61af66fc99e Initial load
duke
parents:
diff changeset
170 }
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 protected void addConditionalPerFileLine(Hashtable table,
a61af66fc99e Initial load
duke
parents:
diff changeset
173 String fileName,
a61af66fc99e Initial load
duke
parents:
diff changeset
174 String releaseLine,
a61af66fc99e Initial load
duke
parents:
diff changeset
175 String debugLine) {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 PerFileCondData data = new PerFileCondData();
a61af66fc99e Initial load
duke
parents:
diff changeset
177 data.releaseString = releaseLine;
a61af66fc99e Initial load
duke
parents:
diff changeset
178 data.debugString = debugLine;
a61af66fc99e Initial load
duke
parents:
diff changeset
179 Vector v = (Vector) table.get(fileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
180 if (v != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 v.add(data);
a61af66fc99e Initial load
duke
parents:
diff changeset
182 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 v = new Vector();
a61af66fc99e Initial load
duke
parents:
diff changeset
184 v.add(data);
a61af66fc99e Initial load
duke
parents:
diff changeset
185 table.put(fileName, v);
a61af66fc99e Initial load
duke
parents:
diff changeset
186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 protected static class PrelinkCommandData {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 String description;
a61af66fc99e Initial load
duke
parents:
diff changeset
191 String commands;
a61af66fc99e Initial load
duke
parents:
diff changeset
192 }
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194 protected void addPrelinkCommand(Hashtable table,
a61af66fc99e Initial load
duke
parents:
diff changeset
195 String build,
a61af66fc99e Initial load
duke
parents:
diff changeset
196 String description,
a61af66fc99e Initial load
duke
parents:
diff changeset
197 String commands) {
a61af66fc99e Initial load
duke
parents:
diff changeset
198 PrelinkCommandData data = new PrelinkCommandData();
a61af66fc99e Initial load
duke
parents:
diff changeset
199 data.description = description;
a61af66fc99e Initial load
duke
parents:
diff changeset
200 data.commands = commands;
a61af66fc99e Initial load
duke
parents:
diff changeset
201 table.put(build, data);
a61af66fc99e Initial load
duke
parents:
diff changeset
202 }
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 public boolean findString(Vector v, String s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 for (Iterator iter = v.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 if (((String) iter.next()).equals(s)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 /* This returns a String containing the full path to the passed
a61af66fc99e Initial load
duke
parents:
diff changeset
215 file name, or null if an error occurred. If the file was not
a61af66fc99e Initial load
duke
parents:
diff changeset
216 found or was a duplicate and couldn't be resolved using the
a61af66fc99e Initial load
duke
parents:
diff changeset
217 preferred paths, the file name is added to the appropriate
a61af66fc99e Initial load
duke
parents:
diff changeset
218 Vector of Strings. */
a61af66fc99e Initial load
duke
parents:
diff changeset
219 private String findFileInDirectory(String fileName,
a61af66fc99e Initial load
duke
parents:
diff changeset
220 DirectoryTree directory,
a61af66fc99e Initial load
duke
parents:
diff changeset
221 Vector preferredPaths,
a61af66fc99e Initial load
duke
parents:
diff changeset
222 Vector filesNotFound,
a61af66fc99e Initial load
duke
parents:
diff changeset
223 Vector filesDuplicate) {
a61af66fc99e Initial load
duke
parents:
diff changeset
224 List locationsInTree = directory.findFile(fileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
225 int rootNameLength = directory.getRootNodeName().length();
a61af66fc99e Initial load
duke
parents:
diff changeset
226 String name = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
227 if ((locationsInTree == null) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
228 (locationsInTree.size() == 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
229 filesNotFound.add(fileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
230 } else if (locationsInTree.size() > 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // We shouldn't have duplicate file names in our workspace.
a61af66fc99e Initial load
duke
parents:
diff changeset
232 System.err.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
233 System.err.println("There are multiple files named as: " + fileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
234 System.exit(-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
235 // The following code could be safely removed if we don't need duplicate
a61af66fc99e Initial load
duke
parents:
diff changeset
236 // file names.
a61af66fc99e Initial load
duke
parents:
diff changeset
237
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // Iterate through them, trying to find one with a
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // preferred path
a61af66fc99e Initial load
duke
parents:
diff changeset
240 search:
a61af66fc99e Initial load
duke
parents:
diff changeset
241 {
a61af66fc99e Initial load
duke
parents:
diff changeset
242 for (Iterator locIter = locationsInTree.iterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
243 locIter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
244 DirectoryTreeNode node =
a61af66fc99e Initial load
duke
parents:
diff changeset
245 (DirectoryTreeNode) locIter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
246 String tmpName = node.getName();
a61af66fc99e Initial load
duke
parents:
diff changeset
247 for (Iterator prefIter = preferredPaths.iterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
248 prefIter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
249 // We need to make sure the preferred path is
a61af66fc99e Initial load
duke
parents:
diff changeset
250 // found from the file path not including the root node name.
a61af66fc99e Initial load
duke
parents:
diff changeset
251 if (tmpName.indexOf((String)prefIter.next(),
a61af66fc99e Initial load
duke
parents:
diff changeset
252 rootNameLength) != -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
253 name = tmpName;
a61af66fc99e Initial load
duke
parents:
diff changeset
254 break search;
a61af66fc99e Initial load
duke
parents:
diff changeset
255 }
a61af66fc99e Initial load
duke
parents:
diff changeset
256 }
a61af66fc99e Initial load
duke
parents:
diff changeset
257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
258 }
a61af66fc99e Initial load
duke
parents:
diff changeset
259
a61af66fc99e Initial load
duke
parents:
diff changeset
260 if (name == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 filesDuplicate.add(fileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
263 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
264 name = ((DirectoryTreeNode) locationsInTree.get(0)).getName();
a61af66fc99e Initial load
duke
parents:
diff changeset
265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
266
a61af66fc99e Initial load
duke
parents:
diff changeset
267 return name;
a61af66fc99e Initial load
duke
parents:
diff changeset
268 }
a61af66fc99e Initial load
duke
parents:
diff changeset
269
a61af66fc99e Initial load
duke
parents:
diff changeset
270 protected String envVarPrefixedFileName(String fileName,
a61af66fc99e Initial load
duke
parents:
diff changeset
271 int sourceBaseLen,
a61af66fc99e Initial load
duke
parents:
diff changeset
272 DirectoryTree tree,
a61af66fc99e Initial load
duke
parents:
diff changeset
273 Vector preferredPaths,
a61af66fc99e Initial load
duke
parents:
diff changeset
274 Vector filesNotFound,
a61af66fc99e Initial load
duke
parents:
diff changeset
275 Vector filesDuplicate) {
a61af66fc99e Initial load
duke
parents:
diff changeset
276 String fullName = findFileInDirectory(fileName,
a61af66fc99e Initial load
duke
parents:
diff changeset
277 tree,
a61af66fc99e Initial load
duke
parents:
diff changeset
278 preferredPaths,
a61af66fc99e Initial load
duke
parents:
diff changeset
279 filesNotFound,
a61af66fc99e Initial load
duke
parents:
diff changeset
280 filesDuplicate);
a61af66fc99e Initial load
duke
parents:
diff changeset
281 return fullName;
a61af66fc99e Initial load
duke
parents:
diff changeset
282 }
a61af66fc99e Initial load
duke
parents:
diff changeset
283
a61af66fc99e Initial load
duke
parents:
diff changeset
284 String getProjectName(String fullPath, String extension)
a61af66fc99e Initial load
duke
parents:
diff changeset
285 throws IllegalArgumentException, IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 File file = new File(fullPath).getCanonicalFile();
a61af66fc99e Initial load
duke
parents:
diff changeset
287 fullPath = file.getCanonicalPath();
a61af66fc99e Initial load
duke
parents:
diff changeset
288 String parent = file.getParent();
a61af66fc99e Initial load
duke
parents:
diff changeset
289
a61af66fc99e Initial load
duke
parents:
diff changeset
290 if (!fullPath.endsWith(extension)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
291 throw new IllegalArgumentException("project file name \"" +
a61af66fc99e Initial load
duke
parents:
diff changeset
292 fullPath +
a61af66fc99e Initial load
duke
parents:
diff changeset
293 "\" does not end in "+extension);
a61af66fc99e Initial load
duke
parents:
diff changeset
294 }
a61af66fc99e Initial load
duke
parents:
diff changeset
295
a61af66fc99e Initial load
duke
parents:
diff changeset
296 if ((parent != null) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
297 (!fullPath.startsWith(parent))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
298 throw new RuntimeException(
a61af66fc99e Initial load
duke
parents:
diff changeset
299 "Internal error: parent of file name \"" + parent +
a61af66fc99e Initial load
duke
parents:
diff changeset
300 "\" does not match file name \"" + fullPath + "\""
a61af66fc99e Initial load
duke
parents:
diff changeset
301 );
a61af66fc99e Initial load
duke
parents:
diff changeset
302 }
a61af66fc99e Initial load
duke
parents:
diff changeset
303
a61af66fc99e Initial load
duke
parents:
diff changeset
304 int len = parent.length();
a61af66fc99e Initial load
duke
parents:
diff changeset
305 if (!parent.endsWith(Util.sep)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
306 len += Util.sep.length();
a61af66fc99e Initial load
duke
parents:
diff changeset
307 }
a61af66fc99e Initial load
duke
parents:
diff changeset
308
a61af66fc99e Initial load
duke
parents:
diff changeset
309 int end = fullPath.length() - extension.length();
a61af66fc99e Initial load
duke
parents:
diff changeset
310
a61af66fc99e Initial load
duke
parents:
diff changeset
311 if (len == end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
312 throw new RuntimeException(
a61af66fc99e Initial load
duke
parents:
diff changeset
313 "Internal error: file name was empty"
a61af66fc99e Initial load
duke
parents:
diff changeset
314 );
a61af66fc99e Initial load
duke
parents:
diff changeset
315 }
a61af66fc99e Initial load
duke
parents:
diff changeset
316
a61af66fc99e Initial load
duke
parents:
diff changeset
317 return fullPath.substring(len, end);
a61af66fc99e Initial load
duke
parents:
diff changeset
318 }
a61af66fc99e Initial load
duke
parents:
diff changeset
319
a61af66fc99e Initial load
duke
parents:
diff changeset
320 protected abstract String getProjectExt();
a61af66fc99e Initial load
duke
parents:
diff changeset
321
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
322 public void createVcproj(String[] args)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
323 throws IllegalArgumentException, IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
324
a61af66fc99e Initial load
duke
parents:
diff changeset
325 parseArguments(args);
a61af66fc99e Initial load
duke
parents:
diff changeset
326
a61af66fc99e Initial load
duke
parents:
diff changeset
327 String projectFileName = BuildConfig.getFieldString(null, "ProjectFileName");
a61af66fc99e Initial load
duke
parents:
diff changeset
328 String ext = getProjectExt();
a61af66fc99e Initial load
duke
parents:
diff changeset
329
a61af66fc99e Initial load
duke
parents:
diff changeset
330 String projectName = getProjectName(projectFileName, ext);
a61af66fc99e Initial load
duke
parents:
diff changeset
331
a61af66fc99e Initial load
duke
parents:
diff changeset
332 writeProjectFile(projectFileName, projectName, createAllConfigs());
a61af66fc99e Initial load
duke
parents:
diff changeset
333 }
a61af66fc99e Initial load
duke
parents:
diff changeset
334
a61af66fc99e Initial load
duke
parents:
diff changeset
335 protected void writePrologue(String[] args) {
a61af66fc99e Initial load
duke
parents:
diff changeset
336 System.err.println("WinGammaPlatform platform-specific arguments:");
a61af66fc99e Initial load
duke
parents:
diff changeset
337 for (int i = 0; i < args.length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
338 System.err.print(args[i] + " ");
a61af66fc99e Initial load
duke
parents:
diff changeset
339 }
a61af66fc99e Initial load
duke
parents:
diff changeset
340 System.err.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
341 }
a61af66fc99e Initial load
duke
parents:
diff changeset
342
a61af66fc99e Initial load
duke
parents:
diff changeset
343
a61af66fc99e Initial load
duke
parents:
diff changeset
344 void parseArguments(String[] args) {
a61af66fc99e Initial load
duke
parents:
diff changeset
345 new ArgsParser(args,
a61af66fc99e Initial load
duke
parents:
diff changeset
346 new ArgRule[]
a61af66fc99e Initial load
duke
parents:
diff changeset
347 {
a61af66fc99e Initial load
duke
parents:
diff changeset
348 new HsArgRule("-sourceBase",
a61af66fc99e Initial load
duke
parents:
diff changeset
349 "SourceBase",
a61af66fc99e Initial load
duke
parents:
diff changeset
350 " (Did you set the HotSpotWorkSpace environment variable?)",
a61af66fc99e Initial load
duke
parents:
diff changeset
351 HsArgHandler.STRING
a61af66fc99e Initial load
duke
parents:
diff changeset
352 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
353
a61af66fc99e Initial load
duke
parents:
diff changeset
354 new HsArgRule("-buildBase",
a61af66fc99e Initial load
duke
parents:
diff changeset
355 "BuildBase",
a61af66fc99e Initial load
duke
parents:
diff changeset
356 " (Did you set the HotSpotBuildSpace environment variable?)",
a61af66fc99e Initial load
duke
parents:
diff changeset
357 HsArgHandler.STRING
a61af66fc99e Initial load
duke
parents:
diff changeset
358 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
359
a61af66fc99e Initial load
duke
parents:
diff changeset
360 new HsArgRule("-projectFileName",
a61af66fc99e Initial load
duke
parents:
diff changeset
361 "ProjectFileName",
a61af66fc99e Initial load
duke
parents:
diff changeset
362 null,
a61af66fc99e Initial load
duke
parents:
diff changeset
363 HsArgHandler.STRING
a61af66fc99e Initial load
duke
parents:
diff changeset
364 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
365
a61af66fc99e Initial load
duke
parents:
diff changeset
366 new HsArgRule("-jdkTargetRoot",
a61af66fc99e Initial load
duke
parents:
diff changeset
367 "JdkTargetRoot",
a61af66fc99e Initial load
duke
parents:
diff changeset
368 " (Did you set the HotSpotJDKDist environment variable?)",
a61af66fc99e Initial load
duke
parents:
diff changeset
369 HsArgHandler.STRING
a61af66fc99e Initial load
duke
parents:
diff changeset
370 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
371
a61af66fc99e Initial load
duke
parents:
diff changeset
372 new HsArgRule("-compiler",
a61af66fc99e Initial load
duke
parents:
diff changeset
373 "CompilerVersion",
a61af66fc99e Initial load
duke
parents:
diff changeset
374 " (Did you set the VcVersion correctly?)",
a61af66fc99e Initial load
duke
parents:
diff changeset
375 HsArgHandler.STRING
a61af66fc99e Initial load
duke
parents:
diff changeset
376 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
377
a61af66fc99e Initial load
duke
parents:
diff changeset
378 new HsArgRule("-platform",
a61af66fc99e Initial load
duke
parents:
diff changeset
379 "Platform",
a61af66fc99e Initial load
duke
parents:
diff changeset
380 null,
a61af66fc99e Initial load
duke
parents:
diff changeset
381 HsArgHandler.STRING
a61af66fc99e Initial load
duke
parents:
diff changeset
382 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
383
a61af66fc99e Initial load
duke
parents:
diff changeset
384 new HsArgRule("-absoluteInclude",
a61af66fc99e Initial load
duke
parents:
diff changeset
385 "AbsoluteInclude",
a61af66fc99e Initial load
duke
parents:
diff changeset
386 null,
a61af66fc99e Initial load
duke
parents:
diff changeset
387 HsArgHandler.VECTOR
a61af66fc99e Initial load
duke
parents:
diff changeset
388 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
389
a61af66fc99e Initial load
duke
parents:
diff changeset
390 new HsArgRule("-relativeInclude",
a61af66fc99e Initial load
duke
parents:
diff changeset
391 "RelativeInclude",
a61af66fc99e Initial load
duke
parents:
diff changeset
392 null,
a61af66fc99e Initial load
duke
parents:
diff changeset
393 HsArgHandler.VECTOR
a61af66fc99e Initial load
duke
parents:
diff changeset
394 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
395
a61af66fc99e Initial load
duke
parents:
diff changeset
396 new HsArgRule("-define",
a61af66fc99e Initial load
duke
parents:
diff changeset
397 "Define",
a61af66fc99e Initial load
duke
parents:
diff changeset
398 null,
a61af66fc99e Initial load
duke
parents:
diff changeset
399 HsArgHandler.VECTOR
a61af66fc99e Initial load
duke
parents:
diff changeset
400 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
401
a61af66fc99e Initial load
duke
parents:
diff changeset
402 new HsArgRule("-useToGeneratePch",
a61af66fc99e Initial load
duke
parents:
diff changeset
403 "UseToGeneratePch",
a61af66fc99e Initial load
duke
parents:
diff changeset
404 null,
a61af66fc99e Initial load
duke
parents:
diff changeset
405 HsArgHandler.STRING
a61af66fc99e Initial load
duke
parents:
diff changeset
406 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
407
a61af66fc99e Initial load
duke
parents:
diff changeset
408 new ArgRuleSpecific("-perFileLine",
a61af66fc99e Initial load
duke
parents:
diff changeset
409 new HsArgHandler() {
a61af66fc99e Initial load
duke
parents:
diff changeset
410 public void handle(ArgIterator it) {
a61af66fc99e Initial load
duke
parents:
diff changeset
411 String cfg = getCfg(it.get());
a61af66fc99e Initial load
duke
parents:
diff changeset
412 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
413 String fileName = it.get();
a61af66fc99e Initial load
duke
parents:
diff changeset
414 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
415 String line = it.get();
a61af66fc99e Initial load
duke
parents:
diff changeset
416 BuildConfig.putFieldHash(cfg, "PerFileLine", fileName, line);
a61af66fc99e Initial load
duke
parents:
diff changeset
417 it.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
418 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
419 }
a61af66fc99e Initial load
duke
parents:
diff changeset
420 }
a61af66fc99e Initial load
duke
parents:
diff changeset
421 empty(null, "** Error: wrong number of args to -perFileLine");
a61af66fc99e Initial load
duke
parents:
diff changeset
422 }
a61af66fc99e Initial load
duke
parents:
diff changeset
423 }
a61af66fc99e Initial load
duke
parents:
diff changeset
424 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
425
a61af66fc99e Initial load
duke
parents:
diff changeset
426 new ArgRuleSpecific("-conditionalPerFileLine",
a61af66fc99e Initial load
duke
parents:
diff changeset
427 new HsArgHandler() {
a61af66fc99e Initial load
duke
parents:
diff changeset
428 public void handle(ArgIterator it) {
a61af66fc99e Initial load
duke
parents:
diff changeset
429 String cfg = getCfg(it.get());
a61af66fc99e Initial load
duke
parents:
diff changeset
430 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
431 String fileName = it.get();
a61af66fc99e Initial load
duke
parents:
diff changeset
432 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
433 String productLine = it.get();
a61af66fc99e Initial load
duke
parents:
diff changeset
434 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
435 String debugLine = it.get();
a61af66fc99e Initial load
duke
parents:
diff changeset
436 BuildConfig.putFieldHash(cfg+"_debug", "CondPerFileLine",
a61af66fc99e Initial load
duke
parents:
diff changeset
437 fileName, debugLine);
a61af66fc99e Initial load
duke
parents:
diff changeset
438 BuildConfig.putFieldHash(cfg+"_product", "CondPerFileLine",
a61af66fc99e Initial load
duke
parents:
diff changeset
439 fileName, productLine);
a61af66fc99e Initial load
duke
parents:
diff changeset
440 it.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
441 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
442 }
a61af66fc99e Initial load
duke
parents:
diff changeset
443 }
a61af66fc99e Initial load
duke
parents:
diff changeset
444 }
a61af66fc99e Initial load
duke
parents:
diff changeset
445
a61af66fc99e Initial load
duke
parents:
diff changeset
446 empty(null, "** Error: wrong number of args to -conditionalPerFileLine");
a61af66fc99e Initial load
duke
parents:
diff changeset
447 }
a61af66fc99e Initial load
duke
parents:
diff changeset
448 }
a61af66fc99e Initial load
duke
parents:
diff changeset
449 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
450
a61af66fc99e Initial load
duke
parents:
diff changeset
451 new HsArgRule("-disablePch",
a61af66fc99e Initial load
duke
parents:
diff changeset
452 "DisablePch",
a61af66fc99e Initial load
duke
parents:
diff changeset
453 null,
a61af66fc99e Initial load
duke
parents:
diff changeset
454 HsArgHandler.HASH
a61af66fc99e Initial load
duke
parents:
diff changeset
455 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
456
a61af66fc99e Initial load
duke
parents:
diff changeset
457 new ArgRule("-startAt",
a61af66fc99e Initial load
duke
parents:
diff changeset
458 new HsArgHandler() {
a61af66fc99e Initial load
duke
parents:
diff changeset
459 public void handle(ArgIterator it) {
a61af66fc99e Initial load
duke
parents:
diff changeset
460 if (BuildConfig.getField(null, "StartAt") != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
461 empty(null, "** Error: multiple -startAt");
a61af66fc99e Initial load
duke
parents:
diff changeset
462 }
a61af66fc99e Initial load
duke
parents:
diff changeset
463 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
464 BuildConfig.putField(null, "StartAt", it.get());
a61af66fc99e Initial load
duke
parents:
diff changeset
465 it.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
466 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
467 empty("-startAt", null);
a61af66fc99e Initial load
duke
parents:
diff changeset
468 }
a61af66fc99e Initial load
duke
parents:
diff changeset
469 }
a61af66fc99e Initial load
duke
parents:
diff changeset
470 }
a61af66fc99e Initial load
duke
parents:
diff changeset
471 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
472
a61af66fc99e Initial load
duke
parents:
diff changeset
473 new HsArgRule("-ignoreFile",
a61af66fc99e Initial load
duke
parents:
diff changeset
474 "IgnoreFile",
a61af66fc99e Initial load
duke
parents:
diff changeset
475 null,
a61af66fc99e Initial load
duke
parents:
diff changeset
476 HsArgHandler.HASH
a61af66fc99e Initial load
duke
parents:
diff changeset
477 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
478
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
479 new HsArgRule("-ignorePath",
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
480 "IgnorePath",
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
481 null,
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
482 HsArgHandler.VECTOR
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
483 ),
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
484
0
a61af66fc99e Initial load
duke
parents:
diff changeset
485 new HsArgRule("-additionalFile",
a61af66fc99e Initial load
duke
parents:
diff changeset
486 "AdditionalFile",
a61af66fc99e Initial load
duke
parents:
diff changeset
487 null,
a61af66fc99e Initial load
duke
parents:
diff changeset
488 HsArgHandler.VECTOR
a61af66fc99e Initial load
duke
parents:
diff changeset
489 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
490
a61af66fc99e Initial load
duke
parents:
diff changeset
491 new ArgRuleSpecific("-additionalGeneratedFile",
a61af66fc99e Initial load
duke
parents:
diff changeset
492 new HsArgHandler() {
a61af66fc99e Initial load
duke
parents:
diff changeset
493 public void handle(ArgIterator it) {
a61af66fc99e Initial load
duke
parents:
diff changeset
494 String cfg = getCfg(it.get());
a61af66fc99e Initial load
duke
parents:
diff changeset
495 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
496 String dir = it.get();
a61af66fc99e Initial load
duke
parents:
diff changeset
497 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
498 String fileName = it.get();
a61af66fc99e Initial load
duke
parents:
diff changeset
499 BuildConfig.putFieldHash(cfg, "AdditionalGeneratedFile",
a61af66fc99e Initial load
duke
parents:
diff changeset
500 Util.normalize(dir + Util.sep + fileName),
a61af66fc99e Initial load
duke
parents:
diff changeset
501 fileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
502 it.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
503 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
504 }
a61af66fc99e Initial load
duke
parents:
diff changeset
505 }
a61af66fc99e Initial load
duke
parents:
diff changeset
506 empty(null, "** Error: wrong number of args to -additionalGeneratedFile");
a61af66fc99e Initial load
duke
parents:
diff changeset
507 }
a61af66fc99e Initial load
duke
parents:
diff changeset
508 }
a61af66fc99e Initial load
duke
parents:
diff changeset
509 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
510
a61af66fc99e Initial load
duke
parents:
diff changeset
511 new ArgRule("-prelink",
a61af66fc99e Initial load
duke
parents:
diff changeset
512 new HsArgHandler() {
a61af66fc99e Initial load
duke
parents:
diff changeset
513 public void handle(ArgIterator it) {
a61af66fc99e Initial load
duke
parents:
diff changeset
514 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
515 String build = it.get();
a61af66fc99e Initial load
duke
parents:
diff changeset
516 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
517 String description = it.get();
a61af66fc99e Initial load
duke
parents:
diff changeset
518 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
519 String command = it.get();
a61af66fc99e Initial load
duke
parents:
diff changeset
520 BuildConfig.putField(null, "PrelinkDescription", description);
a61af66fc99e Initial load
duke
parents:
diff changeset
521 BuildConfig.putField(null, "PrelinkCommand", command);
a61af66fc99e Initial load
duke
parents:
diff changeset
522 it.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
523 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
524 }
a61af66fc99e Initial load
duke
parents:
diff changeset
525 }
a61af66fc99e Initial load
duke
parents:
diff changeset
526 }
a61af66fc99e Initial load
duke
parents:
diff changeset
527
a61af66fc99e Initial load
duke
parents:
diff changeset
528 empty(null, "** Error: wrong number of args to -prelink");
a61af66fc99e Initial load
duke
parents:
diff changeset
529 }
a61af66fc99e Initial load
duke
parents:
diff changeset
530 }
a61af66fc99e Initial load
duke
parents:
diff changeset
531 )
a61af66fc99e Initial load
duke
parents:
diff changeset
532 },
a61af66fc99e Initial load
duke
parents:
diff changeset
533 new ArgHandler() {
a61af66fc99e Initial load
duke
parents:
diff changeset
534 public void handle(ArgIterator it) {
a61af66fc99e Initial load
duke
parents:
diff changeset
535
a61af66fc99e Initial load
duke
parents:
diff changeset
536 throw new RuntimeException("Arg Parser: unrecognized option "+it.get());
a61af66fc99e Initial load
duke
parents:
diff changeset
537 }
a61af66fc99e Initial load
duke
parents:
diff changeset
538 }
a61af66fc99e Initial load
duke
parents:
diff changeset
539 );
a61af66fc99e Initial load
duke
parents:
diff changeset
540 if (BuildConfig.getField(null, "SourceBase") == null ||
a61af66fc99e Initial load
duke
parents:
diff changeset
541 BuildConfig.getField(null, "BuildBase") == null ||
a61af66fc99e Initial load
duke
parents:
diff changeset
542 BuildConfig.getField(null, "ProjectFileName") == null ||
a61af66fc99e Initial load
duke
parents:
diff changeset
543 BuildConfig.getField(null, "CompilerVersion") == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
544 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
545 }
a61af66fc99e Initial load
duke
parents:
diff changeset
546
a61af66fc99e Initial load
duke
parents:
diff changeset
547 if (BuildConfig.getField(null, "UseToGeneratePch") == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
548 throw new RuntimeException("ERROR: need to specify one file to compute PCH, with -useToGeneratePch flag");
a61af66fc99e Initial load
duke
parents:
diff changeset
549 }
a61af66fc99e Initial load
duke
parents:
diff changeset
550
a61af66fc99e Initial load
duke
parents:
diff changeset
551 BuildConfig.putField(null, "PlatformObject", this);
a61af66fc99e Initial load
duke
parents:
diff changeset
552 }
a61af66fc99e Initial load
duke
parents:
diff changeset
553
a61af66fc99e Initial load
duke
parents:
diff changeset
554 Vector createAllConfigs() {
a61af66fc99e Initial load
duke
parents:
diff changeset
555 Vector allConfigs = new Vector();
a61af66fc99e Initial load
duke
parents:
diff changeset
556
a61af66fc99e Initial load
duke
parents:
diff changeset
557 allConfigs.add(new C1DebugConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
558
a61af66fc99e Initial load
duke
parents:
diff changeset
559 boolean b = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
560 if (b) {
a61af66fc99e Initial load
duke
parents:
diff changeset
561 allConfigs.add(new C1FastDebugConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
562 allConfigs.add(new C1ProductConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
563
a61af66fc99e Initial load
duke
parents:
diff changeset
564 allConfigs.add(new C2DebugConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
565 allConfigs.add(new C2FastDebugConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
566 allConfigs.add(new C2ProductConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
567
a61af66fc99e Initial load
duke
parents:
diff changeset
568 allConfigs.add(new TieredDebugConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
569 allConfigs.add(new TieredFastDebugConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
570 allConfigs.add(new TieredProductConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
571
a61af66fc99e Initial load
duke
parents:
diff changeset
572 allConfigs.add(new CoreDebugConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
573 allConfigs.add(new CoreFastDebugConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
574 allConfigs.add(new CoreProductConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
575
a61af66fc99e Initial load
duke
parents:
diff changeset
576 allConfigs.add(new KernelDebugConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
577 allConfigs.add(new KernelFastDebugConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
578 allConfigs.add(new KernelProductConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
579 }
a61af66fc99e Initial load
duke
parents:
diff changeset
580
a61af66fc99e Initial load
duke
parents:
diff changeset
581 return allConfigs;
a61af66fc99e Initial load
duke
parents:
diff changeset
582 }
a61af66fc99e Initial load
duke
parents:
diff changeset
583
a61af66fc99e Initial load
duke
parents:
diff changeset
584 class FileAttribute {
a61af66fc99e Initial load
duke
parents:
diff changeset
585 int numConfigs;
a61af66fc99e Initial load
duke
parents:
diff changeset
586 Vector configs;
a61af66fc99e Initial load
duke
parents:
diff changeset
587 String shortName;
a61af66fc99e Initial load
duke
parents:
diff changeset
588 boolean noPch, pchRoot;
a61af66fc99e Initial load
duke
parents:
diff changeset
589
a61af66fc99e Initial load
duke
parents:
diff changeset
590 FileAttribute(String shortName, BuildConfig cfg, int numConfigs) {
a61af66fc99e Initial load
duke
parents:
diff changeset
591 this.shortName = shortName;
a61af66fc99e Initial load
duke
parents:
diff changeset
592 this.noPch = (cfg.lookupHashFieldInContext("DisablePch", shortName) != null);
a61af66fc99e Initial load
duke
parents:
diff changeset
593 this.pchRoot = shortName.equals(BuildConfig.getFieldString(null, "UseToGeneratePch"));
a61af66fc99e Initial load
duke
parents:
diff changeset
594 this.numConfigs = numConfigs;
a61af66fc99e Initial load
duke
parents:
diff changeset
595
a61af66fc99e Initial load
duke
parents:
diff changeset
596 configs = new Vector();
a61af66fc99e Initial load
duke
parents:
diff changeset
597 add(cfg.get("Name"));
a61af66fc99e Initial load
duke
parents:
diff changeset
598 }
a61af66fc99e Initial load
duke
parents:
diff changeset
599
a61af66fc99e Initial load
duke
parents:
diff changeset
600 void add(String confName) {
a61af66fc99e Initial load
duke
parents:
diff changeset
601 configs.add(confName);
a61af66fc99e Initial load
duke
parents:
diff changeset
602
a61af66fc99e Initial load
duke
parents:
diff changeset
603 // if presented in all configs
a61af66fc99e Initial load
duke
parents:
diff changeset
604 if (configs.size() == numConfigs) {
a61af66fc99e Initial load
duke
parents:
diff changeset
605 configs = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
606 }
a61af66fc99e Initial load
duke
parents:
diff changeset
607 }
a61af66fc99e Initial load
duke
parents:
diff changeset
608 }
a61af66fc99e Initial load
duke
parents:
diff changeset
609
a61af66fc99e Initial load
duke
parents:
diff changeset
610 class FileInfo implements Comparable {
a61af66fc99e Initial load
duke
parents:
diff changeset
611 String full;
a61af66fc99e Initial load
duke
parents:
diff changeset
612 FileAttribute attr;
a61af66fc99e Initial load
duke
parents:
diff changeset
613
a61af66fc99e Initial load
duke
parents:
diff changeset
614 FileInfo(String full, FileAttribute attr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
615 this.full = full;
a61af66fc99e Initial load
duke
parents:
diff changeset
616 this.attr = attr;
a61af66fc99e Initial load
duke
parents:
diff changeset
617 }
a61af66fc99e Initial load
duke
parents:
diff changeset
618
a61af66fc99e Initial load
duke
parents:
diff changeset
619 public int compareTo(Object o) {
a61af66fc99e Initial load
duke
parents:
diff changeset
620 FileInfo oo = (FileInfo)o;
a61af66fc99e Initial load
duke
parents:
diff changeset
621 // Don't squelch identical short file names where the full
a61af66fc99e Initial load
duke
parents:
diff changeset
622 // paths are different
a61af66fc99e Initial load
duke
parents:
diff changeset
623 if (!attr.shortName.equals(oo.attr.shortName))
a61af66fc99e Initial load
duke
parents:
diff changeset
624 return attr.shortName.compareTo(oo.attr.shortName);
a61af66fc99e Initial load
duke
parents:
diff changeset
625 return full.compareTo(oo.full);
a61af66fc99e Initial load
duke
parents:
diff changeset
626 }
a61af66fc99e Initial load
duke
parents:
diff changeset
627
a61af66fc99e Initial load
duke
parents:
diff changeset
628 boolean isHeader() {
a61af66fc99e Initial load
duke
parents:
diff changeset
629 return attr.shortName.endsWith(".h") || attr.shortName.endsWith(".hpp");
a61af66fc99e Initial load
duke
parents:
diff changeset
630 }
a61af66fc99e Initial load
duke
parents:
diff changeset
631 }
a61af66fc99e Initial load
duke
parents:
diff changeset
632
a61af66fc99e Initial load
duke
parents:
diff changeset
633
a61af66fc99e Initial load
duke
parents:
diff changeset
634 TreeSet sortFiles(Hashtable allFiles) {
a61af66fc99e Initial load
duke
parents:
diff changeset
635 TreeSet rv = new TreeSet();
a61af66fc99e Initial load
duke
parents:
diff changeset
636 Enumeration e = allFiles.keys();
a61af66fc99e Initial load
duke
parents:
diff changeset
637 while (e.hasMoreElements()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
638 String fullPath = (String)e.nextElement();
a61af66fc99e Initial load
duke
parents:
diff changeset
639 rv.add(new FileInfo(fullPath, (FileAttribute)allFiles.get(fullPath)));
a61af66fc99e Initial load
duke
parents:
diff changeset
640 }
a61af66fc99e Initial load
duke
parents:
diff changeset
641 return rv;
a61af66fc99e Initial load
duke
parents:
diff changeset
642 }
a61af66fc99e Initial load
duke
parents:
diff changeset
643
a61af66fc99e Initial load
duke
parents:
diff changeset
644 Hashtable computeAttributedFiles(Vector allConfigs) {
a61af66fc99e Initial load
duke
parents:
diff changeset
645 Hashtable ht = new Hashtable();
a61af66fc99e Initial load
duke
parents:
diff changeset
646 int numConfigs = allConfigs.size();
a61af66fc99e Initial load
duke
parents:
diff changeset
647
a61af66fc99e Initial load
duke
parents:
diff changeset
648 for (Iterator i = allConfigs.iterator(); i.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
649 BuildConfig bc = (BuildConfig)i.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
650 Hashtable confFiles = (Hashtable)bc.getSpecificField("AllFilesHash");
a61af66fc99e Initial load
duke
parents:
diff changeset
651 String confName = bc.get("Name");
a61af66fc99e Initial load
duke
parents:
diff changeset
652
a61af66fc99e Initial load
duke
parents:
diff changeset
653 for (Enumeration e=confFiles.keys(); e.hasMoreElements(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
654 String filePath = (String)e.nextElement();
a61af66fc99e Initial load
duke
parents:
diff changeset
655 FileAttribute fa = (FileAttribute)ht.get(filePath);
a61af66fc99e Initial load
duke
parents:
diff changeset
656
a61af66fc99e Initial load
duke
parents:
diff changeset
657 if (fa == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
658 fa = new FileAttribute((String)confFiles.get(filePath), bc, numConfigs);
a61af66fc99e Initial load
duke
parents:
diff changeset
659 ht.put(filePath, fa);
a61af66fc99e Initial load
duke
parents:
diff changeset
660 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
661 fa.add(confName);
a61af66fc99e Initial load
duke
parents:
diff changeset
662 }
a61af66fc99e Initial load
duke
parents:
diff changeset
663 }
a61af66fc99e Initial load
duke
parents:
diff changeset
664 }
a61af66fc99e Initial load
duke
parents:
diff changeset
665
a61af66fc99e Initial load
duke
parents:
diff changeset
666 return ht;
a61af66fc99e Initial load
duke
parents:
diff changeset
667 }
a61af66fc99e Initial load
duke
parents:
diff changeset
668
a61af66fc99e Initial load
duke
parents:
diff changeset
669 Hashtable computeAttributedFiles(BuildConfig bc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
670 Hashtable ht = new Hashtable();
a61af66fc99e Initial load
duke
parents:
diff changeset
671 Hashtable confFiles = (Hashtable)bc.getSpecificField("AllFilesHash");
a61af66fc99e Initial load
duke
parents:
diff changeset
672
a61af66fc99e Initial load
duke
parents:
diff changeset
673 for (Enumeration e = confFiles.keys(); e.hasMoreElements(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
674 String filePath = (String)e.nextElement();
a61af66fc99e Initial load
duke
parents:
diff changeset
675 ht.put(filePath, new FileAttribute((String)confFiles.get(filePath), bc, 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
676 }
a61af66fc99e Initial load
duke
parents:
diff changeset
677
a61af66fc99e Initial load
duke
parents:
diff changeset
678 return ht;
a61af66fc99e Initial load
duke
parents:
diff changeset
679 }
a61af66fc99e Initial load
duke
parents:
diff changeset
680
a61af66fc99e Initial load
duke
parents:
diff changeset
681 PrintWriter printWriter;
a61af66fc99e Initial load
duke
parents:
diff changeset
682
a61af66fc99e Initial load
duke
parents:
diff changeset
683 public void writeProjectFile(String projectFileName, String projectName,
a61af66fc99e Initial load
duke
parents:
diff changeset
684 Vector allConfigs) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
685 throw new RuntimeException("use compiler version specific version");
a61af66fc99e Initial load
duke
parents:
diff changeset
686 }
a61af66fc99e Initial load
duke
parents:
diff changeset
687 }