Add --pg-map-output and proguardMapConsumer to L8 command
This will allow consumers to obtain the produced proguard map by L8.
Bug: 182266325
Change-Id: Iae7112ca69e7825942e5de6968d5dd7b0f4448e0
diff --git a/src/main/java/com/android/tools/r8/BaseCompilerCommand.java b/src/main/java/com/android/tools/r8/BaseCompilerCommand.java
index f0cb3e8..555713b 100644
--- a/src/main/java/com/android/tools/r8/BaseCompilerCommand.java
+++ b/src/main/java/com/android/tools/r8/BaseCompilerCommand.java
@@ -206,6 +206,7 @@
private BiPredicate<String, Long> dexClassChecksumFilter = (name, checksum) -> true;
private List<AssertionsConfiguration> assertionsConfiguration = new ArrayList<>();
private List<Consumer<Inspector>> outputInspections = new ArrayList<>();
+ protected StringConsumer proguardMapConsumer = null;
abstract CompilationMode defaultCompilationMode();
@@ -278,6 +279,33 @@
}
/**
+ * Set an output destination to which proguard-map content should be written.
+ *
+ * <p>This is a short-hand for setting a {@link StringConsumer.FileConsumer} using {@link
+ * #setProguardMapConsumer}. Note that any subsequent call to this method or {@link
+ * #setProguardMapConsumer} will override the previous setting.
+ *
+ * @param proguardMapOutput File-system path to write output at.
+ */
+ B setProguardMapOutputPath(Path proguardMapOutput) {
+ assert proguardMapOutput != null;
+ return setProguardMapConsumer(new StringConsumer.FileConsumer(proguardMapOutput));
+ }
+
+ /**
+ * Set a consumer for receiving the proguard-map content.
+ *
+ * <p>Note that any subsequent call to this method or {@link #setProguardMapOutputPath} will
+ * override the previous setting.
+ *
+ * @param proguardMapConsumer Consumer to receive the content once produced.
+ */
+ B setProguardMapConsumer(StringConsumer proguardMapConsumer) {
+ this.proguardMapConsumer = proguardMapConsumer;
+ return self();
+ }
+
+ /**
* Get the main dex list consumer that will receive the final complete main dex list.
*/
public StringConsumer getMainDexListConsumer() {