annotate src/share/tools/MakeDeps/WinGammaPlatform.java @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
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
a61af66fc99e Initial load
duke
parents:
diff changeset
120 public abstract class WinGammaPlatform extends Platform {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 public void setupFileTemplates() {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 inclFileTemplate = new FileName(this,
a61af66fc99e Initial load
duke
parents:
diff changeset
123 "incls\\", "_", "", ".incl", "", ""
a61af66fc99e Initial load
duke
parents:
diff changeset
124 );
a61af66fc99e Initial load
duke
parents:
diff changeset
125 giFileTemplate = new FileName(this,
a61af66fc99e Initial load
duke
parents:
diff changeset
126 "incls\\", "", "_precompiled", ".incl", "", ""
a61af66fc99e Initial load
duke
parents:
diff changeset
127 );
a61af66fc99e Initial load
duke
parents:
diff changeset
128 gdFileTemplate = new FileName(this,
a61af66fc99e Initial load
duke
parents:
diff changeset
129 "", "", "Dependencies", "", "", ""
a61af66fc99e Initial load
duke
parents:
diff changeset
130 );
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 private static String[] suffixes = { ".cpp", ".c" };
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 public String[] outerSuffixes() {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 return suffixes;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 public String objFileSuffix() {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 return ".obj";
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 public String asmFileSuffix() {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 return ".i";
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 public String dependentPrefix() {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 return "$(VM_PATH)";
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 public boolean includeGIInEachIncl() {
a61af66fc99e Initial load
duke
parents:
diff changeset
152 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 public boolean fileNameStringEquality(String s1, String s2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 return s1.equalsIgnoreCase(s2);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 static void usage() throws IllegalArgumentException {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 System.err.println("WinGammaPlatform platform-specific options:");
a61af66fc99e Initial load
duke
parents:
diff changeset
161 System.err.println(" -sourceBase <path to directory (workspace) " +
a61af66fc99e Initial load
duke
parents:
diff changeset
162 "containing source files; no trailing slash>");
a61af66fc99e Initial load
duke
parents:
diff changeset
163 System.err.println(" -projectFileName <full pathname to which project file " +
a61af66fc99e Initial load
duke
parents:
diff changeset
164 "will be written; all parent directories must " +
a61af66fc99e Initial load
duke
parents:
diff changeset
165 "already exist>");
a61af66fc99e Initial load
duke
parents:
diff changeset
166 System.err.println(" If any of the above are specified, "+
a61af66fc99e Initial load
duke
parents:
diff changeset
167 "they must all be.");
a61af66fc99e Initial load
duke
parents:
diff changeset
168 System.err.println(" Additional, optional arguments, which can be " +
a61af66fc99e Initial load
duke
parents:
diff changeset
169 "specified multiple times:");
a61af66fc99e Initial load
duke
parents:
diff changeset
170 System.err.println(" -absoluteInclude <string containing absolute " +
a61af66fc99e Initial load
duke
parents:
diff changeset
171 "path to include directory>");
a61af66fc99e Initial load
duke
parents:
diff changeset
172 System.err.println(" -relativeInclude <string containing include " +
a61af66fc99e Initial load
duke
parents:
diff changeset
173 "directory relative to -sourceBase>");
a61af66fc99e Initial load
duke
parents:
diff changeset
174 System.err.println(" -define <preprocessor flag to be #defined " +
a61af66fc99e Initial load
duke
parents:
diff changeset
175 "(note: doesn't yet support " +
a61af66fc99e Initial load
duke
parents:
diff changeset
176 "#define (flag) (value))>");
a61af66fc99e Initial load
duke
parents:
diff changeset
177 System.err.println(" -startAt <subdir of sourceBase>");
a61af66fc99e Initial load
duke
parents:
diff changeset
178 System.err.println(" -additionalFile <file not in database but " +
a61af66fc99e Initial load
duke
parents:
diff changeset
179 "which should show up in project file, like " +
a61af66fc99e Initial load
duke
parents:
diff changeset
180 "includeDB_core>");
a61af66fc99e Initial load
duke
parents:
diff changeset
181 System.err.println(" -additionalGeneratedFile <absolute path to " +
a61af66fc99e Initial load
duke
parents:
diff changeset
182 "directory containing file; no trailing slash> " +
a61af66fc99e Initial load
duke
parents:
diff changeset
183 "<name of file generated later in the build process>");
a61af66fc99e Initial load
duke
parents:
diff changeset
184 throw new IllegalArgumentException();
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 public void addPerFileLine(Hashtable table,
a61af66fc99e Initial load
duke
parents:
diff changeset
189 String fileName,
a61af66fc99e Initial load
duke
parents:
diff changeset
190 String line) {
a61af66fc99e Initial load
duke
parents:
diff changeset
191 Vector v = (Vector) table.get(fileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
192 if (v != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
193 v.add(line);
a61af66fc99e Initial load
duke
parents:
diff changeset
194 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
195 v = new Vector();
a61af66fc99e Initial load
duke
parents:
diff changeset
196 v.add(line);
a61af66fc99e Initial load
duke
parents:
diff changeset
197 table.put(fileName, v);
a61af66fc99e Initial load
duke
parents:
diff changeset
198 }
a61af66fc99e Initial load
duke
parents:
diff changeset
199 }
a61af66fc99e Initial load
duke
parents:
diff changeset
200
a61af66fc99e Initial load
duke
parents:
diff changeset
201 protected static class PerFileCondData {
a61af66fc99e Initial load
duke
parents:
diff changeset
202 public String releaseString;
a61af66fc99e Initial load
duke
parents:
diff changeset
203 public String debugString;
a61af66fc99e Initial load
duke
parents:
diff changeset
204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 protected void addConditionalPerFileLine(Hashtable table,
a61af66fc99e Initial load
duke
parents:
diff changeset
207 String fileName,
a61af66fc99e Initial load
duke
parents:
diff changeset
208 String releaseLine,
a61af66fc99e Initial load
duke
parents:
diff changeset
209 String debugLine) {
a61af66fc99e Initial load
duke
parents:
diff changeset
210 PerFileCondData data = new PerFileCondData();
a61af66fc99e Initial load
duke
parents:
diff changeset
211 data.releaseString = releaseLine;
a61af66fc99e Initial load
duke
parents:
diff changeset
212 data.debugString = debugLine;
a61af66fc99e Initial load
duke
parents:
diff changeset
213 Vector v = (Vector) table.get(fileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
214 if (v != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 v.add(data);
a61af66fc99e Initial load
duke
parents:
diff changeset
216 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 v = new Vector();
a61af66fc99e Initial load
duke
parents:
diff changeset
218 v.add(data);
a61af66fc99e Initial load
duke
parents:
diff changeset
219 table.put(fileName, v);
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 protected static class PrelinkCommandData {
a61af66fc99e Initial load
duke
parents:
diff changeset
224 String description;
a61af66fc99e Initial load
duke
parents:
diff changeset
225 String commands;
a61af66fc99e Initial load
duke
parents:
diff changeset
226 }
a61af66fc99e Initial load
duke
parents:
diff changeset
227
a61af66fc99e Initial load
duke
parents:
diff changeset
228 protected void addPrelinkCommand(Hashtable table,
a61af66fc99e Initial load
duke
parents:
diff changeset
229 String build,
a61af66fc99e Initial load
duke
parents:
diff changeset
230 String description,
a61af66fc99e Initial load
duke
parents:
diff changeset
231 String commands) {
a61af66fc99e Initial load
duke
parents:
diff changeset
232 PrelinkCommandData data = new PrelinkCommandData();
a61af66fc99e Initial load
duke
parents:
diff changeset
233 data.description = description;
a61af66fc99e Initial load
duke
parents:
diff changeset
234 data.commands = commands;
a61af66fc99e Initial load
duke
parents:
diff changeset
235 table.put(build, data);
a61af66fc99e Initial load
duke
parents:
diff changeset
236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
237
a61af66fc99e Initial load
duke
parents:
diff changeset
238 public boolean findString(Vector v, String s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 for (Iterator iter = v.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
240 if (((String) iter.next()).equals(s)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
241 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
242 }
a61af66fc99e Initial load
duke
parents:
diff changeset
243 }
a61af66fc99e Initial load
duke
parents:
diff changeset
244
a61af66fc99e Initial load
duke
parents:
diff changeset
245 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
246 }
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 /* This returns a String containing the full path to the passed
a61af66fc99e Initial load
duke
parents:
diff changeset
249 file name, or null if an error occurred. If the file was not
a61af66fc99e Initial load
duke
parents:
diff changeset
250 found or was a duplicate and couldn't be resolved using the
a61af66fc99e Initial load
duke
parents:
diff changeset
251 preferred paths, the file name is added to the appropriate
a61af66fc99e Initial load
duke
parents:
diff changeset
252 Vector of Strings. */
a61af66fc99e Initial load
duke
parents:
diff changeset
253 private String findFileInDirectory(String fileName,
a61af66fc99e Initial load
duke
parents:
diff changeset
254 DirectoryTree directory,
a61af66fc99e Initial load
duke
parents:
diff changeset
255 Vector preferredPaths,
a61af66fc99e Initial load
duke
parents:
diff changeset
256 Vector filesNotFound,
a61af66fc99e Initial load
duke
parents:
diff changeset
257 Vector filesDuplicate) {
a61af66fc99e Initial load
duke
parents:
diff changeset
258 List locationsInTree = directory.findFile(fileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
259 int rootNameLength = directory.getRootNodeName().length();
a61af66fc99e Initial load
duke
parents:
diff changeset
260 String name = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
261 if ((locationsInTree == null) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
262 (locationsInTree.size() == 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
263 filesNotFound.add(fileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
264 } else if (locationsInTree.size() > 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
265 // We shouldn't have duplicate file names in our workspace.
a61af66fc99e Initial load
duke
parents:
diff changeset
266 System.err.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
267 System.err.println("There are multiple files named as: " + fileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
268 System.exit(-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
269 // The following code could be safely removed if we don't need duplicate
a61af66fc99e Initial load
duke
parents:
diff changeset
270 // file names.
a61af66fc99e Initial load
duke
parents:
diff changeset
271
a61af66fc99e Initial load
duke
parents:
diff changeset
272 // Iterate through them, trying to find one with a
a61af66fc99e Initial load
duke
parents:
diff changeset
273 // preferred path
a61af66fc99e Initial load
duke
parents:
diff changeset
274 search:
a61af66fc99e Initial load
duke
parents:
diff changeset
275 {
a61af66fc99e Initial load
duke
parents:
diff changeset
276 for (Iterator locIter = locationsInTree.iterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
277 locIter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
278 DirectoryTreeNode node =
a61af66fc99e Initial load
duke
parents:
diff changeset
279 (DirectoryTreeNode) locIter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
280 String tmpName = node.getName();
a61af66fc99e Initial load
duke
parents:
diff changeset
281 for (Iterator prefIter = preferredPaths.iterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
282 prefIter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 // We need to make sure the preferred path is
a61af66fc99e Initial load
duke
parents:
diff changeset
284 // found from the file path not including the root node name.
a61af66fc99e Initial load
duke
parents:
diff changeset
285 if (tmpName.indexOf((String)prefIter.next(),
a61af66fc99e Initial load
duke
parents:
diff changeset
286 rootNameLength) != -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
287 name = tmpName;
a61af66fc99e Initial load
duke
parents:
diff changeset
288 break search;
a61af66fc99e Initial load
duke
parents:
diff changeset
289 }
a61af66fc99e Initial load
duke
parents:
diff changeset
290 }
a61af66fc99e Initial load
duke
parents:
diff changeset
291 }
a61af66fc99e Initial load
duke
parents:
diff changeset
292 }
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 if (name == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
295 filesDuplicate.add(fileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
296 }
a61af66fc99e Initial load
duke
parents:
diff changeset
297 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
298 name = ((DirectoryTreeNode) locationsInTree.get(0)).getName();
a61af66fc99e Initial load
duke
parents:
diff changeset
299 }
a61af66fc99e Initial load
duke
parents:
diff changeset
300
a61af66fc99e Initial load
duke
parents:
diff changeset
301 return name;
a61af66fc99e Initial load
duke
parents:
diff changeset
302 }
a61af66fc99e Initial load
duke
parents:
diff changeset
303
a61af66fc99e Initial load
duke
parents:
diff changeset
304 protected boolean databaseAllFilesEqual(Database previousDB,
a61af66fc99e Initial load
duke
parents:
diff changeset
305 Database currentDB) {
a61af66fc99e Initial load
duke
parents:
diff changeset
306 Iterator i1 = previousDB.getAllFiles().iterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
307 Iterator i2 = currentDB.getAllFiles().iterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
308
a61af66fc99e Initial load
duke
parents:
diff changeset
309 while (i1.hasNext() && i2.hasNext()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
310 FileList fl1 = (FileList) i1.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
311 FileList fl2 = (FileList) i2.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
312 if (!fl1.getName().equals(fl2.getName())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
313 return false;
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 if (i1.hasNext() != i2.hasNext()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
318 // Different lengths
a61af66fc99e Initial load
duke
parents:
diff changeset
319 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
320 }
a61af66fc99e Initial load
duke
parents:
diff changeset
321
a61af66fc99e Initial load
duke
parents:
diff changeset
322 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
323 }
a61af66fc99e Initial load
duke
parents:
diff changeset
324
a61af66fc99e Initial load
duke
parents:
diff changeset
325 protected String envVarPrefixedFileName(String fileName,
a61af66fc99e Initial load
duke
parents:
diff changeset
326 int sourceBaseLen,
a61af66fc99e Initial load
duke
parents:
diff changeset
327 DirectoryTree tree,
a61af66fc99e Initial load
duke
parents:
diff changeset
328 Vector preferredPaths,
a61af66fc99e Initial load
duke
parents:
diff changeset
329 Vector filesNotFound,
a61af66fc99e Initial load
duke
parents:
diff changeset
330 Vector filesDuplicate) {
a61af66fc99e Initial load
duke
parents:
diff changeset
331 String fullName = findFileInDirectory(fileName,
a61af66fc99e Initial load
duke
parents:
diff changeset
332 tree,
a61af66fc99e Initial load
duke
parents:
diff changeset
333 preferredPaths,
a61af66fc99e Initial load
duke
parents:
diff changeset
334 filesNotFound,
a61af66fc99e Initial load
duke
parents:
diff changeset
335 filesDuplicate);
a61af66fc99e Initial load
duke
parents:
diff changeset
336 return fullName;
a61af66fc99e Initial load
duke
parents:
diff changeset
337 }
a61af66fc99e Initial load
duke
parents:
diff changeset
338
a61af66fc99e Initial load
duke
parents:
diff changeset
339 String getProjectName(String fullPath, String extension)
a61af66fc99e Initial load
duke
parents:
diff changeset
340 throws IllegalArgumentException, IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
341 File file = new File(fullPath).getCanonicalFile();
a61af66fc99e Initial load
duke
parents:
diff changeset
342 fullPath = file.getCanonicalPath();
a61af66fc99e Initial load
duke
parents:
diff changeset
343 String parent = file.getParent();
a61af66fc99e Initial load
duke
parents:
diff changeset
344
a61af66fc99e Initial load
duke
parents:
diff changeset
345 if (!fullPath.endsWith(extension)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
346 throw new IllegalArgumentException("project file name \"" +
a61af66fc99e Initial load
duke
parents:
diff changeset
347 fullPath +
a61af66fc99e Initial load
duke
parents:
diff changeset
348 "\" does not end in "+extension);
a61af66fc99e Initial load
duke
parents:
diff changeset
349 }
a61af66fc99e Initial load
duke
parents:
diff changeset
350
a61af66fc99e Initial load
duke
parents:
diff changeset
351 if ((parent != null) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
352 (!fullPath.startsWith(parent))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
353 throw new RuntimeException(
a61af66fc99e Initial load
duke
parents:
diff changeset
354 "Internal error: parent of file name \"" + parent +
a61af66fc99e Initial load
duke
parents:
diff changeset
355 "\" does not match file name \"" + fullPath + "\""
a61af66fc99e Initial load
duke
parents:
diff changeset
356 );
a61af66fc99e Initial load
duke
parents:
diff changeset
357 }
a61af66fc99e Initial load
duke
parents:
diff changeset
358
a61af66fc99e Initial load
duke
parents:
diff changeset
359 int len = parent.length();
a61af66fc99e Initial load
duke
parents:
diff changeset
360 if (!parent.endsWith(Util.sep)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
361 len += Util.sep.length();
a61af66fc99e Initial load
duke
parents:
diff changeset
362 }
a61af66fc99e Initial load
duke
parents:
diff changeset
363
a61af66fc99e Initial load
duke
parents:
diff changeset
364 int end = fullPath.length() - extension.length();
a61af66fc99e Initial load
duke
parents:
diff changeset
365
a61af66fc99e Initial load
duke
parents:
diff changeset
366 if (len == end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
367 throw new RuntimeException(
a61af66fc99e Initial load
duke
parents:
diff changeset
368 "Internal error: file name was empty"
a61af66fc99e Initial load
duke
parents:
diff changeset
369 );
a61af66fc99e Initial load
duke
parents:
diff changeset
370 }
a61af66fc99e Initial load
duke
parents:
diff changeset
371
a61af66fc99e Initial load
duke
parents:
diff changeset
372 return fullPath.substring(len, end);
a61af66fc99e Initial load
duke
parents:
diff changeset
373 }
a61af66fc99e Initial load
duke
parents:
diff changeset
374
a61af66fc99e Initial load
duke
parents:
diff changeset
375 protected abstract String getProjectExt();
a61af66fc99e Initial load
duke
parents:
diff changeset
376
a61af66fc99e Initial load
duke
parents:
diff changeset
377 public void writePlatformSpecificFiles(Database previousDB,
a61af66fc99e Initial load
duke
parents:
diff changeset
378 Database currentDB, String[] args)
a61af66fc99e Initial load
duke
parents:
diff changeset
379 throws IllegalArgumentException, IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
380
a61af66fc99e Initial load
duke
parents:
diff changeset
381 parseArguments(args);
a61af66fc99e Initial load
duke
parents:
diff changeset
382
a61af66fc99e Initial load
duke
parents:
diff changeset
383 String projectFileName = BuildConfig.getFieldString(null, "ProjectFileName");
a61af66fc99e Initial load
duke
parents:
diff changeset
384 String ext = getProjectExt();
a61af66fc99e Initial load
duke
parents:
diff changeset
385
a61af66fc99e Initial load
duke
parents:
diff changeset
386 // Compare contents of allFiles of previousDB and includeDB.
a61af66fc99e Initial load
duke
parents:
diff changeset
387 // If these haven't changed, then skip writing the .vcproj file.
a61af66fc99e Initial load
duke
parents:
diff changeset
388 if (false && databaseAllFilesEqual(previousDB, currentDB) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
389 new File(projectFileName).exists()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
390 System.out.println(
a61af66fc99e Initial load
duke
parents:
diff changeset
391 " Databases unchanged; skipping overwrite of "+ext+" file."
a61af66fc99e Initial load
duke
parents:
diff changeset
392 );
a61af66fc99e Initial load
duke
parents:
diff changeset
393 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
394 }
a61af66fc99e Initial load
duke
parents:
diff changeset
395
a61af66fc99e Initial load
duke
parents:
diff changeset
396 String projectName = getProjectName(projectFileName, ext);
a61af66fc99e Initial load
duke
parents:
diff changeset
397
a61af66fc99e Initial load
duke
parents:
diff changeset
398 writeProjectFile(projectFileName, projectName, createAllConfigs());
a61af66fc99e Initial load
duke
parents:
diff changeset
399 }
a61af66fc99e Initial load
duke
parents:
diff changeset
400
a61af66fc99e Initial load
duke
parents:
diff changeset
401 protected void writePrologue(String[] args) {
a61af66fc99e Initial load
duke
parents:
diff changeset
402 System.err.println("WinGammaPlatform platform-specific arguments:");
a61af66fc99e Initial load
duke
parents:
diff changeset
403 for (int i = 0; i < args.length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
404 System.err.print(args[i] + " ");
a61af66fc99e Initial load
duke
parents:
diff changeset
405 }
a61af66fc99e Initial load
duke
parents:
diff changeset
406 System.err.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
407 }
a61af66fc99e Initial load
duke
parents:
diff changeset
408
a61af66fc99e Initial load
duke
parents:
diff changeset
409
a61af66fc99e Initial load
duke
parents:
diff changeset
410 void setInclFileTemplate(FileName val) {
a61af66fc99e Initial load
duke
parents:
diff changeset
411 this.inclFileTemplate = val;
a61af66fc99e Initial load
duke
parents:
diff changeset
412 }
a61af66fc99e Initial load
duke
parents:
diff changeset
413
a61af66fc99e Initial load
duke
parents:
diff changeset
414 void setGIFileTemplate(FileName val) {
a61af66fc99e Initial load
duke
parents:
diff changeset
415 this.giFileTemplate = val;
a61af66fc99e Initial load
duke
parents:
diff changeset
416 }
a61af66fc99e Initial load
duke
parents:
diff changeset
417
a61af66fc99e Initial load
duke
parents:
diff changeset
418
a61af66fc99e Initial load
duke
parents:
diff changeset
419 void parseArguments(String[] args) {
a61af66fc99e Initial load
duke
parents:
diff changeset
420 new ArgsParser(args,
a61af66fc99e Initial load
duke
parents:
diff changeset
421 new ArgRule[]
a61af66fc99e Initial load
duke
parents:
diff changeset
422 {
a61af66fc99e Initial load
duke
parents:
diff changeset
423 new HsArgRule("-sourceBase",
a61af66fc99e Initial load
duke
parents:
diff changeset
424 "SourceBase",
a61af66fc99e Initial load
duke
parents:
diff changeset
425 " (Did you set the HotSpotWorkSpace environment variable?)",
a61af66fc99e Initial load
duke
parents:
diff changeset
426 HsArgHandler.STRING
a61af66fc99e Initial load
duke
parents:
diff changeset
427 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
428
a61af66fc99e Initial load
duke
parents:
diff changeset
429 new HsArgRule("-buildBase",
a61af66fc99e Initial load
duke
parents:
diff changeset
430 "BuildBase",
a61af66fc99e Initial load
duke
parents:
diff changeset
431 " (Did you set the HotSpotBuildSpace environment variable?)",
a61af66fc99e Initial load
duke
parents:
diff changeset
432 HsArgHandler.STRING
a61af66fc99e Initial load
duke
parents:
diff changeset
433 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
434
a61af66fc99e Initial load
duke
parents:
diff changeset
435 new HsArgRule("-projectFileName",
a61af66fc99e Initial load
duke
parents:
diff changeset
436 "ProjectFileName",
a61af66fc99e Initial load
duke
parents:
diff changeset
437 null,
a61af66fc99e Initial load
duke
parents:
diff changeset
438 HsArgHandler.STRING
a61af66fc99e Initial load
duke
parents:
diff changeset
439 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
440
a61af66fc99e Initial load
duke
parents:
diff changeset
441 new HsArgRule("-jdkTargetRoot",
a61af66fc99e Initial load
duke
parents:
diff changeset
442 "JdkTargetRoot",
a61af66fc99e Initial load
duke
parents:
diff changeset
443 " (Did you set the HotSpotJDKDist environment variable?)",
a61af66fc99e Initial load
duke
parents:
diff changeset
444 HsArgHandler.STRING
a61af66fc99e Initial load
duke
parents:
diff changeset
445 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
446
a61af66fc99e Initial load
duke
parents:
diff changeset
447 new HsArgRule("-compiler",
a61af66fc99e Initial load
duke
parents:
diff changeset
448 "CompilerVersion",
a61af66fc99e Initial load
duke
parents:
diff changeset
449 " (Did you set the VcVersion correctly?)",
a61af66fc99e Initial load
duke
parents:
diff changeset
450 HsArgHandler.STRING
a61af66fc99e Initial load
duke
parents:
diff changeset
451 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
452
a61af66fc99e Initial load
duke
parents:
diff changeset
453 new HsArgRule("-platform",
a61af66fc99e Initial load
duke
parents:
diff changeset
454 "Platform",
a61af66fc99e Initial load
duke
parents:
diff changeset
455 null,
a61af66fc99e Initial load
duke
parents:
diff changeset
456 HsArgHandler.STRING
a61af66fc99e Initial load
duke
parents:
diff changeset
457 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
458
a61af66fc99e Initial load
duke
parents:
diff changeset
459 new HsArgRule("-absoluteInclude",
a61af66fc99e Initial load
duke
parents:
diff changeset
460 "AbsoluteInclude",
a61af66fc99e Initial load
duke
parents:
diff changeset
461 null,
a61af66fc99e Initial load
duke
parents:
diff changeset
462 HsArgHandler.VECTOR
a61af66fc99e Initial load
duke
parents:
diff changeset
463 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
464
a61af66fc99e Initial load
duke
parents:
diff changeset
465 new HsArgRule("-relativeInclude",
a61af66fc99e Initial load
duke
parents:
diff changeset
466 "RelativeInclude",
a61af66fc99e Initial load
duke
parents:
diff changeset
467 null,
a61af66fc99e Initial load
duke
parents:
diff changeset
468 HsArgHandler.VECTOR
a61af66fc99e Initial load
duke
parents:
diff changeset
469 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
470
a61af66fc99e Initial load
duke
parents:
diff changeset
471 new HsArgRule("-define",
a61af66fc99e Initial load
duke
parents:
diff changeset
472 "Define",
a61af66fc99e Initial load
duke
parents:
diff changeset
473 null,
a61af66fc99e Initial load
duke
parents:
diff changeset
474 HsArgHandler.VECTOR
a61af66fc99e Initial load
duke
parents:
diff changeset
475 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
476
a61af66fc99e Initial load
duke
parents:
diff changeset
477 new HsArgRule("-useToGeneratePch",
a61af66fc99e Initial load
duke
parents:
diff changeset
478 "UseToGeneratePch",
a61af66fc99e Initial load
duke
parents:
diff changeset
479 null,
a61af66fc99e Initial load
duke
parents:
diff changeset
480 HsArgHandler.STRING
a61af66fc99e Initial load
duke
parents:
diff changeset
481 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
482
a61af66fc99e Initial load
duke
parents:
diff changeset
483 new ArgRuleSpecific("-perFileLine",
a61af66fc99e Initial load
duke
parents:
diff changeset
484 new HsArgHandler() {
a61af66fc99e Initial load
duke
parents:
diff changeset
485 public void handle(ArgIterator it) {
a61af66fc99e Initial load
duke
parents:
diff changeset
486 String cfg = getCfg(it.get());
a61af66fc99e Initial load
duke
parents:
diff changeset
487 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
488 String fileName = it.get();
a61af66fc99e Initial load
duke
parents:
diff changeset
489 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
490 String line = it.get();
a61af66fc99e Initial load
duke
parents:
diff changeset
491 BuildConfig.putFieldHash(cfg, "PerFileLine", fileName, line);
a61af66fc99e Initial load
duke
parents:
diff changeset
492 it.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
493 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
494 }
a61af66fc99e Initial load
duke
parents:
diff changeset
495 }
a61af66fc99e Initial load
duke
parents:
diff changeset
496 empty(null, "** Error: wrong number of args to -perFileLine");
a61af66fc99e Initial load
duke
parents:
diff changeset
497 }
a61af66fc99e Initial load
duke
parents:
diff changeset
498 }
a61af66fc99e Initial load
duke
parents:
diff changeset
499 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
500
a61af66fc99e Initial load
duke
parents:
diff changeset
501 new ArgRuleSpecific("-conditionalPerFileLine",
a61af66fc99e Initial load
duke
parents:
diff changeset
502 new HsArgHandler() {
a61af66fc99e Initial load
duke
parents:
diff changeset
503 public void handle(ArgIterator it) {
a61af66fc99e Initial load
duke
parents:
diff changeset
504 String cfg = getCfg(it.get());
a61af66fc99e Initial load
duke
parents:
diff changeset
505 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
506 String fileName = it.get();
a61af66fc99e Initial load
duke
parents:
diff changeset
507 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
508 String productLine = it.get();
a61af66fc99e Initial load
duke
parents:
diff changeset
509 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
510 String debugLine = it.get();
a61af66fc99e Initial load
duke
parents:
diff changeset
511 BuildConfig.putFieldHash(cfg+"_debug", "CondPerFileLine",
a61af66fc99e Initial load
duke
parents:
diff changeset
512 fileName, debugLine);
a61af66fc99e Initial load
duke
parents:
diff changeset
513 BuildConfig.putFieldHash(cfg+"_product", "CondPerFileLine",
a61af66fc99e Initial load
duke
parents:
diff changeset
514 fileName, productLine);
a61af66fc99e Initial load
duke
parents:
diff changeset
515 it.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
516 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
517 }
a61af66fc99e Initial load
duke
parents:
diff changeset
518 }
a61af66fc99e Initial load
duke
parents:
diff changeset
519 }
a61af66fc99e Initial load
duke
parents:
diff changeset
520
a61af66fc99e Initial load
duke
parents:
diff changeset
521 empty(null, "** Error: wrong number of args to -conditionalPerFileLine");
a61af66fc99e Initial load
duke
parents:
diff changeset
522 }
a61af66fc99e Initial load
duke
parents:
diff changeset
523 }
a61af66fc99e Initial load
duke
parents:
diff changeset
524 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
525
a61af66fc99e Initial load
duke
parents:
diff changeset
526 new HsArgRule("-disablePch",
a61af66fc99e Initial load
duke
parents:
diff changeset
527 "DisablePch",
a61af66fc99e Initial load
duke
parents:
diff changeset
528 null,
a61af66fc99e Initial load
duke
parents:
diff changeset
529 HsArgHandler.HASH
a61af66fc99e Initial load
duke
parents:
diff changeset
530 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
531
a61af66fc99e Initial load
duke
parents:
diff changeset
532 new ArgRule("-startAt",
a61af66fc99e Initial load
duke
parents:
diff changeset
533 new HsArgHandler() {
a61af66fc99e Initial load
duke
parents:
diff changeset
534 public void handle(ArgIterator it) {
a61af66fc99e Initial load
duke
parents:
diff changeset
535 if (BuildConfig.getField(null, "StartAt") != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
536 empty(null, "** Error: multiple -startAt");
a61af66fc99e Initial load
duke
parents:
diff changeset
537 }
a61af66fc99e Initial load
duke
parents:
diff changeset
538 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
539 BuildConfig.putField(null, "StartAt", it.get());
a61af66fc99e Initial load
duke
parents:
diff changeset
540 it.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
541 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
542 empty("-startAt", null);
a61af66fc99e Initial load
duke
parents:
diff changeset
543 }
a61af66fc99e Initial load
duke
parents:
diff changeset
544 }
a61af66fc99e Initial load
duke
parents:
diff changeset
545 }
a61af66fc99e Initial load
duke
parents:
diff changeset
546 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
547
a61af66fc99e Initial load
duke
parents:
diff changeset
548 new HsArgRule("-ignoreFile",
a61af66fc99e Initial load
duke
parents:
diff changeset
549 "IgnoreFile",
a61af66fc99e Initial load
duke
parents:
diff changeset
550 null,
a61af66fc99e Initial load
duke
parents:
diff changeset
551 HsArgHandler.HASH
a61af66fc99e Initial load
duke
parents:
diff changeset
552 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
553
a61af66fc99e Initial load
duke
parents:
diff changeset
554 new HsArgRule("-additionalFile",
a61af66fc99e Initial load
duke
parents:
diff changeset
555 "AdditionalFile",
a61af66fc99e Initial load
duke
parents:
diff changeset
556 null,
a61af66fc99e Initial load
duke
parents:
diff changeset
557 HsArgHandler.VECTOR
a61af66fc99e Initial load
duke
parents:
diff changeset
558 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
559
a61af66fc99e Initial load
duke
parents:
diff changeset
560 new ArgRuleSpecific("-additionalGeneratedFile",
a61af66fc99e Initial load
duke
parents:
diff changeset
561 new HsArgHandler() {
a61af66fc99e Initial load
duke
parents:
diff changeset
562 public void handle(ArgIterator it) {
a61af66fc99e Initial load
duke
parents:
diff changeset
563 String cfg = getCfg(it.get());
a61af66fc99e Initial load
duke
parents:
diff changeset
564 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
565 String dir = it.get();
a61af66fc99e Initial load
duke
parents:
diff changeset
566 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
567 String fileName = it.get();
a61af66fc99e Initial load
duke
parents:
diff changeset
568 // we ignore files that we know are generated, so we coudn't
a61af66fc99e Initial load
duke
parents:
diff changeset
569 // find them in sources
a61af66fc99e Initial load
duke
parents:
diff changeset
570 BuildConfig.putFieldHash(cfg, "IgnoreFile", fileName, "1");
a61af66fc99e Initial load
duke
parents:
diff changeset
571 BuildConfig.putFieldHash(cfg, "AdditionalGeneratedFile",
a61af66fc99e Initial load
duke
parents:
diff changeset
572 Util.normalize(dir + Util.sep + fileName),
a61af66fc99e Initial load
duke
parents:
diff changeset
573 fileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
574 it.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
575 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
576 }
a61af66fc99e Initial load
duke
parents:
diff changeset
577 }
a61af66fc99e Initial load
duke
parents:
diff changeset
578 empty(null, "** Error: wrong number of args to -additionalGeneratedFile");
a61af66fc99e Initial load
duke
parents:
diff changeset
579 }
a61af66fc99e Initial load
duke
parents:
diff changeset
580 }
a61af66fc99e Initial load
duke
parents:
diff changeset
581 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
582
a61af66fc99e Initial load
duke
parents:
diff changeset
583 new HsArgRule("-includeDB",
a61af66fc99e Initial load
duke
parents:
diff changeset
584 "IncludeDB",
a61af66fc99e Initial load
duke
parents:
diff changeset
585 null,
a61af66fc99e Initial load
duke
parents:
diff changeset
586 HsArgHandler.STRING
a61af66fc99e Initial load
duke
parents:
diff changeset
587 ),
a61af66fc99e Initial load
duke
parents:
diff changeset
588
a61af66fc99e Initial load
duke
parents:
diff changeset
589 new ArgRule("-prelink",
a61af66fc99e Initial load
duke
parents:
diff changeset
590 new HsArgHandler() {
a61af66fc99e Initial load
duke
parents:
diff changeset
591 public void handle(ArgIterator it) {
a61af66fc99e Initial load
duke
parents:
diff changeset
592 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
593 String build = it.get();
a61af66fc99e Initial load
duke
parents:
diff changeset
594 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
595 String description = it.get();
a61af66fc99e Initial load
duke
parents:
diff changeset
596 if (nextNotKey(it)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
597 String command = it.get();
a61af66fc99e Initial load
duke
parents:
diff changeset
598 BuildConfig.putField(null, "PrelinkDescription", description);
a61af66fc99e Initial load
duke
parents:
diff changeset
599 BuildConfig.putField(null, "PrelinkCommand", command);
a61af66fc99e Initial load
duke
parents:
diff changeset
600 it.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
601 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
602 }
a61af66fc99e Initial load
duke
parents:
diff changeset
603 }
a61af66fc99e Initial load
duke
parents:
diff changeset
604 }
a61af66fc99e Initial load
duke
parents:
diff changeset
605
a61af66fc99e Initial load
duke
parents:
diff changeset
606 empty(null, "** Error: wrong number of args to -prelink");
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 },
a61af66fc99e Initial load
duke
parents:
diff changeset
611 new ArgHandler() {
a61af66fc99e Initial load
duke
parents:
diff changeset
612 public void handle(ArgIterator it) {
a61af66fc99e Initial load
duke
parents:
diff changeset
613
a61af66fc99e Initial load
duke
parents:
diff changeset
614 throw new RuntimeException("Arg Parser: unrecognized option "+it.get());
a61af66fc99e Initial load
duke
parents:
diff changeset
615 }
a61af66fc99e Initial load
duke
parents:
diff changeset
616 }
a61af66fc99e Initial load
duke
parents:
diff changeset
617 );
a61af66fc99e Initial load
duke
parents:
diff changeset
618 if (BuildConfig.getField(null, "SourceBase") == null ||
a61af66fc99e Initial load
duke
parents:
diff changeset
619 BuildConfig.getField(null, "BuildBase") == null ||
a61af66fc99e Initial load
duke
parents:
diff changeset
620 BuildConfig.getField(null, "ProjectFileName") == null ||
a61af66fc99e Initial load
duke
parents:
diff changeset
621 BuildConfig.getField(null, "CompilerVersion") == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
622 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
623 }
a61af66fc99e Initial load
duke
parents:
diff changeset
624
a61af66fc99e Initial load
duke
parents:
diff changeset
625 if (BuildConfig.getField(null, "UseToGeneratePch") == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
626 throw new RuntimeException("ERROR: need to specify one file to compute PCH, with -useToGeneratePch flag");
a61af66fc99e Initial load
duke
parents:
diff changeset
627 }
a61af66fc99e Initial load
duke
parents:
diff changeset
628
a61af66fc99e Initial load
duke
parents:
diff changeset
629 BuildConfig.putField(null, "PlatformObject", this);
a61af66fc99e Initial load
duke
parents:
diff changeset
630 }
a61af66fc99e Initial load
duke
parents:
diff changeset
631
a61af66fc99e Initial load
duke
parents:
diff changeset
632 Vector createAllConfigs() {
a61af66fc99e Initial load
duke
parents:
diff changeset
633 Vector allConfigs = new Vector();
a61af66fc99e Initial load
duke
parents:
diff changeset
634
a61af66fc99e Initial load
duke
parents:
diff changeset
635 allConfigs.add(new C1DebugConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
636
a61af66fc99e Initial load
duke
parents:
diff changeset
637 boolean b = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
638 if (b) {
a61af66fc99e Initial load
duke
parents:
diff changeset
639 allConfigs.add(new C1FastDebugConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
640 allConfigs.add(new C1ProductConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
641
a61af66fc99e Initial load
duke
parents:
diff changeset
642 allConfigs.add(new C2DebugConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
643 allConfigs.add(new C2FastDebugConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
644 allConfigs.add(new C2ProductConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
645
a61af66fc99e Initial load
duke
parents:
diff changeset
646 allConfigs.add(new TieredDebugConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
647 allConfigs.add(new TieredFastDebugConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
648 allConfigs.add(new TieredProductConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
649
a61af66fc99e Initial load
duke
parents:
diff changeset
650 allConfigs.add(new CoreDebugConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
651 allConfigs.add(new CoreFastDebugConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
652 allConfigs.add(new CoreProductConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
653
a61af66fc99e Initial load
duke
parents:
diff changeset
654 allConfigs.add(new KernelDebugConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
655 allConfigs.add(new KernelFastDebugConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
656 allConfigs.add(new KernelProductConfig());
a61af66fc99e Initial load
duke
parents:
diff changeset
657 }
a61af66fc99e Initial load
duke
parents:
diff changeset
658
a61af66fc99e Initial load
duke
parents:
diff changeset
659 return allConfigs;
a61af66fc99e Initial load
duke
parents:
diff changeset
660 }
a61af66fc99e Initial load
duke
parents:
diff changeset
661
a61af66fc99e Initial load
duke
parents:
diff changeset
662 class FileAttribute {
a61af66fc99e Initial load
duke
parents:
diff changeset
663 int numConfigs;
a61af66fc99e Initial load
duke
parents:
diff changeset
664 Vector configs;
a61af66fc99e Initial load
duke
parents:
diff changeset
665 String shortName;
a61af66fc99e Initial load
duke
parents:
diff changeset
666 boolean noPch, pchRoot;
a61af66fc99e Initial load
duke
parents:
diff changeset
667
a61af66fc99e Initial load
duke
parents:
diff changeset
668 FileAttribute(String shortName, BuildConfig cfg, int numConfigs) {
a61af66fc99e Initial load
duke
parents:
diff changeset
669 this.shortName = shortName;
a61af66fc99e Initial load
duke
parents:
diff changeset
670 this.noPch = (cfg.lookupHashFieldInContext("DisablePch", shortName) != null);
a61af66fc99e Initial load
duke
parents:
diff changeset
671 this.pchRoot = shortName.equals(BuildConfig.getFieldString(null, "UseToGeneratePch"));
a61af66fc99e Initial load
duke
parents:
diff changeset
672 this.numConfigs = numConfigs;
a61af66fc99e Initial load
duke
parents:
diff changeset
673
a61af66fc99e Initial load
duke
parents:
diff changeset
674 configs = new Vector();
a61af66fc99e Initial load
duke
parents:
diff changeset
675 add(cfg.get("Name"));
a61af66fc99e Initial load
duke
parents:
diff changeset
676 }
a61af66fc99e Initial load
duke
parents:
diff changeset
677
a61af66fc99e Initial load
duke
parents:
diff changeset
678 void add(String confName) {
a61af66fc99e Initial load
duke
parents:
diff changeset
679 configs.add(confName);
a61af66fc99e Initial load
duke
parents:
diff changeset
680
a61af66fc99e Initial load
duke
parents:
diff changeset
681 // if presented in all configs
a61af66fc99e Initial load
duke
parents:
diff changeset
682 if (configs.size() == numConfigs) {
a61af66fc99e Initial load
duke
parents:
diff changeset
683 configs = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
684 }
a61af66fc99e Initial load
duke
parents:
diff changeset
685 }
a61af66fc99e Initial load
duke
parents:
diff changeset
686 }
a61af66fc99e Initial load
duke
parents:
diff changeset
687
a61af66fc99e Initial load
duke
parents:
diff changeset
688 class FileInfo implements Comparable {
a61af66fc99e Initial load
duke
parents:
diff changeset
689 String full;
a61af66fc99e Initial load
duke
parents:
diff changeset
690 FileAttribute attr;
a61af66fc99e Initial load
duke
parents:
diff changeset
691
a61af66fc99e Initial load
duke
parents:
diff changeset
692 FileInfo(String full, FileAttribute attr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
693 this.full = full;
a61af66fc99e Initial load
duke
parents:
diff changeset
694 this.attr = attr;
a61af66fc99e Initial load
duke
parents:
diff changeset
695 }
a61af66fc99e Initial load
duke
parents:
diff changeset
696
a61af66fc99e Initial load
duke
parents:
diff changeset
697 public int compareTo(Object o) {
a61af66fc99e Initial load
duke
parents:
diff changeset
698 FileInfo oo = (FileInfo)o;
a61af66fc99e Initial load
duke
parents:
diff changeset
699 // Don't squelch identical short file names where the full
a61af66fc99e Initial load
duke
parents:
diff changeset
700 // paths are different
a61af66fc99e Initial load
duke
parents:
diff changeset
701 if (!attr.shortName.equals(oo.attr.shortName))
a61af66fc99e Initial load
duke
parents:
diff changeset
702 return attr.shortName.compareTo(oo.attr.shortName);
a61af66fc99e Initial load
duke
parents:
diff changeset
703 return full.compareTo(oo.full);
a61af66fc99e Initial load
duke
parents:
diff changeset
704 }
a61af66fc99e Initial load
duke
parents:
diff changeset
705
a61af66fc99e Initial load
duke
parents:
diff changeset
706 boolean isHeader() {
a61af66fc99e Initial load
duke
parents:
diff changeset
707 return attr.shortName.endsWith(".h") || attr.shortName.endsWith(".hpp");
a61af66fc99e Initial load
duke
parents:
diff changeset
708 }
a61af66fc99e Initial load
duke
parents:
diff changeset
709 }
a61af66fc99e Initial load
duke
parents:
diff changeset
710
a61af66fc99e Initial load
duke
parents:
diff changeset
711
a61af66fc99e Initial load
duke
parents:
diff changeset
712 TreeSet sortFiles(Hashtable allFiles) {
a61af66fc99e Initial load
duke
parents:
diff changeset
713 TreeSet rv = new TreeSet();
a61af66fc99e Initial load
duke
parents:
diff changeset
714 Enumeration e = allFiles.keys();
a61af66fc99e Initial load
duke
parents:
diff changeset
715 while (e.hasMoreElements()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
716 String fullPath = (String)e.nextElement();
a61af66fc99e Initial load
duke
parents:
diff changeset
717 rv.add(new FileInfo(fullPath, (FileAttribute)allFiles.get(fullPath)));
a61af66fc99e Initial load
duke
parents:
diff changeset
718 }
a61af66fc99e Initial load
duke
parents:
diff changeset
719 return rv;
a61af66fc99e Initial load
duke
parents:
diff changeset
720 }
a61af66fc99e Initial load
duke
parents:
diff changeset
721
a61af66fc99e Initial load
duke
parents:
diff changeset
722 Hashtable computeAttributedFiles(Vector allConfigs) {
a61af66fc99e Initial load
duke
parents:
diff changeset
723 Hashtable ht = new Hashtable();
a61af66fc99e Initial load
duke
parents:
diff changeset
724 int numConfigs = allConfigs.size();
a61af66fc99e Initial load
duke
parents:
diff changeset
725
a61af66fc99e Initial load
duke
parents:
diff changeset
726 for (Iterator i = allConfigs.iterator(); i.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
727 BuildConfig bc = (BuildConfig)i.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
728 Hashtable confFiles = (Hashtable)bc.getSpecificField("AllFilesHash");
a61af66fc99e Initial load
duke
parents:
diff changeset
729 String confName = bc.get("Name");
a61af66fc99e Initial load
duke
parents:
diff changeset
730
a61af66fc99e Initial load
duke
parents:
diff changeset
731 for (Enumeration e=confFiles.keys(); e.hasMoreElements(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
732 String filePath = (String)e.nextElement();
a61af66fc99e Initial load
duke
parents:
diff changeset
733 FileAttribute fa = (FileAttribute)ht.get(filePath);
a61af66fc99e Initial load
duke
parents:
diff changeset
734
a61af66fc99e Initial load
duke
parents:
diff changeset
735 if (fa == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
736 fa = new FileAttribute((String)confFiles.get(filePath), bc, numConfigs);
a61af66fc99e Initial load
duke
parents:
diff changeset
737 ht.put(filePath, fa);
a61af66fc99e Initial load
duke
parents:
diff changeset
738 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
739 fa.add(confName);
a61af66fc99e Initial load
duke
parents:
diff changeset
740 }
a61af66fc99e Initial load
duke
parents:
diff changeset
741 }
a61af66fc99e Initial load
duke
parents:
diff changeset
742 }
a61af66fc99e Initial load
duke
parents:
diff changeset
743
a61af66fc99e Initial load
duke
parents:
diff changeset
744 return ht;
a61af66fc99e Initial load
duke
parents:
diff changeset
745 }
a61af66fc99e Initial load
duke
parents:
diff changeset
746
a61af66fc99e Initial load
duke
parents:
diff changeset
747 Hashtable computeAttributedFiles(BuildConfig bc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
748 Hashtable ht = new Hashtable();
a61af66fc99e Initial load
duke
parents:
diff changeset
749 Hashtable confFiles = (Hashtable)bc.getSpecificField("AllFilesHash");
a61af66fc99e Initial load
duke
parents:
diff changeset
750
a61af66fc99e Initial load
duke
parents:
diff changeset
751 for (Enumeration e = confFiles.keys(); e.hasMoreElements(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
752 String filePath = (String)e.nextElement();
a61af66fc99e Initial load
duke
parents:
diff changeset
753 ht.put(filePath, new FileAttribute((String)confFiles.get(filePath), bc, 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
754 }
a61af66fc99e Initial load
duke
parents:
diff changeset
755
a61af66fc99e Initial load
duke
parents:
diff changeset
756 return ht;
a61af66fc99e Initial load
duke
parents:
diff changeset
757 }
a61af66fc99e Initial load
duke
parents:
diff changeset
758
a61af66fc99e Initial load
duke
parents:
diff changeset
759 PrintWriter printWriter;
a61af66fc99e Initial load
duke
parents:
diff changeset
760
a61af66fc99e Initial load
duke
parents:
diff changeset
761 public void writeProjectFile(String projectFileName, String projectName,
a61af66fc99e Initial load
duke
parents:
diff changeset
762 Vector allConfigs) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
763 throw new RuntimeException("use compiler version specific version");
a61af66fc99e Initial load
duke
parents:
diff changeset
764 }
a61af66fc99e Initial load
duke
parents:
diff changeset
765 }