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