| 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 from util import build_utils | 11 from util import build_utils |
| 12 from util import md5_check | 12 from util import md5_check |
| 13 | 13 |
| 14 | 14 |
| 15 def DoDex(options, paths): | 15 def DoDex(options, paths): |
| 16 dx_binary = os.path.join(options.android_sdk_tools, 'dx') | 16 dx_binary = os.path.join(options.android_sdk_tools, 'dx') |
| 17 # See http://crbug.com/272064 for context on --force-jumbo. | 17 # See http://crbug.com/272064 for context on --force-jumbo. |
| 18 dex_cmd = [dx_binary, '--dex', '--force-jumbo', '--output', options.dex_path] | 18 dex_cmd = [dx_binary, '--dex', '--force-jumbo', '--output', options.dex_path] |
| 19 if options.no_locals != '0': | 19 if options.no_locals != '0': |
| 20 dex_cmd.append('--no-locals') | 20 dex_cmd.append('--no-locals') |
| 21 |
| 21 dex_cmd += paths | 22 dex_cmd += paths |
| 22 | 23 |
| 23 record_path = '%s.md5.stamp' % options.dex_path | 24 record_path = '%s.md5.stamp' % options.dex_path |
| 24 md5_check.CallAndRecordIfStale( | 25 md5_check.CallAndRecordIfStale( |
| 25 lambda: build_utils.CheckOutput(dex_cmd, print_stderr=False), | 26 lambda: build_utils.CheckOutput(dex_cmd, print_stderr=False), |
| 26 record_path=record_path, | 27 record_path=record_path, |
| 27 input_paths=paths, | 28 input_paths=paths, |
| 28 input_strings=dex_cmd, | 29 input_strings=dex_cmd, |
| 29 force=not os.path.exists(options.dex_path)) | 30 force=not os.path.exists(options.dex_path)) |
| 30 build_utils.WriteJson(paths, options.dex_path + '.inputs') | 31 build_utils.WriteJson(paths, options.dex_path + '.inputs') |
| 31 | 32 |
| 32 | 33 |
| 33 def main(): | 34 def main(): |
| 35 args = build_utils.ExpandFileArgs(sys.argv[1:]) |
| 36 |
| 34 parser = optparse.OptionParser() | 37 parser = optparse.OptionParser() |
| 38 build_utils.AddDepfileOption(parser) |
| 39 |
| 35 parser.add_option('--android-sdk-tools', | 40 parser.add_option('--android-sdk-tools', |
| 36 help='Android sdk build tools directory.') | 41 help='Android sdk build tools directory.') |
| 37 parser.add_option('--dex-path', help='Dex output path.') | 42 parser.add_option('--dex-path', help='Dex output path.') |
| 38 parser.add_option('--configuration-name', | 43 parser.add_option('--configuration-name', |
| 39 help='The build CONFIGURATION_NAME.') | 44 help='The build CONFIGURATION_NAME.') |
| 40 parser.add_option('--proguard-enabled', | 45 parser.add_option('--proguard-enabled', |
| 41 help='"true" if proguard is enabled.') | 46 help='"true" if proguard is enabled.') |
| 42 parser.add_option('--proguard-enabled-input-path', | 47 parser.add_option('--proguard-enabled-input-path', |
| 43 help=('Path to dex in Release mode when proguard ' | 48 help=('Path to dex in Release mode when proguard ' |
| 44 'is enabled.')) | 49 'is enabled.')) |
| 45 parser.add_option('--no-locals', | 50 parser.add_option('--no-locals', |
| 46 help='Exclude locals list from the dex file.') | 51 help='Exclude locals list from the dex file.') |
| 52 parser.add_option('--inputs', help='A list of additional input paths.') |
| 47 parser.add_option('--excluded-paths-file', | 53 parser.add_option('--excluded-paths-file', |
| 48 help='Path to a file containing a list of paths to exclude ' | 54 help='Path to a file containing a list of paths to exclude ' |
| 49 'from the dex file.') | 55 'from the dex file.') |
| 50 | 56 |
| 51 options, paths = parser.parse_args() | 57 options, paths = parser.parse_args(args) |
| 58 |
| 59 required_options = ('android_sdk_tools',) |
| 60 build_utils.CheckOptions(options, parser, required=required_options) |
| 52 | 61 |
| 53 if (options.proguard_enabled == 'true' | 62 if (options.proguard_enabled == 'true' |
| 54 and options.configuration_name == 'Release'): | 63 and options.configuration_name == 'Release'): |
| 55 paths = [options.proguard_enabled_input_path] | 64 paths = [options.proguard_enabled_input_path] |
| 56 | 65 |
| 57 if options.excluded_paths_file: | 66 if options.excluded_paths_file: |
| 58 exclude_paths = build_utils.ReadJson(options.excluded_paths_file) | 67 exclude_paths = build_utils.ReadJson(options.excluded_paths_file) |
| 59 paths = [p for p in paths if not p in exclude_paths] | 68 paths = [p for p in paths if not p in exclude_paths] |
| 60 | 69 |
| 70 if options.inputs: |
| 71 paths += build_utils.ParseGypList(options.inputs) |
| 72 |
| 61 DoDex(options, paths) | 73 DoDex(options, paths) |
| 62 | 74 |
| 75 if options.depfile: |
| 76 build_utils.WriteDepfile( |
| 77 options.depfile, |
| 78 paths + build_utils.GetPythonDependencies()) |
| 79 |
| 80 |
| 63 | 81 |
| 64 if __name__ == '__main__': | 82 if __name__ == '__main__': |
| 65 sys.exit(main()) | 83 sys.exit(main()) |
| OLD | NEW |