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/AaptAssets.cpp b/tools/aapt/AaptAssets.cpp
index 2028ff4..eead68c 100644
--- a/tools/aapt/AaptAssets.cpp
+++ b/tools/aapt/AaptAssets.cpp
@@ -1542,22 +1542,41 @@
status_t AaptAssets::buildIncludedResources(Bundle* bundle)
{
- if (!mHaveIncludedAssets) {
- // Add in all includes.
- const Vector<const char*>& incl = bundle->getPackageIncludes();
- const size_t N=incl.size();
- for (size_t i=0; i<N; i++) {
- if (bundle->getVerbose())
- printf("Including resources from package: %s\n", incl[i]);
- if (!mIncludedAssets.addAssetPath(String8(incl[i]), NULL)) {
- fprintf(stderr, "ERROR: Asset package include '%s' not found.\n",
- incl[i]);
- return UNKNOWN_ERROR;
- }
- }
- mHaveIncludedAssets = true;
+ if (mHaveIncludedAssets) {
+ return NO_ERROR;
}
+ // Add in all includes.
+ const Vector<String8>& includes = bundle->getPackageIncludes();
+ const size_t packageIncludeCount = includes.size();
+ for (size_t i = 0; i < packageIncludeCount; i++) {
+ if (bundle->getVerbose()) {
+ printf("Including resources from package: %s\n", includes[i].string());
+ }
+
+ if (!mIncludedAssets.addAssetPath(includes[i], NULL)) {
+ fprintf(stderr, "ERROR: Asset package include '%s' not found.\n",
+ includes[i].string());
+ return UNKNOWN_ERROR;
+ }
+ }
+
+ const String8& featureOfBase = bundle->getFeatureOfPackage();
+ if (!featureOfBase.isEmpty()) {
+ if (bundle->getVerbose()) {
+ printf("Including base feature resources from package: %s\n",
+ featureOfBase.string());
+ }
+
+ if (!mIncludedAssets.addAssetPath(featureOfBase, NULL)) {
+ fprintf(stderr, "ERROR: base feature package '%s' not found.\n",
+ featureOfBase.string());
+ return UNKNOWN_ERROR;
+ }
+ }
+
+ mHaveIncludedAssets = true;
+
return NO_ERROR;
}