| 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 proguard_util | 12 from util import proguard_util |
| 13 | 13 |
| 14 | 14 |
| 15 def _ParseOptions(args): | 15 def _ParseOptions(args): |
| 16 parser = optparse.OptionParser() | 16 parser = optparse.OptionParser() |
| 17 build_utils.AddDepfileOption(parser) | 17 build_utils.AddDepfileOption(parser) |
| 18 parser.add_option('--proguard-path', | 18 parser.add_option('--proguard-path', |
| 19 help='Path to the proguard executable.') | 19 help='Path to the proguard executable.') |
| 20 parser.add_option('--input-paths', | 20 parser.add_option('--input-paths', |
| 21 help='Paths to the .jar files proguard should run on.') | 21 help='Paths to the .jar files proguard should run on.') |
| 22 parser.add_option('--output-path', help='Path to the generated .jar file.') | 22 parser.add_option('--output-path', help='Path to the generated .jar file.') |
| 23 parser.add_option('--proguard-configs', | 23 parser.add_option('--proguard-configs', |
| 24 help='Paths to proguard configuration files.') | 24 help='Paths to proguard configuration files.') |
| 25 parser.add_option('--mapping', help='Path to proguard mapping to apply.') | 25 parser.add_option('--mapping', help='Path to proguard mapping to apply.') |
| 26 parser.add_option('--is-test', action='store_true', | 26 parser.add_option('--is-test', action='store_true', |
| 27 help='If true, extra proguard options for instrumentation tests will be ' | 27 help='If true, extra proguard options for instrumentation tests will be ' |
| 28 'added.') | 28 'added.') |
| 29 parser.add_option('--tested-apk-info', help='Path to the proguard .info file ' |
| 30 'for the tested apk') |
| 29 parser.add_option('--classpath', action='append', | 31 parser.add_option('--classpath', action='append', |
| 30 help='Classpath for proguard.') | 32 help='Classpath for proguard.') |
| 31 parser.add_option('--stamp', help='Path to touch on success.') | 33 parser.add_option('--stamp', help='Path to touch on success.') |
| 32 | 34 |
| 33 options, _ = parser.parse_args(args) | 35 options, _ = parser.parse_args(args) |
| 34 | 36 |
| 35 classpath = [] | 37 classpath = [] |
| 36 for arg in options.classpath: | 38 for arg in options.classpath: |
| 37 classpath += build_utils.ParseGypList(arg) | 39 classpath += build_utils.ParseGypList(arg) |
| 38 options.classpath = classpath | 40 options.classpath = classpath |
| 39 | 41 |
| 40 return options | 42 return options |
| 41 | 43 |
| 42 | 44 |
| 43 def main(args): | 45 def main(args): |
| 44 args = build_utils.ExpandFileArgs(args) | 46 args = build_utils.ExpandFileArgs(args) |
| 45 options = _ParseOptions(args) | 47 options = _ParseOptions(args) |
| 46 | 48 |
| 47 proguard = proguard_util.ProguardCmdBuilder(options.proguard_path) | 49 proguard = proguard_util.ProguardCmdBuilder(options.proguard_path) |
| 48 proguard.injars(build_utils.ParseGypList(options.input_paths)) | 50 proguard.injars(build_utils.ParseGypList(options.input_paths)) |
| 49 proguard.configs(build_utils.ParseGypList(options.proguard_configs)) | 51 proguard.configs(build_utils.ParseGypList(options.proguard_configs)) |
| 50 proguard.outjar(options.output_path) | 52 proguard.outjar(options.output_path) |
| 51 | 53 |
| 52 if options.mapping: | 54 if options.mapping: |
| 53 proguard.mapping(options.mapping) | 55 proguard.mapping(options.mapping) |
| 54 | 56 |
| 55 if options.is_test: | 57 if options.tested_apk_info: |
| 56 proguard.is_test(True) | 58 proguard.tested_apk_info(options.tested_apk_info) |
| 57 | 59 |
| 58 classpath = list(set(options.classpath)) | 60 classpath = list(set(options.classpath)) |
| 59 proguard.libraryjars(classpath) | 61 proguard.libraryjars(classpath) |
| 60 | 62 |
| 61 input_paths = proguard.GetInputs() | 63 input_paths = proguard.GetInputs() |
| 62 | 64 |
| 63 build_utils.CallAndWriteDepfileIfStale( | 65 build_utils.CallAndWriteDepfileIfStale( |
| 64 proguard.CheckOutput, | 66 proguard.CheckOutput, |
| 65 options, | 67 options, |
| 66 input_paths=input_paths, | 68 input_paths=input_paths, |
| 67 input_strings=proguard.build(), | 69 input_strings=proguard.build(), |
| 68 output_paths=[options.output_path]) | 70 output_paths=[options.output_path]) |
| 69 | 71 |
| 70 | 72 |
| 71 if __name__ == '__main__': | 73 if __name__ == '__main__': |
| 72 sys.exit(main(sys.argv[1:])) | 74 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |