Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f89bd67 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Change conditional keep rule syntax"

parents 1c4ab704 09ef94e9
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -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 << "  };\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_) {
+3 −3
Original line number Diff line number Diff line
@@ -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) {