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