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 fnmatch | |
8 import optparse | 7 import optparse |
9 import os | 8 import os |
10 import sys | 9 import sys |
11 | 10 |
12 from util import build_utils | 11 from util import build_utils |
13 from util import md5_check | 12 from util import md5_check |
14 | 13 |
15 | 14 |
16 def DoDex(options, paths): | 15 def DoDex(options, paths): |
17 dx_binary = os.path.join(options.android_sdk_tools, 'dx') | 16 dx_binary = os.path.join(options.android_sdk_tools, 'dx') |
18 | 17 dex_cmd = [dx_binary, '--dex', '--force-jumbo', '--output', options.dex_path] |
19 # See http://crbug.com/272064 for context on --force-jumbo. | 18 if options.no_locals != '0': |
cjhopman
2013/08/20 15:27:24
Nit: keep this comment
gkanwar1
2013/08/20 17:30:14
Oops, must have lost that during a rebase. Fixed.
| |
20 dex_cmd = [dx_binary, '--dex', '--force-jumbo', '--output', | 19 dex_cmd.append('--no-locals') |
21 options.dex_path] + paths | 20 dex_cmd += paths |
22 | 21 |
23 record_path = '%s.md5.stamp' % options.dex_path | 22 record_path = '%s.md5.stamp' % options.dex_path |
24 md5_check.CallAndRecordIfStale( | 23 md5_check.CallAndRecordIfStale( |
25 lambda: build_utils.CheckCallDie(dex_cmd, suppress_output=True), | 24 lambda: build_utils.CheckCallDie(dex_cmd, suppress_output=True), |
26 record_path=record_path, | 25 record_path=record_path, |
27 input_paths=paths, | 26 input_paths=paths, |
28 input_strings=dex_cmd) | 27 input_strings=dex_cmd) |
29 | 28 |
30 build_utils.Touch(options.dex_path) | 29 build_utils.Touch(options.dex_path) |
31 | 30 |
32 | 31 |
33 def main(argv): | 32 def main(argv): |
34 parser = optparse.OptionParser() | 33 parser = optparse.OptionParser() |
35 parser.add_option('--android-sdk-tools', | 34 parser.add_option('--android-sdk-tools', |
36 help='Android sdk build tools directory.') | 35 help='Android sdk build tools directory.') |
37 parser.add_option('--dex-path', help='Dex output path.') | 36 parser.add_option('--dex-path', help='Dex output path.') |
38 parser.add_option('--configuration-name', | 37 parser.add_option('--configuration-name', |
39 help='The build CONFIGURATION_NAME.') | 38 help='The build CONFIGURATION_NAME.') |
40 parser.add_option('--proguard-enabled', | 39 parser.add_option('--proguard-enabled', |
41 help='"true" if proguard is enabled.') | 40 help='"true" if proguard is enabled.') |
42 parser.add_option('--proguard-enabled-input-path', | 41 parser.add_option('--proguard-enabled-input-path', |
43 help='Path to dex in Release mode when proguard is enabled.') | 42 help=('Path to dex in Release mode when proguard ' |
43 'is enabled.')) | |
44 parser.add_option('--no-locals', | |
45 help='Exclude locals list from the dex file.') | |
44 parser.add_option('--stamp', help='Path to touch on success.') | 46 parser.add_option('--stamp', help='Path to touch on success.') |
45 | 47 |
46 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja. | 48 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja. |
47 parser.add_option('--ignore', help='Ignored.') | 49 parser.add_option('--ignore', help='Ignored.') |
48 | 50 |
49 options, paths = parser.parse_args() | 51 options, paths = parser.parse_args() |
50 | 52 |
51 if (options.proguard_enabled == "true" | 53 if (options.proguard_enabled == 'true' |
52 and options.configuration_name == "Release"): | 54 and options.configuration_name == 'Release'): |
53 paths = [options.proguard_enabled_input_path] | 55 paths = [options.proguard_enabled_input_path] |
54 | 56 |
55 DoDex(options, paths) | 57 DoDex(options, paths) |
56 | 58 |
57 if options.stamp: | 59 if options.stamp: |
58 build_utils.Touch(options.stamp) | 60 build_utils.Touch(options.stamp) |
59 | 61 |
60 | 62 |
61 if __name__ == '__main__': | 63 if __name__ == '__main__': |
62 sys.exit(main(sys.argv)) | 64 sys.exit(main(sys.argv)) |
63 | |
OLD | NEW |