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 |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 dex_cmd += paths | 22 dex_cmd += paths |
23 | 23 |
24 record_path = '%s.md5.stamp' % options.dex_path | 24 record_path = '%s.md5.stamp' % options.dex_path |
25 md5_check.CallAndRecordIfStale( | 25 md5_check.CallAndRecordIfStale( |
26 lambda: build_utils.CheckOutput(dex_cmd, print_stderr=False), | 26 lambda: build_utils.CheckOutput(dex_cmd, print_stderr=False), |
27 record_path=record_path, | 27 record_path=record_path, |
28 input_paths=paths, | 28 input_paths=paths, |
29 input_strings=dex_cmd, | 29 input_strings=dex_cmd, |
30 force=not os.path.exists(options.dex_path)) | 30 force=not os.path.exists(options.dex_path)) |
31 build_utils.WriteJson(paths, options.dex_path + '.inputs') | 31 build_utils.WriteJson( |
| 32 [os.path.relpath(p, options.output_directory) for p in paths], |
| 33 options.dex_path + '.inputs') |
32 | 34 |
33 | 35 |
34 def main(): | 36 def main(): |
35 args = build_utils.ExpandFileArgs(sys.argv[1:]) | 37 args = build_utils.ExpandFileArgs(sys.argv[1:]) |
36 | 38 |
37 parser = optparse.OptionParser() | 39 parser = optparse.OptionParser() |
38 build_utils.AddDepfileOption(parser) | 40 build_utils.AddDepfileOption(parser) |
39 | 41 |
40 parser.add_option('--android-sdk-tools', | 42 parser.add_option('--android-sdk-tools', |
41 help='Android sdk build tools directory.') | 43 help='Android sdk build tools directory.') |
| 44 parser.add_option('--output-directory', |
| 45 default=os.getcwd(), |
| 46 help='Path to the output build directory.') |
42 parser.add_option('--dex-path', help='Dex output path.') | 47 parser.add_option('--dex-path', help='Dex output path.') |
43 parser.add_option('--configuration-name', | 48 parser.add_option('--configuration-name', |
44 help='The build CONFIGURATION_NAME.') | 49 help='The build CONFIGURATION_NAME.') |
45 parser.add_option('--proguard-enabled', | 50 parser.add_option('--proguard-enabled', |
46 help='"true" if proguard is enabled.') | 51 help='"true" if proguard is enabled.') |
47 parser.add_option('--proguard-enabled-input-path', | 52 parser.add_option('--proguard-enabled-input-path', |
48 help=('Path to dex in Release mode when proguard ' | 53 help=('Path to dex in Release mode when proguard ' |
49 'is enabled.')) | 54 'is enabled.')) |
50 parser.add_option('--no-locals', | 55 parser.add_option('--no-locals', |
51 help='Exclude locals list from the dex file.') | 56 help='Exclude locals list from the dex file.') |
52 parser.add_option('--inputs', help='A list of additional input paths.') | 57 parser.add_option('--inputs', help='A list of additional input paths.') |
53 parser.add_option('--excluded-paths', | 58 parser.add_option('--excluded-paths', |
54 help='A list of paths to exclude from the dex file.') | 59 help='A list of paths to exclude from the dex file.') |
55 | 60 |
56 options, paths = parser.parse_args(args) | 61 options, paths = parser.parse_args(args) |
57 | 62 |
58 required_options = ('android_sdk_tools',) | 63 required_options = ('android_sdk_tools',) |
59 build_utils.CheckOptions(options, parser, required=required_options) | 64 build_utils.CheckOptions(options, parser, required=required_options) |
60 | 65 |
61 if (options.proguard_enabled == 'true' | 66 if (options.proguard_enabled == 'true' |
62 and options.configuration_name == 'Release'): | 67 and options.configuration_name == 'Release'): |
63 paths = [options.proguard_enabled_input_path] | 68 paths = [options.proguard_enabled_input_path] |
64 | 69 |
65 if options.inputs: | 70 if options.inputs: |
66 paths += build_utils.ParseGypList(options.inputs) | 71 paths += build_utils.ParseGypList(options.inputs) |
67 | 72 |
68 if options.excluded_paths: | 73 if options.excluded_paths: |
| 74 # Excluded paths are relative to the output directory. |
69 exclude_paths = build_utils.ParseGypList(options.excluded_paths) | 75 exclude_paths = build_utils.ParseGypList(options.excluded_paths) |
70 paths = [p for p in paths if not p in exclude_paths] | 76 paths = [p for p in paths if not |
| 77 os.path.relpath(p, options.output_directory) in exclude_paths] |
71 | 78 |
72 DoDex(options, paths) | 79 DoDex(options, paths) |
73 | 80 |
74 if options.depfile: | 81 if options.depfile: |
75 build_utils.WriteDepfile( | 82 build_utils.WriteDepfile( |
76 options.depfile, | 83 options.depfile, |
77 paths + build_utils.GetPythonDependencies()) | 84 paths + build_utils.GetPythonDependencies()) |
78 | 85 |
79 | 86 |
80 | 87 |
81 if __name__ == '__main__': | 88 if __name__ == '__main__': |
82 sys.exit(main()) | 89 sys.exit(main()) |
OLD | NEW |