From 355f285ffd000f6cfe76680eb22d010546d124bb Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Sat, 13 Feb 2016 20:26:45 -0800 Subject: AAPT2: Implement density stripping and initial Split support When a preferred density is supplied, the closest matching densities will be selected, the rest stripped from the APK. Split support will be enabled in a later CL. Command line support is still needed, but the foundation is ready. Bug:25958912 Change-Id: I56d599806b4ec4ffa24e17aad48d47130ca05c08 --- tools/aapt2/Debug.cpp | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'tools/aapt2/Debug.cpp') diff --git a/tools/aapt2/Debug.cpp b/tools/aapt2/Debug.cpp index 4bea12973692..19bd5210c840 100644 --- a/tools/aapt2/Debug.cpp +++ b/tools/aapt2/Debug.cpp @@ -30,7 +30,8 @@ namespace aapt { -struct PrintVisitor : public ValueVisitor { +class PrintVisitor : public ValueVisitor { +public: using ValueVisitor::visit; void visit(Attribute* attr) override { @@ -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) { @@ -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 { @@ -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) { @@ -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; } @@ -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; } } -- cgit v1.2.3-59-g8ed1b