summaryrefslogtreecommitdiff
path: root/tools/aapt/Resource.cpp
diff options
context:
space:
mode:
author Adam Lesinski <adamlesinski@google.com> 2015-10-28 15:44:27 -0700
committer Adam Lesinski <adamlesinski@google.com> 2015-11-30 14:43:43 -0800
commit07dfd2d8642f8a3630ca6429f740865a0c0bfdf7 (patch)
tree28a4aa59b021ddbf0f7bcf9890c98994fd16ade8 /tools/aapt/Resource.cpp
parent14ed6cf3e7bada4932314969000d384bed6d3f92 (diff)
Implement AAPT Bundle format
AAPT will scan XML files looking for the <aapt:attr> XML tag. <!-- @layout/bundle.xml --> <ImageView xmlns:aapt="http://schemas.android.com/aapt"> <aapt:attr name="android:src"> <vector android:pathData="..." ...> </vector> </aapt:attr> </ImageView> The SINGLE child element of the <aapt:attr> tag is extracted into its own top level resource. It is given a generated name. The parent element of <aapt:attr> is then given the resource attribute that was assigned to the `name' attribute. The value is set to a reference to the generated resource. <!-- @layout/bundle.xml --> <ImageView android:src="@drawable/bundle_1.xml"> </ImageView> <!-- @layout/bundle_1.xml --> <vector android:pathData="..." ...> </vector> Bug:22627686 Change-Id: I8575fc4f739011402662fbf6b3db96df0012f598
Diffstat (limited to 'tools/aapt/Resource.cpp')
-rw-r--r--tools/aapt/Resource.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp
index e22e76de66c2..fb0fe38da1ff 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -1537,12 +1537,20 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets, sp<ApkBuil
std::queue<CompileResourceWorkItem>& workQueue = table.getWorkQueue();
while (!workQueue.empty()) {
CompileResourceWorkItem& workItem = workQueue.front();
- err = compileXmlFile(bundle, assets, workItem.resourceName, workItem.file, &table, xmlFlags);
+ int xmlCompilationFlags = xmlFlags | XML_COMPILE_PARSE_VALUES
+ | XML_COMPILE_ASSIGN_ATTRIBUTE_IDS;
+ if (!workItem.needsCompiling) {
+ xmlCompilationFlags &= ~XML_COMPILE_ASSIGN_ATTRIBUTE_IDS;
+ xmlCompilationFlags &= ~XML_COMPILE_PARSE_VALUES;
+ }
+ err = compileXmlFile(bundle, assets, workItem.resourceName, workItem.xmlRoot,
+ workItem.file, &table, xmlCompilationFlags);
+
if (err == NO_ERROR) {
assets->addResource(workItem.resPath.getPathLeaf(),
- workItem.resPath,
- workItem.file,
- workItem.file->getResourceType());
+ workItem.resPath,
+ workItem.file,
+ workItem.file->getResourceType());
} else {
hasErrors = true;
}
@@ -1737,9 +1745,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets, sp<ApkBuil
manifestFile->getGroupEntry(),
manifestFile->getResourceType());
err = compileXmlFile(bundle, assets, String16(), manifestFile,
- outManifestFile, &table,
- XML_COMPILE_ASSIGN_ATTRIBUTE_IDS
- | XML_COMPILE_STRIP_WHITESPACE | XML_COMPILE_STRIP_RAW_VALUES);
+ outManifestFile, &table, XML_COMPILE_STANDARD_RESOURCE & ~XML_COMPILE_STRIP_COMMENTS);
if (err < NO_ERROR) {
return err;
}