diff options
author | Adam Lesinski <adamlesinski@google.com> | 2015-05-04 17:40:56 -0700 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2015-05-12 20:41:31 -0700 |
commit | 330edcdf1316ed599fe0eb16a64330821fd92f18 (patch) | |
tree | 8a9bddd59f53efc836b787565ba206a1d78383e3 /tools/aapt2/ResourceTable.cpp | |
parent | a4492b418d23e3bcdb077aab5d48eb24e932fc13 (diff) |
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/ResourceTable.cpp')
-rw-r--r-- | tools/aapt2/ResourceTable.cpp | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/tools/aapt2/ResourceTable.cpp b/tools/aapt2/ResourceTable.cpp index 94688606391a..c93ecc768022 100644 --- a/tools/aapt2/ResourceTable.cpp +++ b/tools/aapt2/ResourceTable.cpp @@ -42,6 +42,8 @@ static bool lessThanEntry(const std::unique_ptr<ResourceEntry>& lhs, const Strin } ResourceTable::ResourceTable() : mPackageId(kUnsetPackageId) { + // Make sure attrs always have type ID 1. + findOrCreateType(ResourceType::kAttr)->typeId = 1; } std::unique_ptr<ResourceTableType>& ResourceTable::findOrCreateType(ResourceType type) { @@ -142,10 +144,30 @@ static int defaultCollisionHandler(const Value& existing, const Value& incoming) } static constexpr const char16_t* kValidNameChars = u"._-"; +static constexpr const char16_t* kValidNameMangledChars = u"._-$"; + +bool ResourceTable::addResource(const ResourceNameRef& name, const ConfigDescription& config, + const SourceLine& source, std::unique_ptr<Value> value) { + return addResourceImpl(name, ResourceId{}, config, source, std::move(value), kValidNameChars); +} bool ResourceTable::addResource(const ResourceNameRef& name, const ResourceId resId, - const ConfigDescription& config, const SourceLine& source, - std::unique_ptr<Value> value) { + const ConfigDescription& config, const SourceLine& source, + std::unique_ptr<Value> value) { + return addResourceImpl(name, resId, config, source, std::move(value), kValidNameChars); +} + +bool ResourceTable::addResourceAllowMangled(const ResourceNameRef& name, + const ConfigDescription& config, + const SourceLine& source, + std::unique_ptr<Value> value) { + return addResourceImpl(name, ResourceId{}, config, source, std::move(value), + kValidNameMangledChars); +} + +bool ResourceTable::addResourceImpl(const ResourceNameRef& name, const ResourceId resId, + const ConfigDescription& config, const SourceLine& source, + std::unique_ptr<Value> value, const char16_t* validChars) { if (!name.package.empty() && name.package != mPackage) { Logger::error(source) << "resource '" @@ -157,7 +179,7 @@ bool ResourceTable::addResource(const ResourceNameRef& name, const ResourceId re return false; } - auto badCharIter = util::findNonAlphaNumericAndNotInSet(name.entry, kValidNameChars); + auto badCharIter = util::findNonAlphaNumericAndNotInSet(name.entry, validChars); if (badCharIter != name.entry.end()) { Logger::error(source) << "resource '" @@ -233,13 +255,18 @@ bool ResourceTable::addResource(const ResourceNameRef& name, const ResourceId re return true; } -bool ResourceTable::addResource(const ResourceNameRef& name, const ConfigDescription& config, - const SourceLine& source, std::unique_ptr<Value> value) { - return addResource(name, ResourceId{}, config, source, std::move(value)); -} - bool ResourceTable::markPublic(const ResourceNameRef& name, const ResourceId resId, const SourceLine& source) { + return markPublicImpl(name, resId, source, kValidNameChars); +} + +bool ResourceTable::markPublicAllowMangled(const ResourceNameRef& name, const ResourceId resId, + const SourceLine& source) { + return markPublicImpl(name, resId, source, kValidNameMangledChars); +} + +bool ResourceTable::markPublicImpl(const ResourceNameRef& name, const ResourceId resId, + const SourceLine& source, const char16_t* validChars) { if (!name.package.empty() && name.package != mPackage) { Logger::error(source) << "resource '" @@ -251,7 +278,7 @@ bool ResourceTable::markPublic(const ResourceNameRef& name, const ResourceId res return false; } - auto badCharIter = util::findNonAlphaNumericAndNotInSet(name.entry, kValidNameChars); + auto badCharIter = util::findNonAlphaNumericAndNotInSet(name.entry, validChars); if (badCharIter != name.entry.end()) { Logger::error(source) << "resource '" |