| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 options.input_paths = build_utils.ParseGnList(options.input_paths) | 60 options.input_paths = build_utils.ParseGnList(options.input_paths) |
| 61 | 61 |
| 62 return options | 62 return options |
| 63 | 63 |
| 64 | 64 |
| 65 def main(args): | 65 def main(args): |
| 66 args = build_utils.ExpandFileArgs(args) | 66 args = build_utils.ExpandFileArgs(args) |
| 67 options = _ParseOptions(args) | 67 options = _ParseOptions(args) |
| 68 | 68 |
| 69 # Work around cases where we switch from a non-proguard setup |
| 70 # to proguard. The output jar might exist and might be a hardlink |
| 71 # to the input jar, so remove the output before doing anything |
| 72 # in that case to avoid an incremental build failure. |
| 73 try: |
| 74 out_inode = os.stat(options.output_path).st_ino |
| 75 except OSError: |
| 76 out_inode = None |
| 77 if (out_inode and |
| 78 out_inode in (os.stat(injar).st_ino for injar in options.input_paths)): |
| 79 os.unlink(options.output_path) |
| 80 |
| 69 proguard = proguard_util.ProguardCmdBuilder(options.proguard_path) | 81 proguard = proguard_util.ProguardCmdBuilder(options.proguard_path) |
| 70 proguard.injars(options.input_paths) | 82 proguard.injars(options.input_paths) |
| 71 proguard.configs(options.proguard_configs) | 83 proguard.configs(options.proguard_configs) |
| 72 proguard.outjar(options.output_path) | 84 proguard.outjar(options.output_path) |
| 73 | 85 |
| 74 if options.mapping: | 86 if options.mapping: |
| 75 proguard.mapping(options.mapping) | 87 proguard.mapping(options.mapping) |
| 76 | 88 |
| 77 if options.tested_apk_info: | 89 if options.tested_apk_info: |
| 78 proguard.tested_apk_info(options.tested_apk_info) | 90 proguard.tested_apk_info(options.tested_apk_info) |
| 79 | 91 |
| 80 classpath = list(set(options.classpath)) | 92 classpath = list(set(options.classpath)) |
| 81 proguard.libraryjars(classpath) | 93 proguard.libraryjars(classpath) |
| 82 proguard.verbose(options.verbose) | 94 proguard.verbose(options.verbose) |
| 83 if not options.enable_dangerous_optimizations: | 95 if not options.enable_dangerous_optimizations: |
| 84 proguard.disable_optimizations(_DANGEROUS_OPTIMIZATIONS) | 96 proguard.disable_optimizations(_DANGEROUS_OPTIMIZATIONS) |
| 85 | 97 |
| 86 input_paths = proguard.GetInputs() | 98 input_paths = proguard.GetInputs() |
| 87 | 99 |
| 88 build_utils.CallAndWriteDepfileIfStale( | 100 build_utils.CallAndWriteDepfileIfStale( |
| 89 proguard.CheckOutput, | 101 proguard.CheckOutput, |
| 90 options, | 102 options, |
| 91 input_paths=input_paths, | 103 input_paths=input_paths, |
| 92 input_strings=proguard.build(), | 104 input_strings=proguard.build(), |
| 93 output_paths=[options.output_path]) | 105 output_paths=[options.output_path]) |
| 94 | 106 |
| 95 | 107 |
| 96 if __name__ == '__main__': | 108 if __name__ == '__main__': |
| 97 sys.exit(main(sys.argv[1:])) | 109 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |