Loading tools/aapt2/Android.mk +3 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ sources := \ proto/ProtoHelpers.cpp \ proto/TableProtoDeserializer.cpp \ proto/TableProtoSerializer.cpp \ split/TableSplitter.cpp \ unflatten/BinaryResourceParser.cpp \ unflatten/ResChunkPullParser.cpp \ util/BigBuffer.cpp \ Loading Loading @@ -90,6 +91,7 @@ testSources := \ link/XmlReferenceLinker_test.cpp \ process/SymbolTable_test.cpp \ proto/TableProtoSerializer_test.cpp \ split/TableSplitter_test.cpp \ util/BigBuffer_test.cpp \ util/Maybe_test.cpp \ util/StringPiece_test.cpp \ Loading @@ -103,6 +105,7 @@ testSources := \ ResourceParser_test.cpp \ ResourceTable_test.cpp \ ResourceUtils_test.cpp \ SdkConstants_test.cpp \ StringPool_test.cpp \ ValueVisitor_test.cpp \ xml/XmlDom_test.cpp \ Loading tools/aapt2/Debug.cpp +29 −6 Original line number Diff line number Diff line Loading @@ -30,7 +30,8 @@ namespace aapt { struct PrintVisitor : public ValueVisitor { class PrintVisitor : public ValueVisitor { public: using ValueVisitor::visit; void visit(Attribute* attr) override { Loading Loading @@ -69,7 +70,11 @@ struct PrintVisitor : public ValueVisitor { for (const auto& entry : style->entries) { std::cout << "\n "; if (entry.key.name) { std::cout << entry.key.name.value().package << ":" << entry.key.name.value().entry; const ResourceName& name = entry.key.name.value(); if (!name.package.empty()) { std::cout << name.package << ":"; } std::cout << name.entry; } if (entry.key.id) { Loading @@ -89,7 +94,21 @@ struct PrintVisitor : public ValueVisitor { } void visit(Styleable* styleable) override { styleable->print(&std::cout); std::cout << "(styleable)"; for (const auto& attr : styleable->entries) { std::cout << "\n "; if (attr.name) { const ResourceName& name = attr.name.value(); if (!name.package.empty()) { std::cout << name.package << ":"; } std::cout << name.entry; } if (attr.id) { std::cout << "(" << attr.id.value() << ")"; } } } void visitItem(Item* item) override { Loading @@ -97,7 +116,9 @@ struct PrintVisitor : public ValueVisitor { } }; void Debug::printTable(ResourceTable* table) { void Debug::printTable(ResourceTable* table, const DebugPrintTableOptions& options) { PrintVisitor visitor; for (auto& package : table->packages) { std::cout << "Package name=" << package->name; if (package->id) { Loading @@ -106,7 +127,7 @@ void Debug::printTable(ResourceTable* table) { std::cout << std::endl; for (const auto& type : package->types) { std::cout << " type " << type->type; std::cout << "\n type " << type->type; if (type->id) { std::cout << " id=" << std::hex << (int) type->id.value() << std::dec; } Loading Loading @@ -142,10 +163,12 @@ void Debug::printTable(ResourceTable* table) { std::cout << std::endl; PrintVisitor visitor; for (const auto& value : entry->values) { std::cout << " (" << value->config << ") "; value->value->accept(&visitor); if (options.showSources && !value->value->getSource().path.empty()) { std::cout << " src=" << value->value->getSource(); } std::cout << std::endl; } } Loading tools/aapt2/Debug.h +5 −1 Original line number Diff line number Diff line Loading @@ -25,8 +25,12 @@ namespace aapt { struct DebugPrintTableOptions { bool showSources = false; }; struct Debug { static void printTable(ResourceTable* table); static void printTable(ResourceTable* table, const DebugPrintTableOptions& options = {}); static void printStyleGraph(ResourceTable* table, const ResourceName& targetStyle); static void dumpHex(const void* data, size_t len); Loading tools/aapt2/ResourceTable.cpp +19 −8 Original line number Diff line number Diff line Loading @@ -277,20 +277,31 @@ bool ResourceTable::addFileReference(const ResourceNameRef& name, const Source& source, const StringPiece16& path, IDiagnostics* diag) { return addFileReference(name, config, source, path, resolveValueCollision, diag); return addFileReferenceImpl(name, config, source, path, nullptr, kValidNameChars, diag); } bool ResourceTable::addFileReference(const ResourceNameRef& name, bool ResourceTable::addFileReferenceAllowMangled(const ResourceNameRef& name, const ConfigDescription& config, const Source& source, const StringPiece16& path, std::function<int(Value*,Value*)> conflictResolver, io::IFile* file, IDiagnostics* diag) { return addFileReferenceImpl(name, config, source, path, file, kValidNameMangledChars, diag); } bool ResourceTable::addFileReferenceImpl(const ResourceNameRef& name, const ConfigDescription& config, const Source& source, const StringPiece16& path, io::IFile* file, const char16_t* validChars, IDiagnostics* diag) { std::unique_ptr<FileReference> fileRef = util::make_unique<FileReference>( stringPool.makeRef(path)); fileRef->setSource(source); fileRef->file = file; return addResourceImpl(name, ResourceId{}, config, StringPiece{}, std::move(fileRef), kValidNameChars, conflictResolver, diag); kValidNameChars, resolveValueCollision, diag); } bool ResourceTable::addResourceAllowMangled(const ResourceNameRef& name, Loading tools/aapt2/ResourceTable.h +20 −11 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include "ResourceValues.h" #include "Source.h" #include "StringPool.h" #include "io/File.h" #include <android-base/macros.h> #include <map> Loading Loading @@ -207,11 +208,11 @@ public: const StringPiece16& path, IDiagnostics* diag); bool addFileReference(const ResourceNameRef& name, bool addFileReferenceAllowMangled(const ResourceNameRef& name, const ConfigDescription& config, const Source& source, const StringPiece16& path, std::function<int(Value*,Value*)> conflictResolver, io::IFile* file, IDiagnostics* diag); /** Loading Loading @@ -280,6 +281,14 @@ public: private: ResourceTablePackage* findOrCreatePackage(const StringPiece16& name); bool addFileReferenceImpl(const ResourceNameRef& name, const ConfigDescription& config, const Source& source, const StringPiece16& path, io::IFile* file, const char16_t* validChars, IDiagnostics* diag); bool addResourceImpl(const ResourceNameRef& name, ResourceId resId, const ConfigDescription& config, Loading Loading
tools/aapt2/Android.mk +3 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ sources := \ proto/ProtoHelpers.cpp \ proto/TableProtoDeserializer.cpp \ proto/TableProtoSerializer.cpp \ split/TableSplitter.cpp \ unflatten/BinaryResourceParser.cpp \ unflatten/ResChunkPullParser.cpp \ util/BigBuffer.cpp \ Loading Loading @@ -90,6 +91,7 @@ testSources := \ link/XmlReferenceLinker_test.cpp \ process/SymbolTable_test.cpp \ proto/TableProtoSerializer_test.cpp \ split/TableSplitter_test.cpp \ util/BigBuffer_test.cpp \ util/Maybe_test.cpp \ util/StringPiece_test.cpp \ Loading @@ -103,6 +105,7 @@ testSources := \ ResourceParser_test.cpp \ ResourceTable_test.cpp \ ResourceUtils_test.cpp \ SdkConstants_test.cpp \ StringPool_test.cpp \ ValueVisitor_test.cpp \ xml/XmlDom_test.cpp \ Loading
tools/aapt2/Debug.cpp +29 −6 Original line number Diff line number Diff line Loading @@ -30,7 +30,8 @@ namespace aapt { struct PrintVisitor : public ValueVisitor { class PrintVisitor : public ValueVisitor { public: using ValueVisitor::visit; void visit(Attribute* attr) override { Loading Loading @@ -69,7 +70,11 @@ struct PrintVisitor : public ValueVisitor { for (const auto& entry : style->entries) { std::cout << "\n "; if (entry.key.name) { std::cout << entry.key.name.value().package << ":" << entry.key.name.value().entry; const ResourceName& name = entry.key.name.value(); if (!name.package.empty()) { std::cout << name.package << ":"; } std::cout << name.entry; } if (entry.key.id) { Loading @@ -89,7 +94,21 @@ struct PrintVisitor : public ValueVisitor { } void visit(Styleable* styleable) override { styleable->print(&std::cout); std::cout << "(styleable)"; for (const auto& attr : styleable->entries) { std::cout << "\n "; if (attr.name) { const ResourceName& name = attr.name.value(); if (!name.package.empty()) { std::cout << name.package << ":"; } std::cout << name.entry; } if (attr.id) { std::cout << "(" << attr.id.value() << ")"; } } } void visitItem(Item* item) override { Loading @@ -97,7 +116,9 @@ struct PrintVisitor : public ValueVisitor { } }; void Debug::printTable(ResourceTable* table) { void Debug::printTable(ResourceTable* table, const DebugPrintTableOptions& options) { PrintVisitor visitor; for (auto& package : table->packages) { std::cout << "Package name=" << package->name; if (package->id) { Loading @@ -106,7 +127,7 @@ void Debug::printTable(ResourceTable* table) { std::cout << std::endl; for (const auto& type : package->types) { std::cout << " type " << type->type; std::cout << "\n type " << type->type; if (type->id) { std::cout << " id=" << std::hex << (int) type->id.value() << std::dec; } Loading Loading @@ -142,10 +163,12 @@ void Debug::printTable(ResourceTable* table) { std::cout << std::endl; PrintVisitor visitor; for (const auto& value : entry->values) { std::cout << " (" << value->config << ") "; value->value->accept(&visitor); if (options.showSources && !value->value->getSource().path.empty()) { std::cout << " src=" << value->value->getSource(); } std::cout << std::endl; } } Loading
tools/aapt2/Debug.h +5 −1 Original line number Diff line number Diff line Loading @@ -25,8 +25,12 @@ namespace aapt { struct DebugPrintTableOptions { bool showSources = false; }; struct Debug { static void printTable(ResourceTable* table); static void printTable(ResourceTable* table, const DebugPrintTableOptions& options = {}); static void printStyleGraph(ResourceTable* table, const ResourceName& targetStyle); static void dumpHex(const void* data, size_t len); Loading
tools/aapt2/ResourceTable.cpp +19 −8 Original line number Diff line number Diff line Loading @@ -277,20 +277,31 @@ bool ResourceTable::addFileReference(const ResourceNameRef& name, const Source& source, const StringPiece16& path, IDiagnostics* diag) { return addFileReference(name, config, source, path, resolveValueCollision, diag); return addFileReferenceImpl(name, config, source, path, nullptr, kValidNameChars, diag); } bool ResourceTable::addFileReference(const ResourceNameRef& name, bool ResourceTable::addFileReferenceAllowMangled(const ResourceNameRef& name, const ConfigDescription& config, const Source& source, const StringPiece16& path, std::function<int(Value*,Value*)> conflictResolver, io::IFile* file, IDiagnostics* diag) { return addFileReferenceImpl(name, config, source, path, file, kValidNameMangledChars, diag); } bool ResourceTable::addFileReferenceImpl(const ResourceNameRef& name, const ConfigDescription& config, const Source& source, const StringPiece16& path, io::IFile* file, const char16_t* validChars, IDiagnostics* diag) { std::unique_ptr<FileReference> fileRef = util::make_unique<FileReference>( stringPool.makeRef(path)); fileRef->setSource(source); fileRef->file = file; return addResourceImpl(name, ResourceId{}, config, StringPiece{}, std::move(fileRef), kValidNameChars, conflictResolver, diag); kValidNameChars, resolveValueCollision, diag); } bool ResourceTable::addResourceAllowMangled(const ResourceNameRef& name, Loading
tools/aapt2/ResourceTable.h +20 −11 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include "ResourceValues.h" #include "Source.h" #include "StringPool.h" #include "io/File.h" #include <android-base/macros.h> #include <map> Loading Loading @@ -207,11 +208,11 @@ public: const StringPiece16& path, IDiagnostics* diag); bool addFileReference(const ResourceNameRef& name, bool addFileReferenceAllowMangled(const ResourceNameRef& name, const ConfigDescription& config, const Source& source, const StringPiece16& path, std::function<int(Value*,Value*)> conflictResolver, io::IFile* file, IDiagnostics* diag); /** Loading Loading @@ -280,6 +281,14 @@ public: private: ResourceTablePackage* findOrCreatePackage(const StringPiece16& name); bool addFileReferenceImpl(const ResourceNameRef& name, const ConfigDescription& config, const Source& source, const StringPiece16& path, io::IFile* file, const char16_t* validChars, IDiagnostics* diag); bool addResourceImpl(const ResourceNameRef& name, ResourceId resId, const ConfigDescription& config, Loading