1 // 2 // Copyright 2006 The Android Open Source Project 3 // 4 // Android Asset Packaging Tool main entry point. 5 // 6 #include "Main.h" 7 #include "Bundle.h" 8 9 #include <utils/Log.h> 10 #include <utils/threads.h> 11 #include <utils/List.h> 12 #include <utils/Errors.h> 13 14 #include <stdlib.h> 15 #include <getopt.h> 16 #include <assert.h> 17 18 using namespace android; 19 20 static const char* gProgName = "aapt"; 21 22 /* 23 * When running under Cygwin on Windows, this will convert slash-based 24 * paths into back-slash-based ones. Otherwise the ApptAssets file comparisons 25 * fail later as they use back-slash separators under Windows. 26 * 27 * This operates in-place on the path string. 28 */ 29 void convertPath(char *path) { 30 if (path != NULL && OS_PATH_SEPARATOR != '/') { 31 for (; *path; path++) { 32 if (*path == '/') { 33 *path = OS_PATH_SEPARATOR; 34 } 35 } 36 } 37 } 38 39 /* 40 * Print usage info. 41 */ 42 void usage(void) 43 { 44 fprintf(stderr, "Android Asset Packaging Tool\n\n"); 45 fprintf(stderr, "Usage:\n"); 46 fprintf(stderr, 47 " %s l[ist] [-v] [-a] file.{zip,jar,apk}\n" 48 " List contents of Zip-compatible archive.\n\n", gProgName); 49 fprintf(stderr, 50 " %s d[ump] [--values] [--include-meta-data] WHAT file.{apk} [asset [asset ...]]\n" 51 " strings Print the contents of the resource table string pool in the APK.\n" 52 " badging Print the label and icon for the app declared in APK.\n" 53 " permissions Print the permissions from the APK.\n" 54 " resources Print the resource table from the APK.\n" 55 " configurations Print the configurations in the APK.\n" 56 " xmltree Print the compiled xmls in the given assets.\n" 57 " xmlstrings Print the strings of the given compiled xml assets.\n\n", gProgName); 58 fprintf(stderr, 59 " %s p[ackage] [-d][-f][-m][-u][-v][-x][-z][-M AndroidManifest.xml] \\\n" 60 " [-0 extension [-0 extension ...]] [-g tolerance] [-j jarfile] \\\n" 61 " [--debug-mode] [--min-sdk-version VAL] [--target-sdk-version VAL] \\\n" 62 " [--app-version VAL] [--app-version-name TEXT] [--custom-package VAL] \\\n" 63 " [--rename-manifest-package PACKAGE] \\\n" 64 " [--rename-instrumentation-target-package PACKAGE] \\\n" 65 " [--utf16] [--auto-add-overlay] \\\n" 66 " [--max-res-version VAL] \\\n" 67 " [-I base-package [-I base-package ...]] \\\n" 68 " [-A asset-source-dir] [-G class-list-file] [-P public-definitions-file] \\\n" 69 " [-S resource-sources [-S resource-sources ...]] \\\n" 70 " [-F apk-file] [-J R-file-dir] \\\n" 71 " [--product product1,product2,...] \\\n" 72 " [-c CONFIGS] [--preferred-configurations CONFIGS] \\\n" 73 " [--split CONFIGS [--split CONFIGS]] \\\n" 74 " [--feature-of package [--feature-after package]] \\\n" 75 " [raw-files-dir [raw-files-dir] ...] \\\n" 76 " [--output-text-symbols DIR]\n" 77 "\n" 78 " Package the android resources. It will read assets and resources that are\n" 79 " supplied with the -M -A -S or raw-files-dir arguments. The -J -P -F and -R\n" 80 " options control which files are output.\n\n" 81 , gProgName); 82 fprintf(stderr, 83 " %s r[emove] [-v] file.{zip,jar,apk} file1 [file2 ...]\n" 84 " Delete specified files from Zip-compatible archive.\n\n", 85 gProgName); 86 fprintf(stderr, 87 " %s a[dd] [-v] file.{zip,jar,apk} file1 [file2 ...]\n" 88 " Add specified files to Zip-compatible archive.\n\n", gProgName); 89 fprintf(stderr, 90 " %s c[runch] [-v] -S resource-sources ... -C output-folder ...\n" 91 " Do PNG preprocessing on one or several resource folders\n" 92 " and store the results in the output folder.\n\n", gProgName); 93 fprintf(stderr, 94 " %s s[ingleCrunch] [-v] -i input-file -o outputfile\n" 95 " Do PNG preprocessing on a single file.\n\n", gProgName); 96 fprintf(stderr, 97 " %s v[ersion]\n" 98 " Print program version.\n\n", gProgName); 99 fprintf(stderr, 100 " Modifiers:\n" 101 " -a print Android-specific data (resources, manifest) when listing\n" 102 " -c specify which configurations to include. The default is all\n" 103 " configurations. The value of the parameter should be a comma\n" 104 " separated list of configuration values. Locales should be specified\n" 105 " as either a language or language-region pair. Some examples:\n" 106 " en\n" 107 " port,en\n" 108 " port,land,en_US\n" 109 " -d one or more device assets to include, separated by commas\n" 110 " -f force overwrite of existing files\n" 111 " -g specify a pixel tolerance to force images to grayscale, default 0\n" 112 " -j specify a jar or zip file containing classes to include\n" 113 " -k junk path of file(s) added\n" 114 " -m make package directories under location specified by -J\n" 115 " -u update existing packages (add new, replace older, remove deleted files)\n" 116 " -v verbose output\n" 117 " -x create extending (non-application) resource IDs\n" 118 " -z require localization of resource attributes marked with\n" 119 " localization=\"suggested\"\n" 120 " -A additional directory in which to find raw asset files\n" 121 " -G A file to output proguard options into.\n" 122 " -F specify the apk file to output\n" 123 " -I add an existing package to base include set\n" 124 " -J specify where to output R.java resource constant definitions\n" 125 " -M specify full path to AndroidManifest.xml to include in zip\n" 126 " -P specify where to output public resource definitions\n" 127 " -S directory in which to find resources. Multiple directories will be scanned\n" 128 " and the first match found (left to right) will take precedence.\n" 129 " -0 specifies an additional extension for which such files will not\n" 130 " be stored compressed in the .apk. An empty string means to not\n" 131 " compress any files at all.\n" 132 " --debug-mode\n" 133 " inserts android:debuggable=\"true\" in to the application node of the\n" 134 " manifest, making the application debuggable even on production devices.\n" 135 " --include-meta-data\n" 136 " when used with \"dump badging\" also includes meta-data tags.\n" 137 " --pseudo-localize\n" 138 " generate resources for pseudo-locales (en-XA and ar-XB).\n" 139 " --min-sdk-version\n" 140 " inserts android:minSdkVersion in to manifest. If the version is 7 or\n" 141 " higher, the default encoding for resources will be in UTF-8.\n" 142 " --target-sdk-version\n" 143 " inserts android:targetSdkVersion in to manifest.\n" 144 " --max-res-version\n" 145 " ignores versioned resource directories above the given value.\n" 146 " --values\n" 147 " when used with \"dump resources\" also includes resource values.\n" 148 " --version-code\n" 149 " inserts android:versionCode in to manifest.\n" 150 " --version-name\n" 151 " inserts android:versionName in to manifest.\n" 152 " --replace-version\n" 153 " If --version-code and/or --version-name are specified, these\n" 154 " values will replace any value already in the manifest. By\n" 155 " default, nothing is changed if the manifest already defines\n" 156 " these attributes.\n" 157 " --custom-package\n" 158 " generates R.java into a different package.\n" 159 " --extra-packages\n" 160 " generate R.java for libraries. Separate libraries with ':'.\n" 161 " --generate-dependencies\n" 162 " generate dependency files in the same directories for R.java and resource package\n" 163 " --auto-add-overlay\n" 164 " Automatically add resources that are only in overlays.\n" 165 " --preferred-density\n" 166 " Specifies a preference for a particular density. Resources that do not\n" 167 " match this density and have variants that are a closer match are removed.\n" 168 " --split\n" 169 " Builds a separate split APK for the configurations listed. This can\n" 170 " be loaded alongside the base APK at runtime.\n" 171 " --feature-of\n" 172 " Builds a split APK that is a feature of the apk specified here. Resources\n" 173 " in the base APK can be referenced from the the feature APK.\n" 174 " --feature-after\n" 175 " An app can have multiple Feature Split APKs which must be totally ordered.\n" 176 " If --feature-of is specified, this flag specifies which Feature Split APK\n" 177 " comes before this one. The first Feature Split APK should not define\n" 178 " anything here.\n" 179 " --rename-manifest-package\n" 180 " Rewrite the manifest so that its package name is the package name\n" 181 " given here. Relative class names (for example .Foo) will be\n" 182 " changed to absolute names with the old package so that the code\n" 183 " does not need to change.\n" 184 " --rename-instrumentation-target-package\n" 185 " Rewrite the manifest so that all of its instrumentation\n" 186 " components target the given package. Useful when used in\n" 187 " conjunction with --rename-manifest-package to fix tests against\n" 188 " a package that has been renamed.\n" 189 " --product\n" 190 " Specifies which variant to choose for strings that have\n" 191 " product variants\n" 192 " --utf16\n" 193 " changes default encoding for resources to UTF-16. Only useful when API\n" 194 " level is set to 7 or higher where the default encoding is UTF-8.\n" 195 " --non-constant-id\n" 196 " Make the resources ID non constant. This is required to make an R java class\n" 197 " that does not contain the final value but is used to make reusable compiled\n" 198 " libraries that need to access resources.\n" 199 " --shared-lib\n" 200 " Make a shared library resource package that can be loaded by an application\n" 201 " at runtime to access the libraries resources. Implies --non-constant-id.\n" 202 " --error-on-failed-insert\n" 203 " Forces aapt to return an error if it fails to insert values into the manifest\n" 204 " with --debug-mode, --min-sdk-version, --target-sdk-version --version-code\n" 205 " and --version-name.\n" 206 " Insertion typically fails if the manifest already defines the attribute.\n" 207 " --error-on-missing-config-entry\n" 208 " Forces aapt to return an error if it fails to find an entry for a configuration.\n" 209 " --output-text-symbols\n" 210 " Generates a text file containing the resource symbols of the R class in the\n" 211 " specified folder.\n" 212 " --ignore-assets\n" 213 " Assets to be ignored. Default pattern is:\n" 214 " %s\n", 215 gDefaultIgnoreAssets); 216 } 217 218 /* 219 * Dispatch the command. 220 */ 221 int handleCommand(Bundle* bundle) 222 { 223 //printf("--- command %d (verbose=%d force=%d):\n", 224 // bundle->getCommand(), bundle->getVerbose(), bundle->getForce()); 225 //for (int i = 0; i < bundle->getFileSpecCount(); i++) 226 // printf(" %d: '%s'\n", i, bundle->getFileSpecEntry(i)); 227 228 switch (bundle->getCommand()) { 229 case kCommandVersion: return doVersion(bundle); 230 case kCommandList: return doList(bundle); 231 case kCommandDump: return doDump(bundle); 232 case kCommandAdd: return doAdd(bundle); 233 case kCommandRemove: return doRemove(bundle); 234 case kCommandPackage: return doPackage(bundle); 235 case kCommandCrunch: return doCrunch(bundle); 236 case kCommandSingleCrunch: return doSingleCrunch(bundle); 237 case kCommandDaemon: return runInDaemonMode(bundle); 238 default: 239 fprintf(stderr, "%s: requested command not yet supported\n", gProgName); 240 return 1; 241 } 242 } 243 244 /* 245 * Parse args. 246 */ 247 int main(int argc, char* const argv[]) 248 { 249 char *prog = argv[0]; 250 Bundle bundle; 251 bool wantUsage = false; 252 int result = 1; // pessimistically assume an error. 253 int tolerance = 0; 254 255 /* default to compression */ 256 bundle.setCompressionMethod(ZipEntry::kCompressDeflated); 257 258 if (argc < 2) { 259 wantUsage = true; 260 goto bail; 261 } 262 263 if (argv[1][0] == 'v') 264 bundle.setCommand(kCommandVersion); 265 else if (argv[1][0] == 'd') 266 bundle.setCommand(kCommandDump); 267 else if (argv[1][0] == 'l') 268 bundle.setCommand(kCommandList); 269 else if (argv[1][0] == 'a') 270 bundle.setCommand(kCommandAdd); 271 else if (argv[1][0] == 'r') 272 bundle.setCommand(kCommandRemove); 273 else if (argv[1][0] == 'p') 274 bundle.setCommand(kCommandPackage); 275 else if (argv[1][0] == 'c') 276 bundle.setCommand(kCommandCrunch); 277 else if (argv[1][0] == 's') 278 bundle.setCommand(kCommandSingleCrunch); 279 else if (argv[1][0] == 'm') 280 bundle.setCommand(kCommandDaemon); 281 else { 282 fprintf(stderr, "ERROR: Unknown command '%s'\n", argv[1]); 283 wantUsage = true; 284 goto bail; 285 } 286 argc -= 2; 287 argv += 2; 288 289 /* 290 * Pull out flags. We support "-fv" and "-f -v". 291 */ 292 while (argc && argv[0][0] == '-') { 293 /* flag(s) found */ 294 const char* cp = argv[0] +1; 295 296 while (*cp != '\0') { 297 switch (*cp) { 298 case 'v': 299 bundle.setVerbose(true); 300 break; 301 case 'a': 302 bundle.setAndroidList(true); 303 break; 304 case 'c': 305 argc--; 306 argv++; 307 if (!argc) { 308 fprintf(stderr, "ERROR: No argument supplied for '-c' option\n"); 309 wantUsage = true; 310 goto bail; 311 } 312 bundle.addConfigurations(argv[0]); 313 break; 314 case 'f': 315 bundle.setForce(true); 316 break; 317 case 'g': 318 argc--; 319 argv++; 320 if (!argc) { 321 fprintf(stderr, "ERROR: No argument supplied for '-g' option\n"); 322 wantUsage = true; 323 goto bail; 324 } 325 tolerance = atoi(argv[0]); 326 bundle.setGrayscaleTolerance(tolerance); 327 printf("%s: Images with deviation <= %d will be forced to grayscale.\n", prog, tolerance); 328 break; 329 case 'k': 330 bundle.setJunkPath(true); 331 break; 332 case 'm': 333 bundle.setMakePackageDirs(true); 334 break; 335 #if 0 336 case 'p': 337 bundle.setPseudolocalize(true); 338 break; 339 #endif 340 case 'u': 341 bundle.setUpdate(true); 342 break; 343 case 'x': 344 bundle.setExtending(true); 345 break; 346 case 'z': 347 bundle.setRequireLocalization(true); 348 break; 349 case 'j': 350 argc--; 351 argv++; 352 if (!argc) { 353 fprintf(stderr, "ERROR: No argument supplied for '-j' option\n"); 354 wantUsage = true; 355 goto bail; 356 } 357 convertPath(argv[0]); 358 bundle.addJarFile(argv[0]); 359 break; 360 case 'A': 361 argc--; 362 argv++; 363 if (!argc) { 364 fprintf(stderr, "ERROR: No argument supplied for '-A' option\n"); 365 wantUsage = true; 366 goto bail; 367 } 368 convertPath(argv[0]); 369 bundle.addAssetSourceDir(argv[0]); 370 break; 371 case 'G': 372 argc--; 373 argv++; 374 if (!argc) { 375 fprintf(stderr, "ERROR: No argument supplied for '-G' option\n"); 376 wantUsage = true; 377 goto bail; 378 } 379 convertPath(argv[0]); 380 bundle.setProguardFile(argv[0]); 381 break; 382 case 'I': 383 argc--; 384 argv++; 385 if (!argc) { 386 fprintf(stderr, "ERROR: No argument supplied for '-I' option\n"); 387 wantUsage = true; 388 goto bail; 389 } 390 convertPath(argv[0]); 391 bundle.addPackageInclude(argv[0]); 392 break; 393 case 'F': 394 argc--; 395 argv++; 396 if (!argc) { 397 fprintf(stderr, "ERROR: No argument supplied for '-F' option\n"); 398 wantUsage = true; 399 goto bail; 400 } 401 convertPath(argv[0]); 402 bundle.setOutputAPKFile(argv[0]); 403 break; 404 case 'J': 405 argc--; 406 argv++; 407 if (!argc) { 408 fprintf(stderr, "ERROR: No argument supplied for '-J' option\n"); 409 wantUsage = true; 410 goto bail; 411 } 412 convertPath(argv[0]); 413 bundle.setRClassDir(argv[0]); 414 break; 415 case 'M': 416 argc--; 417 argv++; 418 if (!argc) { 419 fprintf(stderr, "ERROR: No argument supplied for '-M' option\n"); 420 wantUsage = true; 421 goto bail; 422 } 423 convertPath(argv[0]); 424 bundle.setAndroidManifestFile(argv[0]); 425 break; 426 case 'P': 427 argc--; 428 argv++; 429 if (!argc) { 430 fprintf(stderr, "ERROR: No argument supplied for '-P' option\n"); 431 wantUsage = true; 432 goto bail; 433 } 434 convertPath(argv[0]); 435 bundle.setPublicOutputFile(argv[0]); 436 break; 437 case 'S': 438 argc--; 439 argv++; 440 if (!argc) { 441 fprintf(stderr, "ERROR: No argument supplied for '-S' option\n"); 442 wantUsage = true; 443 goto bail; 444 } 445 convertPath(argv[0]); 446 bundle.addResourceSourceDir(argv[0]); 447 break; 448 case 'C': 449 argc--; 450 argv++; 451 if (!argc) { 452 fprintf(stderr, "ERROR: No argument supplied for '-C' option\n"); 453 wantUsage = true; 454 goto bail; 455 } 456 convertPath(argv[0]); 457 bundle.setCrunchedOutputDir(argv[0]); 458 break; 459 case 'i': 460 argc--; 461 argv++; 462 if (!argc) { 463 fprintf(stderr, "ERROR: No argument supplied for '-i' option\n"); 464 wantUsage = true; 465 goto bail; 466 } 467 convertPath(argv[0]); 468 bundle.setSingleCrunchInputFile(argv[0]); 469 break; 470 case 'o': 471 argc--; 472 argv++; 473 if (!argc) { 474 fprintf(stderr, "ERROR: No argument supplied for '-o' option\n"); 475 wantUsage = true; 476 goto bail; 477 } 478 convertPath(argv[0]); 479 bundle.setSingleCrunchOutputFile(argv[0]); 480 break; 481 case '0': 482 argc--; 483 argv++; 484 if (!argc) { 485 fprintf(stderr, "ERROR: No argument supplied for '-e' option\n"); 486 wantUsage = true; 487 goto bail; 488 } 489 if (argv[0][0] != 0) { 490 bundle.addNoCompressExtension(argv[0]); 491 } else { 492 bundle.setCompressionMethod(ZipEntry::kCompressStored); 493 } 494 break; 495 case '-': 496 if (strcmp(cp, "-debug-mode") == 0) { 497 bundle.setDebugMode(true); 498 } else if (strcmp(cp, "-min-sdk-version") == 0) { 499 argc--; 500 argv++; 501 if (!argc) { 502 fprintf(stderr, "ERROR: No argument supplied for '--min-sdk-version' option\n"); 503 wantUsage = true; 504 goto bail; 505 } 506 bundle.setMinSdkVersion(argv[0]); 507 } else if (strcmp(cp, "-target-sdk-version") == 0) { 508 argc--; 509 argv++; 510 if (!argc) { 511 fprintf(stderr, "ERROR: No argument supplied for '--target-sdk-version' option\n"); 512 wantUsage = true; 513 goto bail; 514 } 515 bundle.setTargetSdkVersion(argv[0]); 516 } else if (strcmp(cp, "-max-sdk-version") == 0) { 517 argc--; 518 argv++; 519 if (!argc) { 520 fprintf(stderr, "ERROR: No argument supplied for '--max-sdk-version' option\n"); 521 wantUsage = true; 522 goto bail; 523 } 524 bundle.setMaxSdkVersion(argv[0]); 525 } else if (strcmp(cp, "-max-res-version") == 0) { 526 argc--; 527 argv++; 528 if (!argc) { 529 fprintf(stderr, "ERROR: No argument supplied for '--max-res-version' option\n"); 530 wantUsage = true; 531 goto bail; 532 } 533 bundle.setMaxResVersion(argv[0]); 534 } else if (strcmp(cp, "-version-code") == 0) { 535 argc--; 536 argv++; 537 if (!argc) { 538 fprintf(stderr, "ERROR: No argument supplied for '--version-code' option\n"); 539 wantUsage = true; 540 goto bail; 541 } 542 bundle.setVersionCode(argv[0]); 543 } else if (strcmp(cp, "-version-name") == 0) { 544 argc--; 545 argv++; 546 if (!argc) { 547 fprintf(stderr, "ERROR: No argument supplied for '--version-name' option\n"); 548 wantUsage = true; 549 goto bail; 550 } 551 bundle.setVersionName(argv[0]); 552 } else if (strcmp(cp, "-replace-version") == 0) { 553 bundle.setReplaceVersion(true); 554 } else if (strcmp(cp, "-values") == 0) { 555 bundle.setValues(true); 556 } else if (strcmp(cp, "-include-meta-data") == 0) { 557 bundle.setIncludeMetaData(true); 558 } else if (strcmp(cp, "-custom-package") == 0) { 559 argc--; 560 argv++; 561 if (!argc) { 562 fprintf(stderr, "ERROR: No argument supplied for '--custom-package' option\n"); 563 wantUsage = true; 564 goto bail; 565 } 566 bundle.setCustomPackage(argv[0]); 567 } else if (strcmp(cp, "-extra-packages") == 0) { 568 argc--; 569 argv++; 570 if (!argc) { 571 fprintf(stderr, "ERROR: No argument supplied for '--extra-packages' option\n"); 572 wantUsage = true; 573 goto bail; 574 } 575 bundle.setExtraPackages(argv[0]); 576 } else if (strcmp(cp, "-generate-dependencies") == 0) { 577 bundle.setGenDependencies(true); 578 } else if (strcmp(cp, "-utf16") == 0) { 579 bundle.setWantUTF16(true); 580 } else if (strcmp(cp, "-preferred-density") == 0) { 581 argc--; 582 argv++; 583 if (!argc) { 584 fprintf(stderr, "ERROR: No argument supplied for '--preferred-density' option\n"); 585 wantUsage = true; 586 goto bail; 587 } 588 bundle.setPreferredDensity(argv[0]); 589 } else if (strcmp(cp, "-split") == 0) { 590 argc--; 591 argv++; 592 if (!argc) { 593 fprintf(stderr, "ERROR: No argument supplied for '--split' option\n"); 594 wantUsage = true; 595 goto bail; 596 } 597 bundle.addSplitConfigurations(argv[0]); 598 } else if (strcmp(cp, "-feature-of") == 0) { 599 argc--; 600 argv++; 601 if (!argc) { 602 fprintf(stderr, "ERROR: No argument supplied for '--feature-of' option\n"); 603 wantUsage = true; 604 goto bail; 605 } 606 bundle.setFeatureOfPackage(argv[0]); 607 } else if (strcmp(cp, "-feature-after") == 0) { 608 argc--; 609 argv++; 610 if (!argc) { 611 fprintf(stderr, "ERROR: No argument supplied for '--feature-after' option\n"); 612 wantUsage = true; 613 goto bail; 614 } 615 bundle.setFeatureAfterPackage(argv[0]); 616 } else if (strcmp(cp, "-rename-manifest-package") == 0) { 617 argc--; 618 argv++; 619 if (!argc) { 620 fprintf(stderr, "ERROR: No argument supplied for '--rename-manifest-package' option\n"); 621 wantUsage = true; 622 goto bail; 623 } 624 bundle.setManifestPackageNameOverride(argv[0]); 625 } else if (strcmp(cp, "-rename-instrumentation-target-package") == 0) { 626 argc--; 627 argv++; 628 if (!argc) { 629 fprintf(stderr, "ERROR: No argument supplied for '--rename-instrumentation-target-package' option\n"); 630 wantUsage = true; 631 goto bail; 632 } 633 bundle.setInstrumentationPackageNameOverride(argv[0]); 634 } else if (strcmp(cp, "-auto-add-overlay") == 0) { 635 bundle.setAutoAddOverlay(true); 636 } else if (strcmp(cp, "-error-on-failed-insert") == 0) { 637 bundle.setErrorOnFailedInsert(true); 638 } else if (strcmp(cp, "-error-on-missing-config-entry") == 0) { 639 bundle.setErrorOnMissingConfigEntry(true); 640 } else if (strcmp(cp, "-output-text-symbols") == 0) { 641 argc--; 642 argv++; 643 if (!argc) { 644 fprintf(stderr, "ERROR: No argument supplied for '-output-text-symbols' option\n"); 645 wantUsage = true; 646 goto bail; 647 } 648 bundle.setOutputTextSymbols(argv[0]); 649 } else if (strcmp(cp, "-product") == 0) { 650 argc--; 651 argv++; 652 if (!argc) { 653 fprintf(stderr, "ERROR: No argument supplied for '--product' option\n"); 654 wantUsage = true; 655 goto bail; 656 } 657 bundle.setProduct(argv[0]); 658 } else if (strcmp(cp, "-non-constant-id") == 0) { 659 bundle.setNonConstantId(true); 660 } else if (strcmp(cp, "-shared-lib") == 0) { 661 bundle.setNonConstantId(true); 662 bundle.setBuildSharedLibrary(true); 663 } else if (strcmp(cp, "-no-crunch") == 0) { 664 bundle.setUseCrunchCache(true); 665 } else if (strcmp(cp, "-ignore-assets") == 0) { 666 argc--; 667 argv++; 668 if (!argc) { 669 fprintf(stderr, "ERROR: No argument supplied for '--ignore-assets' option\n"); 670 wantUsage = true; 671 goto bail; 672 } 673 gUserIgnoreAssets = argv[0]; 674 } else if (strcmp(cp, "-pseudo-localize") == 0) { 675 bundle.setPseudolocalize(PSEUDO_ACCENTED | PSEUDO_BIDI); 676 } else { 677 fprintf(stderr, "ERROR: Unknown option '-%s'\n", cp); 678 wantUsage = true; 679 goto bail; 680 } 681 cp += strlen(cp) - 1; 682 break; 683 default: 684 fprintf(stderr, "ERROR: Unknown flag '-%c'\n", *cp); 685 wantUsage = true; 686 goto bail; 687 } 688 689 cp++; 690 } 691 argc--; 692 argv++; 693 } 694 695 /* 696 * We're past the flags. The rest all goes straight in. 697 */ 698 bundle.setFileSpec(argv, argc); 699 700 result = handleCommand(&bundle); 701 702 bail: 703 if (wantUsage) { 704 usage(); 705 result = 2; 706 } 707 708 //printf("--> returning %d\n", result); 709 return result; 710 } 711