From e4bb9eb5af5b0899dc0921d5580220b20e15bd5a Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Fri, 12 Feb 2016 22:18:51 -0800 Subject: [PATCH] AAPT2: Introduce notion of 'product' to ResourceTable This allows us to preserve the various product definitions during the compile phase, and allows us to select the product in the link phase. This allows compiled files to remain product-independent, so that they do not need to be recompiled when switching targets. Bug:25958912 Change-Id: Iaa7eed25c834b67a39cdc9be43613e8b5ab6cdd7 --- tools/aapt2/Android.mk | 2 + tools/aapt2/Debug.cpp | 6 +- tools/aapt2/ResourceParser.cpp | 46 +----- tools/aapt2/ResourceParser.h | 10 -- tools/aapt2/ResourceParser_test.cpp | 60 +++----- tools/aapt2/ResourceTable.cpp | 134 +++++++++++++---- tools/aapt2/ResourceTable.h | 132 ++++++++++++----- tools/aapt2/ResourceTable_test.cpp | 44 +++++- tools/aapt2/ValueVisitor.h | 2 +- tools/aapt2/compile/Compile.cpp | 11 -- tools/aapt2/compile/PseudolocaleGenerator.cpp | 50 ++++--- tools/aapt2/flatten/TableFlattener.cpp | 8 +- tools/aapt2/java/JavaClassGenerator.cpp | 14 +- tools/aapt2/link/AutoVersioner.cpp | 37 +++-- tools/aapt2/link/AutoVersioner_test.cpp | 14 +- tools/aapt2/link/Link.cpp | 30 +++- tools/aapt2/link/Linkers.h | 2 +- tools/aapt2/link/ProductFilter.cpp | 118 +++++++++++++++ tools/aapt2/link/ProductFilter.h | 49 +++++++ tools/aapt2/link/ProductFilter_test.cpp | 136 ++++++++++++++++++ tools/aapt2/link/ReferenceLinker.cpp | 2 +- tools/aapt2/link/TableMerger.cpp | 39 ++--- tools/aapt2/process/SymbolTable.cpp | 10 +- tools/aapt2/proto/TableProtoDeserializer.cpp | 15 +- tools/aapt2/proto/TableProtoSerializer.cpp | 21 +-- .../aapt2/proto/TableProtoSerializer_test.cpp | 23 ++- tools/aapt2/test/Builders.h | 12 +- tools/aapt2/test/Common.h | 27 ++-- .../aapt2/unflatten/BinaryResourceParser.cpp | 2 +- tools/aapt2/util/Comparators.h | 37 ----- 30 files changed, 754 insertions(+), 339 deletions(-) create mode 100644 tools/aapt2/link/ProductFilter.cpp create mode 100644 tools/aapt2/link/ProductFilter.h create mode 100644 tools/aapt2/link/ProductFilter_test.cpp delete mode 100644 tools/aapt2/util/Comparators.h diff --git a/tools/aapt2/Android.mk b/tools/aapt2/Android.mk index 88b6270fad609..cb82ac37a3b2f 100644 --- a/tools/aapt2/Android.mk +++ b/tools/aapt2/Android.mk @@ -38,6 +38,7 @@ sources := \ io/ZipArchive.cpp \ link/AutoVersioner.cpp \ link/ManifestFixer.cpp \ + link/ProductFilter.cpp \ link/PrivateAttributeMover.cpp \ link/ReferenceLinker.cpp \ link/TableMerger.cpp \ @@ -83,6 +84,7 @@ testSources := \ link/AutoVersioner_test.cpp \ link/ManifestFixer_test.cpp \ link/PrivateAttributeMover_test.cpp \ + link/ProductFilter_test.cpp \ link/ReferenceLinker_test.cpp \ link/TableMerger_test.cpp \ link/XmlReferenceLinker_test.cpp \ diff --git a/tools/aapt2/Debug.cpp b/tools/aapt2/Debug.cpp index b4e75f9be3a9b..4bea129736922 100644 --- a/tools/aapt2/Debug.cpp +++ b/tools/aapt2/Debug.cpp @@ -144,8 +144,8 @@ void Debug::printTable(ResourceTable* table) { PrintVisitor visitor; for (const auto& value : entry->values) { - std::cout << " (" << value.config << ") "; - value.value->accept(&visitor); + std::cout << " (" << value->config << ") "; + value->value->accept(&visitor); std::cout << std::endl; } } @@ -176,7 +176,7 @@ void Debug::printStyleGraph(ResourceTable* table, const ResourceName& targetStyl if (result) { ResourceEntry* entry = result.value().entry; for (const auto& value : entry->values) { - if (Style* style = valueCast