Main.cpp revision 5892248580859620db90d5ef2e3c2f48531933fa
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 <cstdlib> 15#include <getopt.h> 16#include <cassert> 17 18using namespace android; 19 20static 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 */ 29void 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 */ 42void 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-density DENSITY] \\\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 " --skip-symbols-without-default-localization\n" 216 " Prevents symbols from being generated for strings that do not have a default\n" 217 " localization\n" 218 " --no-version-vectors\n" 219 " Do not automatically generate versioned copies of vector XML resources.\n", 220 gDefaultIgnoreAssets); 221} 222 223/* 224 * Dispatch the command. 225 */ 226int handleCommand(Bundle* bundle) 227{ 228 //printf("--- command %d (verbose=%d force=%d):\n", 229 // bundle->getCommand(), bundle->getVerbose(), bundle->getForce()); 230 //for (int i = 0; i < bundle->getFileSpecCount(); i++) 231 // printf(" %d: '%s'\n", i, bundle->getFileSpecEntry(i)); 232 233 switch (bundle->getCommand()) { 234 case kCommandVersion: return doVersion(bundle); 235 case kCommandList: return doList(bundle); 236 case kCommandDump: return doDump(bundle); 237 case kCommandAdd: return doAdd(bundle); 238 case kCommandRemove: return doRemove(bundle); 239 case kCommandPackage: return doPackage(bundle); 240 case kCommandCrunch: return doCrunch(bundle); 241 case kCommandSingleCrunch: return doSingleCrunch(bundle); 242 case kCommandDaemon: return runInDaemonMode(bundle); 243 default: 244 fprintf(stderr, "%s: requested command not yet supported\n", gProgName); 245 return 1; 246 } 247} 248 249/* 250 * Parse args. 251 */ 252int main(int argc, char* const argv[]) 253{ 254 char *prog = argv[0]; 255 Bundle bundle; 256 bool wantUsage = false; 257 int result = 1; // pessimistically assume an error. 258 int tolerance = 0; 259 260 /* default to compression */ 261 bundle.setCompressionMethod(ZipEntry::kCompressDeflated); 262 263 if (argc < 2) { 264 wantUsage = true; 265 goto bail; 266 } 267 268 if (argv[1][0] == 'v') 269 bundle.setCommand(kCommandVersion); 270 else if (argv[1][0] == 'd') 271 bundle.setCommand(kCommandDump); 272 else if (argv[1][0] == 'l') 273 bundle.setCommand(kCommandList); 274 else if (argv[1][0] == 'a') 275 bundle.setCommand(kCommandAdd); 276 else if (argv[1][0] == 'r') 277 bundle.setCommand(kCommandRemove); 278 else if (argv[1][0] == 'p') 279 bundle.setCommand(kCommandPackage); 280 else if (argv[1][0] == 'c') 281 bundle.setCommand(kCommandCrunch); 282 else if (argv[1][0] == 's') 283 bundle.setCommand(kCommandSingleCrunch); 284 else if (argv[1][0] == 'm') 285 bundle.setCommand(kCommandDaemon); 286 else { 287 fprintf(stderr, "ERROR: Unknown command '%s'\n", argv[1]); 288 wantUsage = true; 289 goto bail; 290 } 291 argc -= 2; 292 argv += 2; 293 294 /* 295 * Pull out flags. We support "-fv" and "-f -v". 296 */ 297 while (argc && argv[0][0] == '-') { 298 /* flag(s) found */ 299 const char* cp = argv[0] +1; 300 301 while (*cp != '\0') { 302 switch (*cp) { 303 case 'v': 304 bundle.setVerbose(true); 305 break; 306 case 'a': 307 bundle.setAndroidList(true); 308 break; 309 case 'c': 310 argc--; 311 argv++; 312 if (!argc) { 313 fprintf(stderr, "ERROR: No argument supplied for '-c' option\n"); 314 wantUsage = true; 315 goto bail; 316 } 317 bundle.addConfigurations(argv[0]); 318 break; 319 case 'f': 320 bundle.setForce(true); 321 break; 322 case 'g': 323 argc--; 324 argv++; 325 if (!argc) { 326 fprintf(stderr, "ERROR: No argument supplied for '-g' option\n"); 327 wantUsage = true; 328 goto bail; 329 } 330 tolerance = atoi(argv[0]); 331 bundle.setGrayscaleTolerance(tolerance); 332 printf("%s: Images with deviation <= %d will be forced to grayscale.\n", prog, tolerance); 333 break; 334 case 'k': 335 bundle.setJunkPath(true); 336 break; 337 case 'm': 338 bundle.setMakePackageDirs(true); 339 break; 340#if 0 341 case 'p': 342 bundle.setPseudolocalize(true); 343 break; 344#endif 345 case 'u': 346 bundle.setUpdate(true); 347 break; 348 case 'x': 349 bundle.setExtending(true); 350 break; 351 case 'z': 352 bundle.setRequireLocalization(true); 353 break; 354 case 'j': 355 argc--; 356 argv++; 357 if (!argc) { 358 fprintf(stderr, "ERROR: No argument supplied for '-j' option\n"); 359 wantUsage = true; 360 goto bail; 361 } 362 convertPath(argv[0]); 363 bundle.addJarFile(argv[0]); 364 break; 365 case 'A': 366 argc--; 367 argv++; 368 if (!argc) { 369 fprintf(stderr, "ERROR: No argument supplied for '-A' option\n"); 370 wantUsage = true; 371 goto bail; 372 } 373 convertPath(argv[0]); 374 bundle.addAssetSourceDir(argv[0]); 375 break; 376 case 'G': 377 argc--; 378 argv++; 379 if (!argc) { 380 fprintf(stderr, "ERROR: No argument supplied for '-G' option\n"); 381 wantUsage = true; 382 goto bail; 383 } 384 convertPath(argv[0]); 385 bundle.setProguardFile(argv[0]); 386 break; 387 case 'I': 388 argc--; 389 argv++; 390 if (!argc) { 391 fprintf(stderr, "ERROR: No argument supplied for '-I' option\n"); 392 wantUsage = true; 393 goto bail; 394 } 395 convertPath(argv[0]); 396 bundle.addPackageInclude(argv[0]); 397 break; 398 case 'F': 399 argc--; 400 argv++; 401 if (!argc) { 402 fprintf(stderr, "ERROR: No argument supplied for '-F' option\n"); 403 wantUsage = true; 404 goto bail; 405 } 406 convertPath(argv[0]); 407 bundle.setOutputAPKFile(argv[0]); 408 break; 409 case 'J': 410 argc--; 411 argv++; 412 if (!argc) { 413 fprintf(stderr, "ERROR: No argument supplied for '-J' option\n"); 414 wantUsage = true; 415 goto bail; 416 } 417 convertPath(argv[0]); 418 bundle.setRClassDir(argv[0]); 419 break; 420 case 'M': 421 argc--; 422 argv++; 423 if (!argc) { 424 fprintf(stderr, "ERROR: No argument supplied for '-M' option\n"); 425 wantUsage = true; 426 goto bail; 427 } 428 convertPath(argv[0]); 429 bundle.setAndroidManifestFile(argv[0]); 430 break; 431 case 'P': 432 argc--; 433 argv++; 434 if (!argc) { 435 fprintf(stderr, "ERROR: No argument supplied for '-P' option\n"); 436 wantUsage = true; 437 goto bail; 438 } 439 convertPath(argv[0]); 440 bundle.setPublicOutputFile(argv[0]); 441 break; 442 case 'S': 443 argc--; 444 argv++; 445 if (!argc) { 446 fprintf(stderr, "ERROR: No argument supplied for '-S' option\n"); 447 wantUsage = true; 448 goto bail; 449 } 450 convertPath(argv[0]); 451 bundle.addResourceSourceDir(argv[0]); 452 break; 453 case 'C': 454 argc--; 455 argv++; 456 if (!argc) { 457 fprintf(stderr, "ERROR: No argument supplied for '-C' option\n"); 458 wantUsage = true; 459 goto bail; 460 } 461 convertPath(argv[0]); 462 bundle.setCrunchedOutputDir(argv[0]); 463 break; 464 case 'i': 465 argc--; 466 argv++; 467 if (!argc) { 468 fprintf(stderr, "ERROR: No argument supplied for '-i' option\n"); 469 wantUsage = true; 470 goto bail; 471 } 472 convertPath(argv[0]); 473 bundle.setSingleCrunchInputFile(argv[0]); 474 break; 475 case 'o': 476 argc--; 477 argv++; 478 if (!argc) { 479 fprintf(stderr, "ERROR: No argument supplied for '-o' option\n"); 480 wantUsage = true; 481 goto bail; 482 } 483 convertPath(argv[0]); 484 bundle.setSingleCrunchOutputFile(argv[0]); 485 break; 486 case '0': 487 argc--; 488 argv++; 489 if (!argc) { 490 fprintf(stderr, "ERROR: No argument supplied for '-e' option\n"); 491 wantUsage = true; 492 goto bail; 493 } 494 if (argv[0][0] != 0) { 495 bundle.addNoCompressExtension(argv[0]); 496 } else { 497 bundle.setCompressionMethod(ZipEntry::kCompressStored); 498 } 499 break; 500 case '-': 501 if (strcmp(cp, "-debug-mode") == 0) { 502 bundle.setDebugMode(true); 503 } else if (strcmp(cp, "-min-sdk-version") == 0) { 504 argc--; 505 argv++; 506 if (!argc) { 507 fprintf(stderr, "ERROR: No argument supplied for '--min-sdk-version' option\n"); 508 wantUsage = true; 509 goto bail; 510 } 511 bundle.setMinSdkVersion(argv[0]); 512 } else if (strcmp(cp, "-target-sdk-version") == 0) { 513 argc--; 514 argv++; 515 if (!argc) { 516 fprintf(stderr, "ERROR: No argument supplied for '--target-sdk-version' option\n"); 517 wantUsage = true; 518 goto bail; 519 } 520 bundle.setTargetSdkVersion(argv[0]); 521 } else if (strcmp(cp, "-max-sdk-version") == 0) { 522 argc--; 523 argv++; 524 if (!argc) { 525 fprintf(stderr, "ERROR: No argument supplied for '--max-sdk-version' option\n"); 526 wantUsage = true; 527 goto bail; 528 } 529 bundle.setMaxSdkVersion(argv[0]); 530 } else if (strcmp(cp, "-max-res-version") == 0) { 531 argc--; 532 argv++; 533 if (!argc) { 534 fprintf(stderr, "ERROR: No argument supplied for '--max-res-version' option\n"); 535 wantUsage = true; 536 goto bail; 537 } 538 bundle.setMaxResVersion(argv[0]); 539 } else if (strcmp(cp, "-version-code") == 0) { 540 argc--; 541 argv++; 542 if (!argc) { 543 fprintf(stderr, "ERROR: No argument supplied for '--version-code' option\n"); 544 wantUsage = true; 545 goto bail; 546 } 547 bundle.setVersionCode(argv[0]); 548 } else if (strcmp(cp, "-version-name") == 0) { 549 argc--; 550 argv++; 551 if (!argc) { 552 fprintf(stderr, "ERROR: No argument supplied for '--version-name' option\n"); 553 wantUsage = true; 554 goto bail; 555 } 556 bundle.setVersionName(argv[0]); 557 } else if (strcmp(cp, "-replace-version") == 0) { 558 bundle.setReplaceVersion(true); 559 } else if (strcmp(cp, "-values") == 0) { 560 bundle.setValues(true); 561 } else if (strcmp(cp, "-include-meta-data") == 0) { 562 bundle.setIncludeMetaData(true); 563 } else if (strcmp(cp, "-custom-package") == 0) { 564 argc--; 565 argv++; 566 if (!argc) { 567 fprintf(stderr, "ERROR: No argument supplied for '--custom-package' option\n"); 568 wantUsage = true; 569 goto bail; 570 } 571 bundle.setCustomPackage(argv[0]); 572 } else if (strcmp(cp, "-extra-packages") == 0) { 573 argc--; 574 argv++; 575 if (!argc) { 576 fprintf(stderr, "ERROR: No argument supplied for '--extra-packages' option\n"); 577 wantUsage = true; 578 goto bail; 579 } 580 bundle.setExtraPackages(argv[0]); 581 } else if (strcmp(cp, "-generate-dependencies") == 0) { 582 bundle.setGenDependencies(true); 583 } else if (strcmp(cp, "-utf16") == 0) { 584 bundle.setWantUTF16(true); 585 } else if (strcmp(cp, "-preferred-density") == 0) { 586 argc--; 587 argv++; 588 if (!argc) { 589 fprintf(stderr, "ERROR: No argument supplied for '--preferred-density' option\n"); 590 wantUsage = true; 591 goto bail; 592 } 593 bundle.setPreferredDensity(argv[0]); 594 } else if (strcmp(cp, "-split") == 0) { 595 argc--; 596 argv++; 597 if (!argc) { 598 fprintf(stderr, "ERROR: No argument supplied for '--split' option\n"); 599 wantUsage = true; 600 goto bail; 601 } 602 bundle.addSplitConfigurations(argv[0]); 603 } else if (strcmp(cp, "-feature-of") == 0) { 604 argc--; 605 argv++; 606 if (!argc) { 607 fprintf(stderr, "ERROR: No argument supplied for '--feature-of' option\n"); 608 wantUsage = true; 609 goto bail; 610 } 611 bundle.setFeatureOfPackage(argv[0]); 612 } else if (strcmp(cp, "-feature-after") == 0) { 613 argc--; 614 argv++; 615 if (!argc) { 616 fprintf(stderr, "ERROR: No argument supplied for '--feature-after' option\n"); 617 wantUsage = true; 618 goto bail; 619 } 620 bundle.setFeatureAfterPackage(argv[0]); 621 } else if (strcmp(cp, "-rename-manifest-package") == 0) { 622 argc--; 623 argv++; 624 if (!argc) { 625 fprintf(stderr, "ERROR: No argument supplied for '--rename-manifest-package' option\n"); 626 wantUsage = true; 627 goto bail; 628 } 629 bundle.setManifestPackageNameOverride(argv[0]); 630 } else if (strcmp(cp, "-rename-instrumentation-target-package") == 0) { 631 argc--; 632 argv++; 633 if (!argc) { 634 fprintf(stderr, "ERROR: No argument supplied for '--rename-instrumentation-target-package' option\n"); 635 wantUsage = true; 636 goto bail; 637 } 638 bundle.setInstrumentationPackageNameOverride(argv[0]); 639 } else if (strcmp(cp, "-auto-add-overlay") == 0) { 640 bundle.setAutoAddOverlay(true); 641 } else if (strcmp(cp, "-error-on-failed-insert") == 0) { 642 bundle.setErrorOnFailedInsert(true); 643 } else if (strcmp(cp, "-error-on-missing-config-entry") == 0) { 644 bundle.setErrorOnMissingConfigEntry(true); 645 } else if (strcmp(cp, "-output-text-symbols") == 0) { 646 argc--; 647 argv++; 648 if (!argc) { 649 fprintf(stderr, "ERROR: No argument supplied for '-output-text-symbols' option\n"); 650 wantUsage = true; 651 goto bail; 652 } 653 bundle.setOutputTextSymbols(argv[0]); 654 } else if (strcmp(cp, "-product") == 0) { 655 argc--; 656 argv++; 657 if (!argc) { 658 fprintf(stderr, "ERROR: No argument supplied for '--product' option\n"); 659 wantUsage = true; 660 goto bail; 661 } 662 bundle.setProduct(argv[0]); 663 } else if (strcmp(cp, "-non-constant-id") == 0) { 664 bundle.setNonConstantId(true); 665 } else if (strcmp(cp, "-skip-symbols-without-default-localization") == 0) { 666 bundle.setSkipSymbolsWithoutDefaultLocalization(true); 667 } else if (strcmp(cp, "-shared-lib") == 0) { 668 bundle.setNonConstantId(true); 669 bundle.setBuildSharedLibrary(true); 670 } else if (strcmp(cp, "-no-crunch") == 0) { 671 bundle.setUseCrunchCache(true); 672 } else if (strcmp(cp, "-ignore-assets") == 0) { 673 argc--; 674 argv++; 675 if (!argc) { 676 fprintf(stderr, "ERROR: No argument supplied for '--ignore-assets' option\n"); 677 wantUsage = true; 678 goto bail; 679 } 680 gUserIgnoreAssets = argv[0]; 681 } else if (strcmp(cp, "-pseudo-localize") == 0) { 682 bundle.setPseudolocalize(PSEUDO_ACCENTED | PSEUDO_BIDI); 683 } else if (strcmp(cp, "-no-version-vectors") == 0) { 684 bundle.setNoVersionVectors(true); 685 } else { 686 fprintf(stderr, "ERROR: Unknown option '-%s'\n", cp); 687 wantUsage = true; 688 goto bail; 689 } 690 cp += strlen(cp) - 1; 691 break; 692 default: 693 fprintf(stderr, "ERROR: Unknown flag '-%c'\n", *cp); 694 wantUsage = true; 695 goto bail; 696 } 697 698 cp++; 699 } 700 argc--; 701 argv++; 702 } 703 704 /* 705 * We're past the flags. The rest all goes straight in. 706 */ 707 bundle.setFileSpec(argv, argc); 708 709 result = handleCommand(&bundle); 710 711bail: 712 if (wantUsage) { 713 usage(); 714 result = 2; 715 } 716 717 //printf("--> returning %d\n", result); 718 return result; 719} 720