diff options
author | Shane Farmer <safarmer@google.com> | 2017-06-19 12:52:04 -0700 |
---|---|---|
committer | Shane Farmer <safarmer@google.com> | 2017-06-21 14:10:23 -0700 |
commit | 5766943f558c8fccc714bb3d0a96af70816a5545 (patch) | |
tree | fb4cf8d223e103b930e217432e8579675a02b356 /tools/aapt2/configuration/ConfigurationParser.cpp | |
parent | c10f9d81f849b883eb72663bb62d344ce70a3e1e (diff) |
AAPT2: Split APK by ABI.
Added a FilterChain that can apply multiple filter steps to an APK file
as it is being written to disk. The first filter applied is by ABI. If
a library in the APK does not match the filter it is skipped.
Added an AbiFilter that keeps files that are either not native libs or
are for the set of wanted ABIs
Test: ran unit tests locally
Test: ran against an APK with ARM and x68 libs and diffed the results
Change-Id: I3fb901d3de3513e85f2a2763a8e4487a28ed4881
Diffstat (limited to 'tools/aapt2/configuration/ConfigurationParser.cpp')
-rw-r--r-- | tools/aapt2/configuration/ConfigurationParser.cpp | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/tools/aapt2/configuration/ConfigurationParser.cpp b/tools/aapt2/configuration/ConfigurationParser.cpp index 303a809fbaa9..555cb35c0bb9 100644 --- a/tools/aapt2/configuration/ConfigurationParser.cpp +++ b/tools/aapt2/configuration/ConfigurationParser.cpp @@ -18,6 +18,7 @@ #include <algorithm> #include <functional> +#include <map> #include <memory> #include <utility> @@ -56,15 +57,15 @@ using ::aapt::xml::XmlActionExecutorPolicy; using ::aapt::xml::XmlNodeAction; using ::android::base::ReadFileToString; -const std::unordered_map<std::string, Abi> kAbiMap = { - {"armeabi", Abi::kArmeV6}, - {"armeabi-v7a", Abi::kArmV7a}, - {"arm64-v8a", Abi::kArm64V8a}, - {"x86", Abi::kX86}, - {"x86_64", Abi::kX86_64}, - {"mips", Abi::kMips}, - {"mips64", Abi::kMips64}, - {"universal", Abi::kUniversal}, +const std::unordered_map<std::string, Abi> kStringToAbiMap = { + {"armeabi", Abi::kArmeV6}, {"armeabi-v7a", Abi::kArmV7a}, {"arm64-v8a", Abi::kArm64V8a}, + {"x86", Abi::kX86}, {"x86_64", Abi::kX86_64}, {"mips", Abi::kMips}, + {"mips64", Abi::kMips64}, {"universal", Abi::kUniversal}, +}; +const std::map<Abi, std::string> kAbiToStringMap = { + {Abi::kArmeV6, "armeabi"}, {Abi::kArmV7a, "armeabi-v7a"}, {Abi::kArm64V8a, "arm64-v8a"}, + {Abi::kX86, "x86"}, {Abi::kX86_64, "x86_64"}, {Abi::kMips, "mips"}, + {Abi::kMips64, "mips64"}, {Abi::kUniversal, "universal"}, }; constexpr const char* kAaptXmlNs = "http://schemas.android.com/tools/aapt"; @@ -102,7 +103,13 @@ class NamespaceVisitor : public xml::Visitor { } // namespace +namespace configuration { + +const std::string& AbiToString(Abi abi) { + return kAbiToStringMap.find(abi)->second; +} +} // namespace configuration /** Returns a ConfigurationParser for the file located at the provided path. */ Maybe<ConfigurationParser> ConfigurationParser::ForPath(const std::string& path) { @@ -175,6 +182,9 @@ Maybe<Configuration> ConfigurationParser::Parse() { return {}; } + // TODO: Validate all references in the configuration are valid. It should be safe to assume from + // this point on that any references from one section to another will be present. + return {config}; } @@ -201,7 +211,7 @@ ConfigurationParser::ActionHandler ConfigurationParser::artifact_handler_ = DiagMessage() << "Unknown artifact attribute: " << attr.name << " = " << attr.value); } } - config->artifacts[artifact.name] = artifact; + config->artifacts.push_back(artifact); return true; }; @@ -236,7 +246,7 @@ ConfigurationParser::ActionHandler ConfigurationParser::abi_group_handler_ = for (auto& node : child->children) { xml::Text* t; if ((t = NodeCast<xml::Text>(node.get())) != nullptr) { - group.push_back(kAbiMap.at(TrimWhitespace(t->text).to_string())); + group.push_back(kStringToAbiMap.at(TrimWhitespace(t->text).to_string())); break; } } |