Add compare_apk_sizes support for ignoring debug info

Small changes in the dex can, with the buckets, have a big effect on the debug info.
This allows us to compare the sizes of apks ignoring the debug info

Change-Id: If21314a69ff310fb358c8444ac67293e25c3a7f5
diff --git a/src/main/java/com/android/tools/r8/dex/DexParser.java b/src/main/java/com/android/tools/r8/dex/DexParser.java
index cb80f3d..5ddb8c1 100644
--- a/src/main/java/com/android/tools/r8/dex/DexParser.java
+++ b/src/main/java/com/android/tools/r8/dex/DexParser.java
@@ -1027,6 +1027,9 @@
     int saved = dexReader.position();
     DexDebugInfo debugInfo = debugInfoAt(debugInfoOff, instructions);
     dexReader.position(saved);
+    if (options.testing.nullOutDebugInfo) {
+      debugInfo = null;
+    }
 
     return new DexCode(registerSize, insSize, outsSize, instructions, tries, handlers, debugInfo);
   }
diff --git a/src/main/java/com/android/tools/r8/utils/InternalOptions.java b/src/main/java/com/android/tools/r8/utils/InternalOptions.java
index be887b7..27b7af9 100644
--- a/src/main/java/com/android/tools/r8/utils/InternalOptions.java
+++ b/src/main/java/com/android/tools/r8/utils/InternalOptions.java
@@ -2216,6 +2216,8 @@
         System.getProperty("com.android.tools.r8.dexVersion40ForApiLevel30") != null;
     public boolean dexContainerExperiment =
         System.getProperty("com.android.tools.r8.dexContainerExperiment") != null;
+    public boolean nullOutDebugInfo =
+        System.getProperty("com.android.tools.r8.nullOutDebugInfo") != null;
 
     // Testing options to analyse locality of items in DEX files when they are generated.
     public boolean calculateItemUseCountInDex = false;
diff --git a/tools/compare_apk_sizes.py b/tools/compare_apk_sizes.py
index 5ed768b..57448f6 100755
--- a/tools/compare_apk_sizes.py
+++ b/tools/compare_apk_sizes.py
@@ -39,6 +39,11 @@
         default=False,
         action='store_true')
     result.add_option(
+        '--ignore_debug_info',
+        help='Do not include debug info in the comparison.',
+        default=False,
+        action='store_true')
+    result.add_option(
         '--report', help='Print comparison to this location instead of stdout')
     return result.parse_args()
 
@@ -66,7 +71,10 @@
     if options.no_build:
         args.extend(['--no-build'])
     args.extend(input)
-    if toolhelper.run('d8', args) is not 0:
+    extra_args = []
+    if options.ignore_debug_info:
+        extra_args.append('-Dcom.android.tools.r8.nullOutDebugInfo=1')
+    if toolhelper.run('d8', args, extra_args=extra_args) is not 0:
         raise Exception('Failed running d8')