AAPT support for feature splits
This change allows the developer to add a base package for
which to build a feature split. The generated resource types
will begin after the base APK's defined types so as not
to collide or override resources.
Multiple features can be generated by first choosing an
arbitrary order for the features. Then for each feature,
the base APK and any preceding features are specified
with the --feature-of flags.
So with a base APK 'A' and features, 'B', and 'C',
'B' would be built with
aapt package [...] --feature-of A [...]
and 'C' would be built with
aapt package [...] --feature-of A --feature-of B [...]
Change-Id: I1be66e3f8df9a737b21c71f8a93685376c7e6780
diff --git a/tools/aapt/Main.cpp b/tools/aapt/Main.cpp
index 322d86c..736ae26 100644
--- a/tools/aapt/Main.cpp
+++ b/tools/aapt/Main.cpp
@@ -71,6 +71,7 @@
" [--product product1,product2,...] \\\n"
" [-c CONFIGS] [--preferred-configurations CONFIGS] \\\n"
" [--split CONFIGS [--split CONFIGS]] \\\n"
+ " [--feature-of package [--feature-after package]] \\\n"
" [raw-files-dir [raw-files-dir] ...] \\\n"
" [--output-text-symbols DIR]\n"
"\n"
@@ -167,6 +168,14 @@
" --split\n"
" Builds a separate split APK for the configurations listed. This can\n"
" be loaded alongside the base APK at runtime.\n"
+ " --feature-of\n"
+ " Builds a split APK that is a feature of the apk specified here. Resources\n"
+ " in the base APK can be referenced from the the feature APK.\n"
+ " --feature-after\n"
+ " An app can have multiple Feature Split APKs which must be totally ordered.\n"
+ " If --feature-of is specified, this flag specifies which Feature Split APK\n"
+ " comes before this one. The first Feature Split APK should not define\n"
+ " anything here.\n"
" --rename-manifest-package\n"
" Rewrite the manifest so that its package name is the package name\n"
" given here. Relative class names (for example .Foo) will be\n"
@@ -583,6 +592,24 @@
goto bail;
}
bundle.addSplitConfigurations(argv[0]);
+ } else if (strcmp(cp, "-feature-of") == 0) {
+ argc--;
+ argv++;
+ if (!argc) {
+ fprintf(stderr, "ERROR: No argument supplied for '--feature-of' option\n");
+ wantUsage = true;
+ goto bail;
+ }
+ bundle.setFeatureOfPackage(argv[0]);
+ } else if (strcmp(cp, "-feature-after") == 0) {
+ argc--;
+ argv++;
+ if (!argc) {
+ fprintf(stderr, "ERROR: No argument supplied for '--feature-after' option\n");
+ wantUsage = true;
+ goto bail;
+ }
+ bundle.setFeatureAfterPackage(argv[0]);
} else if (strcmp(cp, "-rename-manifest-package") == 0) {
argc--;
argv++;