summaryrefslogtreecommitdiff
path: root/tools/aapt/AaptAssets.cpp
diff options
context:
space:
mode:
author Adam Lesinski <adamlesinski@google.com> 2014-06-18 15:06:01 -0700
committer Adam Lesinski <adamlesinski@google.com> 2014-08-04 18:48:14 -0700
commit833f3ccbc8f4dd1ec8abb9121988b99ff34ec4c1 (patch)
treea57e8389088178108de1424faf41ea3bb87c934a /tools/aapt/AaptAssets.cpp
parent5c09e8ad5ee8e67976066366527ee58792551953 (diff)
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
Diffstat (limited to 'tools/aapt/AaptAssets.cpp')
-rw-r--r--tools/aapt/AaptAssets.cpp45
1 files changed, 32 insertions, 13 deletions
diff --git a/tools/aapt/AaptAssets.cpp b/tools/aapt/AaptAssets.cpp
index 2028ff4ebc12..eead68c940cf 100644
--- a/tools/aapt/AaptAssets.cpp
+++ b/tools/aapt/AaptAssets.cpp
@@ -1542,22 +1542,41 @@ bool AaptAssets::isJavaSymbol(const AaptSymbolEntry& sym, bool includePrivate) c
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;
- }
+ 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;
}
- mHaveIncludedAssets = true;
}
+ 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;
}