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/run_on_app.py b/tools/run_on_app.py
index b9bcc60..571d96d 100755
--- a/tools/run_on_app.py
+++ b/tools/run_on_app.py
@@ -10,10 +10,9 @@
import sys
import time
-import d8
import gmail_data
import gmscore_data
-import r8
+import toolhelper
import utils
import youtube_data
@@ -191,22 +190,20 @@
if options.print_memoryuse and not options.track_memory_to_file:
options.track_memory_to_file = os.path.join(temp,
utils.MEMORY_USE_TMP_FILE)
- if options.compiler == 'd8':
- d8.run(args, not options.no_build, not options.no_debug,
- options.profile, options.track_memory_to_file)
- else:
- if app_provided_pg_conf:
- # Ensure that output of -printmapping and -printseeds go to the output
- # location and not where the app Proguard configuration places them.
- if outdir.endswith('.zip') or outdir.endswith('.jar'):
- pg_outdir = os.path.dirname(outdir)
- else:
- pg_outdir = outdir
- additional_pg_conf = GenerateAdditionalProguardConfiguration(
- temp, os.path.abspath(pg_outdir))
- args.extend(['--pg-conf', additional_pg_conf])
- r8.run(args, not options.no_build, not options.no_debug,
- options.profile, options.track_memory_to_file)
+ if options.compiler == 'r8' and app_provided_pg_conf:
+ # Ensure that output of -printmapping and -printseeds go to the output
+ # location and not where the app Proguard configuration places them.
+ if outdir.endswith('.zip') or outdir.endswith('.jar'):
+ pg_outdir = os.path.dirname(outdir)
+ else:
+ pg_outdir = outdir
+ additional_pg_conf = GenerateAdditionalProguardConfiguration(
+ temp, os.path.abspath(pg_outdir))
+ args.extend(['--pg-conf', additional_pg_conf])
+ toolhelper.run(options.compiler, args, build=not options.no_build,
+ debug=not options.no_debug,
+ profile=options.profile,
+ track_memory_to_file=options.track_memory_to_file)
if options.print_memoryuse:
print('{}(MemoryUse): {}'
.format(options.print_memoryuse,