summaryrefslogtreecommitdiff
path: root/tools/aapt2/Debug.cpp
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2016-02-13 20:26:45 -0800
committerAdam Lesinski <adamlesinski@google.com>2016-02-17 18:17:25 -0800
commit355f285ffd000f6cfe76680eb22d010546d124bb (patch)
tree94d86559ba73ed2f482af1f296ef56374776a8f6 /tools/aapt2/Debug.cpp
parente4735a99598bf29847a9f12dd7fae6d7df880bc4 (diff)
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
Diffstat (limited to 'tools/aapt2/Debug.cpp')
-rw-r--r--tools/aapt2/Debug.cpp35
1 files changed, 29 insertions, 6 deletions
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;
}
}