Make '--app' and '--compiler' explicit in run_on_app.py
Also fix d8.py not printing the d8 command line.
Bug:
Change-Id: Ice2fb5f8c50c85e1cd820a258d3a985792953dd7
diff --git a/tools/d8.py b/tools/d8.py
index cb0c841..d214cf5 100755
--- a/tools/d8.py
+++ b/tools/d8.py
@@ -24,6 +24,7 @@
cmd.append('-agentlib:hprof=cpu=samples,interval=1,depth=8')
cmd.extend(['-jar', D8_JAR])
cmd.extend(args)
+ utils.PrintCmd(cmd)
subprocess.check_call(cmd)
def main():
diff --git a/tools/run-r8-on-gmscore.py b/tools/run-r8-on-gmscore.py
index f4d8994..ee8b813 100755
--- a/tools/run-r8-on-gmscore.py
+++ b/tools/run-r8-on-gmscore.py
@@ -8,4 +8,5 @@
if __name__ == '__main__':
# Default compiler is R8.
- sys.exit(run_on_app.main())
+ sys.exit(run_on_app.main(sys.argv[1:]
+ + ['--app', 'gmscore', '--compiler', 'r8']))
diff --git a/tools/run_on_app.py b/tools/run_on_app.py
index a091e1c..a207ed8 100755
--- a/tools/run_on_app.py
+++ b/tools/run_on_app.py
@@ -19,16 +19,15 @@
TYPES = ['dex', 'deploy', 'proguarded']
APPS = ['gmscore', 'youtube', 'gmail']
+COMPILERS = ['d8', 'r8']
-def ParseOptions():
+def ParseOptions(argv):
result = optparse.OptionParser()
result.add_option('--compiler',
help='',
- default='r8',
- choices=['d8', 'r8'])
+ choices=COMPILERS)
result.add_option('--app',
help='',
- default='gmscore',
choices=APPS)
result.add_option('--type',
help='Default for R8: deploy, for D8: proguarded',
@@ -87,7 +86,7 @@
metavar='BENCHMARKNAME',
help='Print the sizes of individual dex segments as ' +
'\'<BENCHMARKNAME>-<segment>(CodeSize): <bytes>\'')
- return result.parse_args()
+ return result.parse_args(argv)
# Most apps have the -printmapping and -printseeds in the Proguard
# configuration. However we don't want to write these files in these
@@ -100,9 +99,9 @@
f.write('-printseeds ' + os.path.join(outdir, 'proguard.seeds') + "\n")
return os.path.abspath(f.name)
-def main():
+def main(argv):
app_provided_pg_conf = False;
- (options, args) = ParseOptions()
+ (options, args) = ParseOptions(argv)
outdir = options.out
data = None
if options.app == 'gmscore':
@@ -115,7 +114,11 @@
options.version = options.version or '170604.16'
data = gmail_data
else:
- raise 'Unexpected'
+ raise Exception("You need to specify '--app={}'".format('|'.join(APPS)))
+
+ if options.compiler not in COMPILERS:
+ raise Exception("You need to specify '--compiler={}'"
+ .format('|'.join(COMPILERS)))
if not options.version in data.VERSIONS.keys():
print('No version {} for application {}'
@@ -217,4 +220,4 @@
utils.print_dexsegments(options.print_dexsegments, dex_files)
if __name__ == '__main__':
- sys.exit(main())
+ sys.exit(main(sys.argv[1:]))