From dc21dea9b8b1157a4a9347b68301da4307c51168 Mon Sep 17 00:00:00 2001 From: Adam Koski Date: Fri, 21 Jul 2017 10:55:27 -0700 Subject: AAPT2: Produce Conditional Proguard Keep Rules Add the option to produce keep rules that conditional keep based on usage of R identifiers. This allows Proguard to potentially shrink more code if resources are not used. Currently only produces conditional rules for classes referenced in layout resources because they are the most common and has the easiest transitive usage chain to analyze. Bug: 63628451 Test: make aapt2_tests and manual testing Change-Id: I6c1af7affd64af40c80e004d8506a9463444b2c3 --- tools/aapt2/java/JavaClassGenerator.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tools/aapt2/java/JavaClassGenerator.cpp') diff --git a/tools/aapt2/java/JavaClassGenerator.cpp b/tools/aapt2/java/JavaClassGenerator.cpp index 8da9106aa8d7..3ba4dd880607 100644 --- a/tools/aapt2/java/JavaClassGenerator.cpp +++ b/tools/aapt2/java/JavaClassGenerator.cpp @@ -61,7 +61,7 @@ static bool IsValidSymbol(const StringPiece& symbol) { // Java symbols can not contain . or -, but those are valid in a resource name. // Replace those with '_'. -static std::string TransformToFieldName(const StringPiece& symbol) { +std::string JavaClassGenerator::TransformToFieldName(const StringPiece& symbol) { std::string output = symbol.to_string(); for (char& c : output) { if (c == '.' || c == '-') { @@ -89,9 +89,9 @@ static std::string TransformNestedAttr(const ResourceNameRef& attr_name, // the package. if (!attr_name.package.empty() && package_name_to_generate != attr_name.package) { - output += "_" + TransformToFieldName(attr_name.package); + output += "_" + JavaClassGenerator::TransformToFieldName(attr_name.package); } - output += "_" + TransformToFieldName(attr_name.entry); + output += "_" + JavaClassGenerator::TransformToFieldName(attr_name.entry); return output; } -- cgit v1.2.3