Loading tools/aapt2/cmd/Link.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -1297,7 +1297,8 @@ class Linker { return false; } proguard::WriteKeepSet(keep_set, &fout, options_.generate_minimal_proguard_rules); proguard::WriteKeepSet(keep_set, &fout, options_.generate_minimal_proguard_rules, options_.no_proguard_location_reference); fout.Flush(); if (fout.HadError()) { Loading tools/aapt2/cmd/Link.h +4 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ struct LinkOptions { bool generate_conditional_proguard_rules = false; bool generate_minimal_proguard_rules = false; bool generate_non_final_ids = false; bool no_proguard_location_reference = false; std::vector<std::string> javadoc_annotations; Maybe<std::string> private_symbols; Loading Loading @@ -215,6 +216,9 @@ class LinkCommand : public Command { "Generates R.java without the final modifier. This is implied when\n" "--static-lib is specified.", &options_.generate_non_final_ids); AddOptionalSwitch("--no-proguard-location-reference", "Keep proguard rules files from having a reference to the source file", &options_.no_proguard_location_reference); AddOptionalFlag("--stable-ids", "File containing a list of name to ID mapping.", &stable_id_file_path_); AddOptionalFlag("--emit-ids", Loading tools/aapt2/java/ProguardRules.cpp +18 −8 Original line number Diff line number Diff line Loading @@ -393,12 +393,16 @@ bool CollectProguardRules(IAaptContext* context_, xml::XmlResource* res, KeepSet return true; } void WriteKeepSet(const KeepSet& keep_set, OutputStream* out, bool minimal_keep) { void WriteKeepSet(const KeepSet& keep_set, OutputStream* out, bool minimal_keep, bool no_location_reference) { Printer printer(out); for (const auto& entry : keep_set.manifest_class_set_) { if (!no_location_reference) { for (const UsageLocation& location : entry.second) { printer.Print("# Referenced at ").Println(location.source.to_string()); } } printer.Print("-keep class ").Print(entry.first).Println(" { <init>(); }"); } Loading @@ -414,7 +418,9 @@ void WriteKeepSet(const KeepSet& keep_set, OutputStream* out, bool minimal_keep) if (can_be_conditional) { for (const UsageLocation& location : locations) { if (!no_location_reference) { printer.Print("# Referenced at ").Println(location.source.to_string()); } printer.Print("-if class **.R$layout { int ") .Print(JavaClassGenerator::TransformToFieldName(location.name.entry)) .Println("; }"); Loading @@ -424,9 +430,11 @@ void WriteKeepSet(const KeepSet& keep_set, OutputStream* out, bool minimal_keep) printer.Println("); }"); } } else { if (!no_location_reference) { for (const UsageLocation& location : entry.second) { printer.Print("# Referenced at ").Println(location.source.to_string()); } } printer.Print("-keep class ").Print(entry.first.name).Print(" { <init>("); printer.Print((minimal_keep) ? entry.first.signature : "..."); Loading @@ -436,9 +444,11 @@ void WriteKeepSet(const KeepSet& keep_set, OutputStream* out, bool minimal_keep) } for (const auto& entry : keep_set.method_set_) { if (!no_location_reference) { for (const UsageLocation& location : entry.second) { printer.Print("# Referenced at ").Println(location.source.to_string()); } } printer.Print("-keepclassmembers class * { *** ").Print(entry.first.name) .Print("(").Print(entry.first.signature).Println("); }"); printer.Println(); Loading tools/aapt2/java/ProguardRules.h +4 −2 Original line number Diff line number Diff line Loading @@ -70,7 +70,8 @@ class KeepSet { } private: friend void WriteKeepSet(const KeepSet& keep_set, io::OutputStream* out, bool minimal_keep); friend void WriteKeepSet(const KeepSet& keep_set, io::OutputStream* out, bool minimal_keep, bool no_location_reference); friend bool CollectLocations(const UsageLocation& location, const KeepSet& keep_set, std::set<UsageLocation>* locations); Loading @@ -89,7 +90,8 @@ bool CollectProguardRules(IAaptContext* context, xml::XmlResource* res, KeepSet* bool CollectResourceReferences(IAaptContext* context, ResourceTable* table, KeepSet* keep_set); void WriteKeepSet(const KeepSet& keep_set, io::OutputStream* out, bool minimal_keep); void WriteKeepSet(const KeepSet& keep_set, io::OutputStream* out, bool minimal_keep, bool no_location_reference); bool CollectLocations(const UsageLocation& location, const KeepSet& keep_set, std::set<UsageLocation>* locations); Loading tools/aapt2/java/ProguardRules_test.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ namespace aapt { std::string GetKeepSetString(const proguard::KeepSet& set, bool minimal_rules) { std::string out; StringOutputStream sout(&out); proguard::WriteKeepSet(set, &sout, minimal_rules); proguard::WriteKeepSet(set, &sout, minimal_rules, false); sout.Flush(); return out; } Loading Loading
tools/aapt2/cmd/Link.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -1297,7 +1297,8 @@ class Linker { return false; } proguard::WriteKeepSet(keep_set, &fout, options_.generate_minimal_proguard_rules); proguard::WriteKeepSet(keep_set, &fout, options_.generate_minimal_proguard_rules, options_.no_proguard_location_reference); fout.Flush(); if (fout.HadError()) { Loading
tools/aapt2/cmd/Link.h +4 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ struct LinkOptions { bool generate_conditional_proguard_rules = false; bool generate_minimal_proguard_rules = false; bool generate_non_final_ids = false; bool no_proguard_location_reference = false; std::vector<std::string> javadoc_annotations; Maybe<std::string> private_symbols; Loading Loading @@ -215,6 +216,9 @@ class LinkCommand : public Command { "Generates R.java without the final modifier. This is implied when\n" "--static-lib is specified.", &options_.generate_non_final_ids); AddOptionalSwitch("--no-proguard-location-reference", "Keep proguard rules files from having a reference to the source file", &options_.no_proguard_location_reference); AddOptionalFlag("--stable-ids", "File containing a list of name to ID mapping.", &stable_id_file_path_); AddOptionalFlag("--emit-ids", Loading
tools/aapt2/java/ProguardRules.cpp +18 −8 Original line number Diff line number Diff line Loading @@ -393,12 +393,16 @@ bool CollectProguardRules(IAaptContext* context_, xml::XmlResource* res, KeepSet return true; } void WriteKeepSet(const KeepSet& keep_set, OutputStream* out, bool minimal_keep) { void WriteKeepSet(const KeepSet& keep_set, OutputStream* out, bool minimal_keep, bool no_location_reference) { Printer printer(out); for (const auto& entry : keep_set.manifest_class_set_) { if (!no_location_reference) { for (const UsageLocation& location : entry.second) { printer.Print("# Referenced at ").Println(location.source.to_string()); } } printer.Print("-keep class ").Print(entry.first).Println(" { <init>(); }"); } Loading @@ -414,7 +418,9 @@ void WriteKeepSet(const KeepSet& keep_set, OutputStream* out, bool minimal_keep) if (can_be_conditional) { for (const UsageLocation& location : locations) { if (!no_location_reference) { printer.Print("# Referenced at ").Println(location.source.to_string()); } printer.Print("-if class **.R$layout { int ") .Print(JavaClassGenerator::TransformToFieldName(location.name.entry)) .Println("; }"); Loading @@ -424,9 +430,11 @@ void WriteKeepSet(const KeepSet& keep_set, OutputStream* out, bool minimal_keep) printer.Println("); }"); } } else { if (!no_location_reference) { for (const UsageLocation& location : entry.second) { printer.Print("# Referenced at ").Println(location.source.to_string()); } } printer.Print("-keep class ").Print(entry.first.name).Print(" { <init>("); printer.Print((minimal_keep) ? entry.first.signature : "..."); Loading @@ -436,9 +444,11 @@ void WriteKeepSet(const KeepSet& keep_set, OutputStream* out, bool minimal_keep) } for (const auto& entry : keep_set.method_set_) { if (!no_location_reference) { for (const UsageLocation& location : entry.second) { printer.Print("# Referenced at ").Println(location.source.to_string()); } } printer.Print("-keepclassmembers class * { *** ").Print(entry.first.name) .Print("(").Print(entry.first.signature).Println("); }"); printer.Println(); Loading
tools/aapt2/java/ProguardRules.h +4 −2 Original line number Diff line number Diff line Loading @@ -70,7 +70,8 @@ class KeepSet { } private: friend void WriteKeepSet(const KeepSet& keep_set, io::OutputStream* out, bool minimal_keep); friend void WriteKeepSet(const KeepSet& keep_set, io::OutputStream* out, bool minimal_keep, bool no_location_reference); friend bool CollectLocations(const UsageLocation& location, const KeepSet& keep_set, std::set<UsageLocation>* locations); Loading @@ -89,7 +90,8 @@ bool CollectProguardRules(IAaptContext* context, xml::XmlResource* res, KeepSet* bool CollectResourceReferences(IAaptContext* context, ResourceTable* table, KeepSet* keep_set); void WriteKeepSet(const KeepSet& keep_set, io::OutputStream* out, bool minimal_keep); void WriteKeepSet(const KeepSet& keep_set, io::OutputStream* out, bool minimal_keep, bool no_location_reference); bool CollectLocations(const UsageLocation& location, const KeepSet& keep_set, std::set<UsageLocation>* locations); Loading
tools/aapt2/java/ProguardRules_test.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ namespace aapt { std::string GetKeepSetString(const proguard::KeepSet& set, bool minimal_rules) { std::string out; StringOutputStream sout(&out); proguard::WriteKeepSet(set, &sout, minimal_rules); proguard::WriteKeepSet(set, &sout, minimal_rules, false); sout.Flush(); return out; } Loading