Tools: Switch from JAR-per-tool to a single swiss army knife
Introduce SwissArmyKnife entrypoint that defers to the different
entrypoints based on the first argument, defaulting to R8.main()
if the first argument is not recognized as the name of a tool.
In build.gradle, change tasks for D8, CompatDx and CompatProguard
to simply repackaging the R8 JAR but with a different Main-Class.
Remove gradle tasks for DexFileMerger, DexSplitter, D8Logger, disasm,
bisect, DexSegments, maindex, ExtractMarker, jardiff.
Introduce toolhelper.py with a run() method that runs the swiss army
knife. Change r8.py, d8.py, compatdx.py nad bisect.py to use
toolhelper.run(), and add Python scripts compatproguard, d8logger,
dexfilemerger, dexsegments, dexsplitter, disasm, extractmarker, jardiff,
maindex that use toolhelper.run().
Make archive.py use subprocess.check_output() directly instead of going
through r8.run() and d8.run() to get the versions.
Simplify run_on_app.py a bit by using toolhelper.run().
Change-Id: I752705188e728d2c4f7bfdc61b90448298eaa5bd
diff --git a/tools/archive.py b/tools/archive.py
index 815e416..32d58bc 100755
--- a/tools/archive.py
+++ b/tools/archive.py
@@ -3,22 +3,25 @@
# 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.
-import gradle
import create_maven_release
-import d8
+import gradle
import os
-import r8
+import shutil
import subprocess
import sys
+import toolhelper
import utils
-import shutil
import zipfile
ARCHIVE_BUCKET = 'r8-releases'
+def GetToolVersion(jar_path):
+ output = subprocess.check_output(['java', '-jar', jar_path, '--version'])
+ return output.splitlines()[0].strip()
+
def GetVersion():
- r8_version = r8.run(['--version'], build = False).splitlines()[0].strip()
- d8_version = d8.run(['--version'], build = False).splitlines()[0].strip()
+ r8_version = GetToolVersion(utils.R8_JAR)
+ d8_version = GetToolVersion(utils.D8_JAR)
# The version printed is "D8 vVERSION_NUMBER" and "R8 vVERSION_NUMBER"
# Sanity check that versions match.
if d8_version.split()[1] != r8_version.split()[1]: