Merge "Fix pg compilation and relax r8 assertion when running run_on_as_app"
diff --git a/tools/as_utils.py b/tools/as_utils.py
index 7a6528a..817f7ed 100644
--- a/tools/as_utils.py
+++ b/tools/as_utils.py
@@ -8,8 +8,6 @@
 import os
 import shutil
 
-import utils
-
 def add_r8_dependency(checkout_dir, temp_dir, minified):
   build_file = os.path.join(checkout_dir, 'build.gradle')
   assert os.path.isfile(build_file), (
@@ -112,7 +110,7 @@
     assert 'transformDexArchiveWithDexMergerFor' not in x
     return 'transformClassesAndResourcesWithR8For' in x
 
-  assert shrinker == 'proguard'
+  assert shrinker == 'pg'
   return ('transformClassesAndResourcesWithProguard' in x
       or 'transformClassesWithDexBuilderFor' in x
       or 'transformDexArchiveWithDexMergerFor' in x)
diff --git a/tools/run_on_as_app.py b/tools/run_on_as_app.py
index 3b21ba9..53ddbe7 100755
--- a/tools/run_on_as_app.py
+++ b/tools/run_on_as_app.py
@@ -728,13 +728,14 @@
     if not options.no_build or options.golem:
       gradle.RunGradle(['r8', 'r8lib'])
 
-    assert os.path.isfile(utils.R8_JAR), 'Cannot build without r8.jar'
-    assert os.path.isfile(utils.R8LIB_JAR), 'Cannot build without r8lib.jar'
-
     # Make a copy of r8.jar and r8lib.jar such that they stay the same for
     # the entire execution of this script.
-    shutil.copyfile(utils.R8_JAR, os.path.join(temp_dir, 'r8.jar'))
-    shutil.copyfile(utils.R8LIB_JAR, os.path.join(temp_dir, 'r8lib.jar'))
+    if 'r8-nolib' in options.shrinker:
+      assert os.path.isfile(utils.R8_JAR), 'Cannot build without r8.jar'
+      shutil.copyfile(utils.R8_JAR, os.path.join(temp_dir, 'r8.jar'))
+    if 'r8' in options.shrinker:
+      assert os.path.isfile(utils.R8LIB_JAR), 'Cannot build without r8lib.jar'
+      shutil.copyfile(utils.R8LIB_JAR, os.path.join(temp_dir, 'r8lib.jar'))
 
     result_per_shrinker_per_app = {}