summaryrefslogtreecommitdiffstats
path: root/tools/aapt2/TableFlattener.cpp
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2015-05-04 17:40:56 -0700
committerAdam Lesinski <adamlesinski@google.com>2015-05-12 20:41:31 -0700
commit330edcdf1316ed599fe0eb16a64330821fd92f18 (patch)
tree8a9bddd59f53efc836b787565ba206a1d78383e3 /tools/aapt2/TableFlattener.cpp
parenta4492b418d23e3bcdb077aab5d48eb24e932fc13 (diff)
downloadframeworks_base-330edcdf1316ed599fe0eb16a64330821fd92f18.zip
frameworks_base-330edcdf1316ed599fe0eb16a64330821fd92f18.tar.gz
frameworks_base-330edcdf1316ed599fe0eb16a64330821fd92f18.tar.bz2
AAPT2: Support static lib referencing static lib
When a static library A references static library B, and app C references both A and B, we get the following symbol merging, symbols from library B get imported twice. We must only check that symbol references to library B are valid when building library A. We should only merge all the symbols when building final app C. Change-Id: I23cba33b0901dcbb5328d9c9dfaa6a979c073c36
Diffstat (limited to 'tools/aapt2/TableFlattener.cpp')
-rw-r--r--tools/aapt2/TableFlattener.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/tools/aapt2/TableFlattener.cpp b/tools/aapt2/TableFlattener.cpp
index aa0f1d5..539c48f 100644
--- a/tools/aapt2/TableFlattener.cpp
+++ b/tools/aapt2/TableFlattener.cpp
@@ -79,6 +79,7 @@ public:
// Write the key.
if (!Res_INTERNALID(key.id.id) && !key.id.isValid()) {
+ assert(key.name.isValid());
mSymbols->push_back(std::make_pair(ResourceNameRef(key.name),
mOut->size() - sizeof(*outMapEntry)));
}
@@ -96,6 +97,23 @@ public:
outMapEntry->value.size = sizeof(outMapEntry->value);
}
+ void flattenValueOnly(const Item& value) {
+ mMap->count++;
+
+ android::ResTable_map* outMapEntry = mOut->nextBlock<android::ResTable_map>();
+
+ // Write the value.
+ value.flatten(outMapEntry->value);
+
+ if (outMapEntry->value.data == 0x0) {
+ visitFunc<Reference>(value, [&](const Reference& reference) {
+ mSymbols->push_back(std::make_pair(ResourceNameRef(reference.name),
+ mOut->size() - sizeof(outMapEntry->value.data)));
+ });
+ }
+ outMapEntry->value.size = sizeof(outMapEntry->value);
+ }
+
static bool compareStyleEntries(const Style::Entry* lhs, const Style::Entry* rhs) {
return lhs->key.id < rhs->key.id;
}
@@ -139,7 +157,7 @@ public:
void visit(const Array& array, ValueVisitorArgs&) override {
for (const auto& item : array.items) {
- flattenEntry({}, *item);
+ flattenValueOnly(*item);
}
}
@@ -334,6 +352,10 @@ bool TableFlattener::flatten(BigBuffer* out, const ResourceTable& table) {
spec->id = type->typeId;
spec->entryCount = type->entries.size();
+ if (type->entries.empty()) {
+ continue;
+ }
+
// Reserve space for the masks of each resource in this type. These
// show for which configuration axis the resource changes.
uint32_t* configMasks = typeBlock.nextBlock<uint32_t>(type->entries.size());