summaryrefslogtreecommitdiff
path: root/tools/aapt2/cmd/Compile.cpp
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2018-08-13 18:07:38 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-08-13 18:07:38 +0000
commitf2c5ee5900ed5710bb0aaad31401937837fbe6fb (patch)
tree0dd814beb6fa134d9b9e97cfde606225d642f7f1 /tools/aapt2/cmd/Compile.cpp
parent031bfca15733a538b9e018c05b1b91dc5afda69e (diff)
parentf67d486e58f93a1d45795cee04633fce5e5e2bc7 (diff)
Merge "AAPT2: partial files contain only local resources"
Diffstat (limited to 'tools/aapt2/cmd/Compile.cpp')
-rw-r--r--tools/aapt2/cmd/Compile.cpp74
1 files changed, 39 insertions, 35 deletions
diff --git a/tools/aapt2/cmd/Compile.cpp b/tools/aapt2/cmd/Compile.cpp
index 36b5578d1deb..2ba2cf7926b0 100644
--- a/tools/aapt2/cmd/Compile.cpp
+++ b/tools/aapt2/cmd/Compile.cpp
@@ -288,44 +288,48 @@ static bool CompileTable(IAaptContext* context, const CompileOptions& options,
Printer r_txt_printer(&fout_text);
for (const auto& package : table.packages) {
- for (const auto& type : package->types) {
- for (const auto& entry : type->entries) {
- // Check access modifiers.
- switch(entry->visibility.level) {
- case Visibility::Level::kUndefined :
- r_txt_printer.Print("default ");
- break;
- case Visibility::Level::kPublic :
- r_txt_printer.Print("public ");
- break;
- case Visibility::Level::kPrivate :
- r_txt_printer.Print("private ");
- }
+ // Only print resources defined locally, e.g. don't write android attributes.
+ if (package->name.empty()) {
+ for (const auto& type : package->types) {
+ for (const auto& entry : type->entries) {
+ // Check access modifiers.
+ switch (entry->visibility.level) {
+ case Visibility::Level::kUndefined :
+ r_txt_printer.Print("default ");
+ break;
+ case Visibility::Level::kPublic :
+ r_txt_printer.Print("public ");
+ break;
+ case Visibility::Level::kPrivate :
+ r_txt_printer.Print("private ");
+ }
- if (type->type != ResourceType::kStyleable) {
- r_txt_printer.Print("int ");
- r_txt_printer.Print(to_string(type->type));
- r_txt_printer.Print(" ");
- r_txt_printer.Println(entry->name);
- } else {
- r_txt_printer.Print("int[] styleable ");
- r_txt_printer.Println(entry->name);
-
- if (!entry->values.empty()) {
- auto styleable = static_cast<const Styleable*>(entry->values.front()->value.get());
- for (const auto& attr : styleable->entries) {
- // The visibility of the children under the styleable does not matter as they are
- // nested under their parent and use its visibility.
- r_txt_printer.Print("default int styleable ");
- r_txt_printer.Print(entry->name);
- // If the package name is present, also include it in the mangled name (e.g.
- // "android")
- if (!attr.name.value().package.empty()) {
+ if (type->type != ResourceType::kStyleable) {
+ r_txt_printer.Print("int ");
+ r_txt_printer.Print(to_string(type->type));
+ r_txt_printer.Print(" ");
+ r_txt_printer.Println(entry->name);
+ } else {
+ r_txt_printer.Print("int[] styleable ");
+ r_txt_printer.Println(entry->name);
+
+ if (!entry->values.empty()) {
+ auto styleable =
+ static_cast<const Styleable*>(entry->values.front()->value.get());
+ for (const auto& attr : styleable->entries) {
+ // The visibility of the children under the styleable does not matter as they are
+ // nested under their parent and use its visibility.
+ r_txt_printer.Print("default int styleable ");
+ r_txt_printer.Print(entry->name);
+ // If the package name is present, also include it in the mangled name (e.g.
+ // "android")
+ if (!attr.name.value().package.empty()) {
+ r_txt_printer.Print("_");
+ r_txt_printer.Print(MakePackageSafeName(attr.name.value().package));
+ }
r_txt_printer.Print("_");
- r_txt_printer.Print(MakePackageSafeName(attr.name.value().package));
+ r_txt_printer.Println(attr.name.value().entry);
}
- r_txt_printer.Print("_");
- r_txt_printer.Println(attr.name.value().entry);
}
}
}