| 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 | 7 import fnmatch |
| 8 import optparse | 8 import optparse |
| 9 import os | 9 import os |
| 10 import sys | 10 import sys |
| 11 | 11 |
| 12 from util import build_utils | 12 from util import build_utils |
| 13 from util import md5_check | 13 from util import md5_check |
| 14 | 14 |
| 15 | 15 |
| 16 def DoDex(options, paths): | 16 def DoDex(options, paths): |
| 17 dx_binary = os.path.join(options.android_sdk_root, 'platform-tools', 'dx') | 17 dx_binary = os.path.join(options.android_sdk_root, 'platform-tools', 'dx') |
| 18 dex_cmd = [dx_binary, '--dex', '--output', options.dex_path] + paths | 18 dex_cmd = [dx_binary, '--dex', '--output', options.dex_path] + paths |
| 19 | 19 |
| 20 md5_stamp = '%s.md5' % options.dex_path | 20 record_path = '%s.md5.stamp' % options.dex_path |
| 21 md5_checker = md5_check.Md5Checker( | 21 md5_check.CallAndRecordIfStale( |
| 22 stamp=md5_stamp, inputs=paths, command=dex_cmd) | 22 lambda: build_utils.CheckCallDie(dex_cmd, suppress_output=True), |
| 23 if md5_checker.IsStale(): | 23 record_path=record_path, |
| 24 build_utils.CheckCallDie(dex_cmd, suppress_output=True) | 24 input_paths=paths, |
| 25 else: | 25 input_strings=dex_cmd) |
| 26 build_utils.Touch(options.dex_path) | 26 |
| 27 md5_checker.Write() | 27 build_utils.Touch(options.dex_path) |
| 28 | 28 |
| 29 | 29 |
| 30 def main(argv): | 30 def main(argv): |
| 31 parser = optparse.OptionParser() | 31 parser = optparse.OptionParser() |
| 32 parser.add_option('--android-sdk-root', help='Android sdk root directory.') | 32 parser.add_option('--android-sdk-root', help='Android sdk root directory.') |
| 33 parser.add_option('--dex-path', help='Dex output path.') | 33 parser.add_option('--dex-path', help='Dex output path.') |
| 34 parser.add_option('--stamp', help='Path to touch on success.') | 34 parser.add_option('--stamp', help='Path to touch on success.') |
| 35 | 35 |
| 36 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja. | 36 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja. |
| 37 parser.add_option('--ignore', help='Ignored.') | 37 parser.add_option('--ignore', help='Ignored.') |
| 38 | 38 |
| 39 options, paths = parser.parse_args() | 39 options, paths = parser.parse_args() |
| 40 | 40 |
| 41 DoDex(options, paths) | 41 DoDex(options, paths) |
| 42 | 42 |
| 43 if options.stamp: | 43 if options.stamp: |
| 44 build_utils.Touch(options.stamp) | 44 build_utils.Touch(options.stamp) |
| 45 | 45 |
| 46 | 46 |
| 47 if __name__ == '__main__': | 47 if __name__ == '__main__': |
| 48 sys.exit(main(sys.argv)) | 48 sys.exit(main(sys.argv)) |
| 49 | 49 |
| OLD | NEW |