Add +excldeps to R8 exclude-deps library build marker.

Change-Id: I90346800aab6c9687459e8026496e5bf71f454f1
diff --git a/build.gradle b/build.gradle
index 56804d1..cbe0747 100644
--- a/build.gradle
+++ b/build.gradle
@@ -967,7 +967,7 @@
     return baseD8CommandLine(allArgs)
 }
 
-def r8LibCreateTask(name, pgConfs = [], r8Task, output, libs = [], classpath = []) {
+def r8LibCreateTask(name, pgConfs = [], r8Task, output, libs = [], classpath = [], excldeps=false) {
     return tasks.create("r8Lib${name}", Exec) {
         inputs.files ([pgConfs, r8WithRelocatedDeps.outputs, r8Task.outputs])
         outputs.file output
@@ -978,6 +978,7 @@
                 "python3", "tools/create_r8lib.py",
                 "--r8jar", r8Task.outputs.files[0],
                 "--output", output]
+                + (excldeps ? ['--excldeps-variant'] : [])
                 + (pgConfs.collectMany { ["--pg-conf", it] })
                 + (libs.collectMany { ["--lib", it] })
                 + (classpath.collectMany { ["--classpath", it] }))
@@ -1070,7 +1071,8 @@
             r8NoManifestWithoutDeps,
             r8LibExludeDepsPath,
             [],
-            repackageDeps.outputs.files
+            repackageDeps.outputs.files,
+            true,
     ).dependsOn(repackageDeps)
     inputs.files ([r8NoManifestWithoutDeps.outputs, repackageDeps.outputs])
     outputs.file r8LibExludeDepsPath
@@ -1107,7 +1109,8 @@
             R8LibNoDeps,
             r8RetraceExludeDepsPath,
             [],
-            repackageDeps.outputs.files
+            repackageDeps.outputs.files,
+            true,
     ).dependsOn(R8LibNoDeps)
     outputs.file r8RetraceExludeDepsPath
 }
diff --git a/tools/create_r8lib.py b/tools/create_r8lib.py
index c8fcac3..6f77ba6 100755
--- a/tools/create_r8lib.py
+++ b/tools/create_r8lib.py
@@ -42,6 +42,11 @@
       '--classpath',
       action='append',
       help='Dependencies to add to classpath')
+  parser.add_argument(
+      '--excldeps-variant',
+      action='store_true',
+      default=False,
+      help='Mark this artifact as an "excldeps" variant of the compiler')
   return parser.parse_args()
 
 def get_r8_version(r8jar):
@@ -72,7 +77,8 @@
     print("Could not find jar: " + args.r8jar)
     return 1
   version = get_r8_version(args.r8jar)
-  map_id_template = version
+  variant = '+excldeps' if args.excldeps_variant else ''
+  map_id_template = version + variant
   source_file_template = 'R8_%MAP_ID_%MAP_HASH'
   # TODO(b/139725780): See if we can remove or lower the heap size (-Xmx8g).
   cmd = [jdk.GetJavaExecutable(), '-Xmx8g', '-ea']
diff --git a/tools/retrace.py b/tools/retrace.py
index a883d90..a2df6ef 100755
--- a/tools/retrace.py
+++ b/tools/retrace.py
@@ -110,6 +110,13 @@
 
   if r8_source_file:
     (header, r8_version_or_hash, maphash) = r8_source_file.split('_')
+    # If the command-line specified --exclude-deps then assume it is as previous
+    # versions will not be marked as such in the source-file line.
+    is_excldeps = args.exclude_deps
+    excldeps_start = r8_version_or_hash.find('+excldeps')
+    if (excldeps_start > 0):
+      is_excldeps = True
+      r8_version_or_hash = r8_version_or_hash[0:excldeps_start]
     if len(r8_version_or_hash) < 40:
       args.version = r8_version_or_hash
     else:
@@ -117,7 +124,7 @@
     map_path = None
     try:
       map_path = utils.find_cloud_storage_file_from_options(
-        'r8lib' + ('-exclude-deps' if args.exclude_deps else '' ) + '.jar.map', args)
+        'r8lib' + ('-exclude-deps' if is_excldeps else '') + '.jar.map', args)
     except Exception as e:
       print(e)
       print('WARNING: Falling back to using local mapping file.')