From 833f3ccbc8f4dd1ec8abb9121988b99ff34ec4c1 Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Wed, 18 Jun 2014 15:06:01 -0700 Subject: 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 --- tools/aapt/AaptAssets.cpp | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) (limited to 'tools/aapt/AaptAssets.cpp') 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& incl = bundle->getPackageIncludes(); - const size_t N=incl.size(); - for (size_t i=0; igetVerbose()) - 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& 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; } -- cgit v1.2.3-59-g8ed1b