Reland "Revert removing retrace from utils"
This reverts commit cec4be2e2f9991ba1f8747ef504a7572b0ef2420.
Change-Id: Ic44a24388e63d8819c61c749f199ac3a7505d360
diff --git a/build.gradle b/build.gradle
index 8b08d17..d3005a8 100644
--- a/build.gradle
+++ b/build.gradle
@@ -301,6 +301,9 @@
def r8DesugaredPath = "$buildDir/libs/r8desugared.jar"
def r8LibGeneratedKeepRulesPath = "$buildDir/generated/keep.txt"
def r8LibTestPath = "$buildDir/classes/r8libtest"
+def java11ClassFiles = "$buildDir/classes/java/mainJava11"
+def r8RetracePath = "$buildDir/libs/r8retrace.jar"
+def r8RetraceExludeDepsPath = "$buildDir/libs/r8retrace-exclude-deps.jar"
def osString = OperatingSystem.current().isLinux() ? "linux" :
OperatingSystem.current().isMacOsX() ? "mac" : "windows"
@@ -1117,6 +1120,29 @@
outputs.file r8DesugaredPath
}
+task R8Retrace {
+ dependsOn R8Lib
+ dependsOn r8LibCreateTask(
+ "Retrace",
+ ["src/main/keep_retrace.txt"],
+ R8Lib,
+ r8RetracePath,
+ ).dependsOn(R8Lib)
+ outputs.file r8RetracePath
+}
+
+task R8RetraceNoDeps {
+ dependsOn R8LibNoDeps
+ dependsOn r8LibCreateTask(
+ "RetraceNoDeps",
+ ["src/main/keep_retrace.txt"],
+ R8LibNoDeps,
+ r8RetraceExludeDepsPath,
+ repackageDeps.outputs.files
+ ).dependsOn(R8LibNoDeps)
+ outputs.file r8RetraceExludeDepsPath
+}
+
task sourceJar(type: Jar, dependsOn: classes) {
classifier = 'src'
from sourceSets.main.allSource
diff --git a/src/main/keep_retrace.txt b/src/main/keep_retrace.txt
new file mode 100644
index 0000000..e8d050a
--- /dev/null
+++ b/src/main/keep_retrace.txt
@@ -0,0 +1,19 @@
+# Copyright (c) 2021, the R8 project authors. Please see the AUTHORS file
+# for details. All rights reserved. Use of this source code is governed by a
+# BSD-style license that can be found in the LICENSE file.
+
+# The retrace api is separated out without repackaging which is why this broad
+# rule is used.
+-keep public class com.android.tools.r8.retrace.* {
+ public <methods>;
+ public <fields>;
+ }
+-keepattributes SourceFile, LineNumberTable, InnerClasses, EnclosingMethod, Exceptions, Signature
+-keepparameternames
+
+# This is run on r8lib so keep everything in lib that is traced. That way
+# we only need a single mapping file
+-keep,allowshrinking class * { *; }
+
+# Keep all things that can be reached from the retrace api
+-keep @com.android.tools.r8.KeepForRetraceApi class * { public *; }
diff --git a/src/test/java/com/android/tools/r8/ToolHelper.java b/src/test/java/com/android/tools/r8/ToolHelper.java
index 8f3b1e4..e4b6462 100644
--- a/src/test/java/com/android/tools/r8/ToolHelper.java
+++ b/src/test/java/com/android/tools/r8/ToolHelper.java
@@ -177,6 +177,7 @@
public static final Path R8LIB_EXCLUDE_DEPS_MAP =
Paths.get(LIBS_DIR, "r8lib-exclude-deps.jar.map");
public static final Path DEPS = Paths.get(LIBS_DIR, "deps_all.jar");
+ public static final Path R8_RETRACE_JAR = Paths.get(LIBS_DIR, "r8retrace.jar");
public static final Path DESUGAR_LIB_CONVERSIONS =
Paths.get(LIBS_DIR, "library_desugar_conversions.zip");
diff --git a/src/test/java/com/android/tools/r8/retrace/RetraceCommandLineTests.java b/src/test/java/com/android/tools/r8/retrace/RetraceCommandLineTests.java
index 3fb600a..d348b54 100644
--- a/src/test/java/com/android/tools/r8/retrace/RetraceCommandLineTests.java
+++ b/src/test/java/com/android/tools/r8/retrace/RetraceCommandLineTests.java
@@ -303,7 +303,7 @@
command.add(ToolHelper.getSystemJavaExecutable());
command.add("-ea");
command.add("-cp");
- command.add(ToolHelper.R8LIB_JAR.toString());
+ command.add(ToolHelper.R8_RETRACE_JAR.toString());
command.add("com.android.tools.r8.retrace.Retrace");
command.addAll(args);
ProcessBuilder builder = new ProcessBuilder(command);
diff --git a/src/test/java/com/android/tools/r8/retrace/RetraceTests.java b/src/test/java/com/android/tools/r8/retrace/RetraceTests.java
index 17ea86d..16aa702 100644
--- a/src/test/java/com/android/tools/r8/retrace/RetraceTests.java
+++ b/src/test/java/com/android/tools/r8/retrace/RetraceTests.java
@@ -408,7 +408,7 @@
command.add(testParameters.getRuntime().asCf().getJavaExecutable().toString());
command.add("-ea");
command.add("-cp");
- command.add(ToolHelper.R8LIB_JAR.toString());
+ command.add(ToolHelper.R8_RETRACE_JAR.toString());
if (allowExperimentalMapping) {
command.add("-Dcom.android.tools.r8.experimentalmapping");
}
diff --git a/src/test/java/com/android/tools/r8/retrace/api/RetraceApiTestCollection.java b/src/test/java/com/android/tools/r8/retrace/api/RetraceApiTestCollection.java
index 4deb785..fb48ff4 100644
--- a/src/test/java/com/android/tools/r8/retrace/api/RetraceApiTestCollection.java
+++ b/src/test/java/com/android/tools/r8/retrace/api/RetraceApiTestCollection.java
@@ -56,7 +56,7 @@
@Override
public Path getTargetJar() {
- return ToolHelper.isTestingR8Lib() ? ToolHelper.R8LIB_JAR : ToolHelper.R8_JAR;
+ return ToolHelper.isTestingR8Lib() ? ToolHelper.R8_RETRACE_JAR : ToolHelper.R8_JAR;
}
@Override
diff --git a/tools/archive.py b/tools/archive.py
index 5207e5c..24e8e0a 100755
--- a/tools/archive.py
+++ b/tools/archive.py
@@ -145,6 +145,8 @@
utils.D8,
utils.R8LIB,
utils.R8LIB_NO_DEPS,
+ utils.R8RETRACE,
+ utils.R8RETRACE_NO_DEPS,
utils.LIBRARY_DESUGAR_CONVERSIONS,
'-Pno_internal'
])
@@ -191,6 +193,8 @@
utils.R8_FULL_EXCLUDE_DEPS_JAR,
utils.R8LIB_EXCLUDE_DEPS_JAR,
utils.R8LIB_EXCLUDE_DEPS_JAR + '.map',
+ utils.R8RETRACE_JAR,
+ utils.R8RETRACE_EXCLUDE_DEPS_JAR,
utils.MAVEN_ZIP,
utils.MAVEN_ZIP_LIB,
utils.DESUGAR_CONFIGURATION,
diff --git a/tools/r8_release.py b/tools/r8_release.py
index a0ed999..f9d14f9 100755
--- a/tools/r8_release.py
+++ b/tools/r8_release.py
@@ -363,6 +363,7 @@
g4_open('src.jar')
g4_open('lib.jar')
g4_open('lib.jar.map')
+ g4_open('retrace_lib.jar')
g4_open('desugar_jdk_libs_configuration.jar')
download_file(options.version, 'r8-full-exclude-deps.jar', 'full.jar')
download_file(options.version, 'r8-src.jar', 'src.jar')
@@ -371,6 +372,7 @@
options.version, 'r8lib-exclude-deps.jar.map', 'lib.jar.map')
download_file(options.version, 'desugar_jdk_libs_configuration.jar',
'desugar_jdk_libs_configuration.jar')
+ download_file(options.version, 'r8retrace-exclude-deps.jar', 'retrace_lib.jar')
g4_open('METADATA')
sed(r'[1-9]\.[0-9]{1,2}\.[0-9]{1,3}-dev',
options.version,
diff --git a/tools/test.py b/tools/test.py
index 5da5b71..4a5d79c 100755
--- a/tools/test.py
+++ b/tools/test.py
@@ -321,6 +321,7 @@
# Force gradle to build a version of r8lib without dependencies for
# BootstrapCurrentEqualityTest.
gradle_args.append('R8LibNoDeps')
+ gradle_args.append('R8Retrace')
if options.r8lib_no_deps:
gradle_args.append('-Pr8lib_no_deps')
if options.worktree:
diff --git a/tools/utils.py b/tools/utils.py
index 40c5c7a..5d574ac 100644
--- a/tools/utils.py
+++ b/tools/utils.py
@@ -41,6 +41,8 @@
R8 = 'r8'
R8LIB = 'r8lib'
R8LIB_NO_DEPS = 'r8LibNoDeps'
+R8RETRACE = 'R8Retrace'
+R8RETRACE_NO_DEPS = 'R8RetraceNoDeps'
R8_SRC = 'sourceJar'
LIBRARY_DESUGAR_CONVERSIONS = 'buildLibraryDesugarConversions'
@@ -52,6 +54,8 @@
R8_SRC_JAR = os.path.join(LIBS, 'r8-src.jar')
R8LIB_EXCLUDE_DEPS_JAR = os.path.join(LIBS, 'r8lib-exclude-deps.jar')
R8_FULL_EXCLUDE_DEPS_JAR = os.path.join(LIBS, 'r8-full-exclude-deps.jar')
+R8RETRACE_JAR = os.path.join(LIBS, 'r8retrace.jar')
+R8RETRACE_EXCLUDE_DEPS_JAR = os.path.join(LIBS, 'r8retrace-exclude-deps.jar')
MAVEN_ZIP = os.path.join(LIBS, 'r8.zip')
MAVEN_ZIP_LIB = os.path.join(LIBS, 'r8lib.zip')
LIBRARY_DESUGAR_CONVERSIONS_ZIP = os.path.join(LIBS, 'library_desugar_conversions.zip')