blob: 63865d05ca1d9cf047364d3a143bcc47399527d4 [file] [log] [blame]
Mads Ager418d1ca2017-05-22 09:35:49 +02001#!/usr/bin/env python
2# Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
3# for details. All rights reserved. Use of this source code is governed by a
4# BSD-style license that can be found in the LICENSE file.
5
6import d8
7import gmscore_data
8import optparse
9import os
10import sys
11
12def ParseOptions():
13 result = optparse.OptionParser()
14 result.add_option('--out',
15 help = '',
16 default = os.getcwd())
17 result.add_option('--no-build',
18 help = '',
19 default = False,
20 action = 'store_true')
21 result.add_option('--no-debug',
22 help = 'Run without debug asserts.',
23 default = False,
24 action = 'store_true')
25 result.add_option('--version',
26 help = '',
27 default = 'v9',
Tamas Kenez228870b2017-08-23 13:53:22 +020028 choices = ['v9', 'v10', 'latest'])
Mads Ager418d1ca2017-05-22 09:35:49 +020029 result.add_option('--type',
30 help = '',
31 default = 'proguarded',
32 choices = ['proguarded', 'deploy'])
33 result.add_option('--d8-flags',
34 help = 'Additional option(s) for D8. ' +
35 'If passing several options use a quoted string.')
36 result.add_option('--track-memory-to-file',
37 help = 'Track how much memory the jvm is using while ' +
38 ' compiling. Output to the specified file.')
39 result.add_option('--profile',
40 help = 'Profile D8 run.',
41 default = False,
42 action = 'store_true')
43 result.add_option('--dump-args-file',
44 help = 'Dump a file with the arguments for the specified ' +
45 'configuration. For use as a @<file> argument to perform ' +
46 'the run.')
47 return result.parse_args()
48
49def main():
50 (options, args) = ParseOptions()
51 outdir = options.out
52 version = gmscore_data.VERSIONS[options.version]
53 values = version[options.type]
54 inputs = values['inputs']
55
56 args.extend(['--output', outdir])
57
58 if not os.path.exists(outdir):
59 os.makedirs(outdir)
60
Lars Bak9bee2d82017-08-23 11:00:04 +020061 if 'main-dex-list' in values:
62 args.extend(['--main-dex-list', values['main-dex-list']])
63
Mads Ager418d1ca2017-05-22 09:35:49 +020064 if options.d8_flags:
65 args.extend(options.d8_flags.split(' '))
66
67 args.extend(inputs)
68
69 if options.dump_args_file:
70 with open(options.dump_args_file, 'w') as args_file:
71 args_file.writelines([arg + os.linesep for arg in args])
72 else:
73 d8.run(args, not options.no_build, not options.no_debug, options.profile,
74 options.track_memory_to_file)
75
76if __name__ == '__main__':
77 sys.exit(main())