annotate src/share/tools/ProjectCreator/WinGammaPlatform.java @ 2184:5d801e6b9a80

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