Debian Codegraph @

tools/aapt/Main.cpp

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