Skip to content

Commit

Permalink
Parse -maximumremovedandroidloglevel
Browse files Browse the repository at this point in the history
  • Loading branch information
piazzesiNiccolo-GS committed Mar 7, 2024
1 parent 858bcd0 commit 20c99aa
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 2 deletions.
2 changes: 2 additions & 0 deletions base/src/main/java/proguard/ConfigurationConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ public class ConfigurationConstants

public static final String ALWAYS_INLINE = "-alwaysinline";
public static final String IDENTIFIER_NAME_STRING = "-identifiernamestring";
public static final String MAXIMUM_REMOVED_ANDROID_LOG_LEVEL = "-maximumremovedandroidloglevel";


public static final String ANY_FILE_KEYWORD = "**";

Expand Down
18 changes: 16 additions & 2 deletions base/src/main/java/proguard/ConfigurationParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ else if (ConfigurationConstants.REPACKAGE_CLASSES_OPTION
else if (ConfigurationConstants.OPTIMIZE_AGGRESSIVELY .startsWith(nextWord)) configuration.optimizeConservatively = parseNoArgument(false);
else if (ConfigurationConstants.ALWAYS_INLINE .startsWith(nextWord)) parseUnsupportedR8Rules(ConfigurationConstants.ALWAYS_INLINE, true);
else if (ConfigurationConstants.IDENTIFIER_NAME_STRING .startsWith(nextWord)) parseUnsupportedR8Rules(ConfigurationConstants.IDENTIFIER_NAME_STRING, true);
else if (ConfigurationConstants.MAXIMUM_REMOVED_ANDROID_LOG_LEVEL .equals(nextWord)) parseMaximumRemovedAndroidLogLevel();
else
{
if (unknownOptionHandler != null) {
Expand Down Expand Up @@ -2087,9 +2088,22 @@ private void parseUnsupportedR8Rules(String option, boolean parseClassSpecificat
parseClassSpecificationArguments();
}

System.out.println("Warning: The R8 option " + option + " is currently not supported by ProGuard.\n" +
"This option will have no effect on the optimized artifact.");

warnUnsupportedR8Option(option);
}

private void parseMaximumRemovedAndroidLogLevel() throws IOException, ParseException {
parseIntegerArgument();
if (!configurationEnd(true)) {
parseClassSpecificationArguments();
}

warnUnsupportedR8Option(ConfigurationConstants.MAXIMUM_REMOVED_ANDROID_LOG_LEVEL);
}

private static void warnUnsupportedR8Option(String option) {
System.out.println("Warning: The R8 option " + option + " is currently not supported by ProGuard.\n" +
"This option will have no effect on the optimized artifact.");
}


Expand Down
49 changes: 49 additions & 0 deletions base/src/test/kotlin/proguard/ConfigurationParserTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,55 @@ class ConfigurationParserTest : FreeSpec({
}
}
}
"Testing -maximumremovedandroidloglevel parsing" - {
"Given an empty configuration" - {
val savedPrintStream = System.out
val customOutputStream = ByteArrayOutputStream()
System.setOut(PrintStream(customOutputStream))

parseConfiguration("")

"The option does not print anything" {
customOutputStream.toString() shouldContain ""
System.setOut(savedPrintStream)
}
}

"Given a configuration with -maximumremovedandroidloglevel without a class specification" - {
val savedPrintStream = System.out
val customOutputStream = ByteArrayOutputStream()
System.setOut(PrintStream(customOutputStream))

parseConfiguration("-maximumremovedandroidloglevel 1")

"The option prints out a warning" {
customOutputStream.toString() shouldContain "Warning: The R8 option -maximumremovedandroidloglevel is currently not supported by ProGuard.\n" +
"This option will have no effect on the optimized artifact."
System.setOut(savedPrintStream)
}
}

"Given a configuration with -maximumremovedandroidloglevel with a class specification" - {
val savedPrintStream = System.out
val customOutputStream = ByteArrayOutputStream()
System.setOut(PrintStream(customOutputStream))

parseConfiguration(
"""
-maximumremovedandroidloglevel 1 @org.chromium.build.annotations.DoNotStripLogs class ** {
<methods>;
}
""".trimIndent(),
)

"The option prints out a warning" {
customOutputStream.toString() shouldContain "Warning: The R8 option -maximumremovedandroidloglevel is currently not supported by ProGuard.\n" +
"This option will have no effect on the optimized artifact."
System.setOut(savedPrintStream)
}
}
}


"Wildcard type tests" - {
class TestConfig(
Expand Down
1 change: 1 addition & 0 deletions docs/md/manual/releasenotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Bugfixes

- Prevent unwanted name collision leading to missing methods in Kotlin DefaultImpls classes.
- Prevent `ParseException` when consumer rules contain `-maximumremovedandroidloglevel` rules.

## Version 7.4.2

Expand Down

0 comments on commit 20c99aa

Please sign in to comment.