Change conditional keep rule syntax
Google's ProGuard fork is migrating to a new syntax that upstream ProGuard 6.0 will also support. Test: unit tests Bug: 69162105 Change-Id: I3b6d7e82eb99c2e2af6c4d851a4f97ec3e471b55
This commit is contained in:
@@ -345,15 +345,14 @@ bool WriteKeepSet(std::ostream* out, const KeepSet& keep_set) {
|
||||
*out << "# Referenced at " << location.source << "\n";
|
||||
}
|
||||
if (keep_set.conditional_keep_rules_ && can_be_conditional) {
|
||||
*out << "-keep class " << entry.first << " {\n ifused class **.R$layout {\n";
|
||||
*out << "-if class **.R$layout {\n";
|
||||
for (const UsageLocation& location : locations) {
|
||||
auto transformed_name = JavaClassGenerator::TransformToFieldName(location.name.entry);
|
||||
*out << " int " << transformed_name << ";\n";
|
||||
*out << " int " << transformed_name << ";\n";
|
||||
}
|
||||
*out << " };\n <init>(...);\n}\n" << std::endl;
|
||||
} else {
|
||||
*out << "-keep class " << entry.first << " { <init>(...); }\n" << std::endl;
|
||||
*out << "}\n";
|
||||
}
|
||||
*out << "-keep class " << entry.first << " { <init>(...); }\n" << std::endl;
|
||||
}
|
||||
|
||||
for (const auto& entry : keep_set.method_set_) {
|
||||
|
||||
@@ -130,7 +130,7 @@ TEST(ProguardRulesTest, IncludedLayoutRulesAreConditional) {
|
||||
ASSERT_TRUE(proguard::WriteKeepSet(&out, set));
|
||||
|
||||
std::string actual = out.str();
|
||||
EXPECT_THAT(actual, HasSubstr("ifused class **.R$layout"));
|
||||
EXPECT_THAT(actual, HasSubstr("-if class **.R$layout"));
|
||||
EXPECT_THAT(actual, HasSubstr("int foo"));
|
||||
EXPECT_THAT(actual, HasSubstr("int bar"));
|
||||
EXPECT_THAT(actual, HasSubstr("com.foo.Bar"));
|
||||
@@ -152,7 +152,7 @@ TEST(ProguardRulesTest, AliasedLayoutRulesAreConditional) {
|
||||
ASSERT_TRUE(proguard::WriteKeepSet(&out, set));
|
||||
|
||||
std::string actual = out.str();
|
||||
EXPECT_THAT(actual, HasSubstr("ifused class **.R$layout"));
|
||||
EXPECT_THAT(actual, HasSubstr("-if class **.R$layout"));
|
||||
EXPECT_THAT(actual, HasSubstr("int foo"));
|
||||
EXPECT_THAT(actual, HasSubstr("int bar"));
|
||||
EXPECT_THAT(actual, HasSubstr("com.foo.Bar"));
|
||||
@@ -174,7 +174,7 @@ TEST(ProguardRulesTest, NonLayoutReferencesAreUnconditional) {
|
||||
ASSERT_TRUE(proguard::WriteKeepSet(&out, set));
|
||||
|
||||
std::string actual = out.str();
|
||||
EXPECT_THAT(actual, Not(HasSubstr("ifused")));
|
||||
EXPECT_THAT(actual, Not(HasSubstr("-if")));
|
||||
}
|
||||
|
||||
TEST(ProguardRulesTest, ViewOnClickRuleIsEmitted) {
|
||||
|
||||
Reference in New Issue
Block a user