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