OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 import optparse | 7 import optparse |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 | 10 |
| 11 # pylint: disable=F0401 |
11 from util import build_utils | 12 from util import build_utils |
12 from util import md5_check | 13 from util import md5_check |
| 14 # pylint: enable=F0401 |
13 | 15 |
14 | 16 |
15 def DoDex(options, paths): | 17 def DoDex(options, paths): |
16 dx_binary = os.path.join(options.android_sdk_tools, 'dx') | 18 dx_binary = os.path.join(options.android_sdk_tools, 'dx') |
17 # See http://crbug.com/272064 for context on --force-jumbo. | 19 # See http://crbug.com/272064 for context on --force-jumbo. |
18 dex_cmd = [dx_binary, '--dex', '--force-jumbo', '--output', options.dex_path] | 20 dex_cmd = [dx_binary, '--dex', '--force-jumbo', '--output', options.dex_path] |
19 if options.no_locals != '0': | 21 if options.no_locals != '0': |
20 dex_cmd.append('--no-locals') | 22 dex_cmd.append('--no-locals') |
21 dex_cmd += paths | 23 dex_cmd += paths |
22 | 24 |
23 record_path = '%s.md5.stamp' % options.dex_path | 25 record_path = '%s.md5.stamp' % options.dex_path |
24 md5_check.CallAndRecordIfStale( | 26 md5_check.CallAndRecordIfStale( |
25 lambda: build_utils.CheckOutput(dex_cmd, print_stderr=False), | 27 lambda: build_utils.CheckOutput(dex_cmd, print_stderr=False), |
26 record_path=record_path, | 28 record_path=record_path, |
27 input_paths=paths, | 29 input_paths=paths, |
28 input_strings=dex_cmd) | 30 input_strings=dex_cmd) |
29 | 31 |
30 build_utils.Touch(options.dex_path) | 32 build_utils.Touch(options.dex_path) |
31 | 33 |
32 | 34 |
33 def main(argv): | 35 def main(): |
34 parser = optparse.OptionParser() | 36 parser = optparse.OptionParser() |
35 parser.add_option('--android-sdk-tools', | 37 parser.add_option('--android-sdk-tools', |
36 help='Android sdk build tools directory.') | 38 help='Android sdk build tools directory.') |
37 parser.add_option('--dex-path', help='Dex output path.') | 39 parser.add_option('--dex-path', help='Dex output path.') |
38 parser.add_option('--configuration-name', | 40 parser.add_option('--configuration-name', |
39 help='The build CONFIGURATION_NAME.') | 41 help='The build CONFIGURATION_NAME.') |
40 parser.add_option('--proguard-enabled', | 42 parser.add_option('--proguard-enabled', |
41 help='"true" if proguard is enabled.') | 43 help='"true" if proguard is enabled.') |
42 parser.add_option('--proguard-enabled-input-path', | 44 parser.add_option('--proguard-enabled-input-path', |
43 help=('Path to dex in Release mode when proguard ' | 45 help=('Path to dex in Release mode when proguard ' |
44 'is enabled.')) | 46 'is enabled.')) |
45 parser.add_option('--no-locals', | 47 parser.add_option('--no-locals', |
46 help='Exclude locals list from the dex file.') | 48 help='Exclude locals list from the dex file.') |
47 | 49 |
48 options, paths = parser.parse_args() | 50 options, paths = parser.parse_args() |
49 | 51 |
50 if (options.proguard_enabled == 'true' | 52 if (options.proguard_enabled == 'true' |
51 and options.configuration_name == 'Release'): | 53 and options.configuration_name == 'Release'): |
52 paths = [options.proguard_enabled_input_path] | 54 paths = [options.proguard_enabled_input_path] |
53 | 55 |
54 DoDex(options, paths) | 56 DoDex(options, paths) |
55 | 57 |
56 | 58 |
57 if __name__ == '__main__': | 59 if __name__ == '__main__': |
58 sys.exit(main(sys.argv)) | 60 sys.exit(main()) |
OLD | NEW |