| 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 """Pushes native libraries to a device. | 7 """Pushes native libraries to a device. |
| 8 | 8 |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 import json | 11 import json |
| 12 import optparse | 12 import optparse |
| 13 import os | 13 import os |
| 14 import sys | 14 import sys |
| 15 | 15 |
| 16 from util import md5_check |
| 17 |
| 16 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..') | 18 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..') |
| 17 sys.path.append(BUILD_ANDROID_DIR) | 19 sys.path.append(BUILD_ANDROID_DIR) |
| 18 | 20 |
| 19 from pylib import android_commands | 21 from pylib import android_commands |
| 20 from pylib import build_utils | 22 from pylib import build_utils |
| 21 | 23 |
| 22 | 24 |
| 23 def DoPush(options): | 25 def DoPush(options): |
| 24 libraries = build_utils.ReadJson(options.libraries_json) | 26 libraries = build_utils.ReadJson(options.libraries_json) |
| 25 | 27 |
| 26 adb = android_commands.AndroidCommands() | 28 adb = android_commands.AndroidCommands() |
| 27 adb.RunShellCommand('mkdir ' + options.device_dir) | 29 needs_directory = True |
| 28 for lib in libraries: | 30 for lib in libraries: |
| 29 device_path = os.path.join(options.device_dir, lib) | 31 device_path = os.path.join(options.device_dir, lib) |
| 30 host_path = os.path.join(options.libraries_dir, lib) | 32 host_path = os.path.join(options.libraries_dir, lib) |
| 31 adb.PushIfNeeded(host_path, device_path) | 33 |
| 34 md5_stamp = '%s.%s.md5' % (host_path, adb.Adb().GetSerialNumber()) |
| 35 md5_checker = md5_check.Md5Checker(stamp=md5_stamp, inputs=[host_path]) |
| 36 if md5_checker.IsStale(): |
| 37 if needs_directory: |
| 38 adb.RunShellCommand('mkdir ' + options.device_dir) |
| 39 needs_directory = False |
| 40 adb.PushIfNeeded(host_path, device_path) |
| 41 md5_checker.Write() |
| 32 | 42 |
| 33 | 43 |
| 34 def main(argv): | 44 def main(argv): |
| 35 parser = optparse.OptionParser() | 45 parser = optparse.OptionParser() |
| 36 parser.add_option('--libraries-dir', | 46 parser.add_option('--libraries-dir', |
| 37 help='Directory that contains stripped libraries.') | 47 help='Directory that contains stripped libraries.') |
| 38 parser.add_option('--device-dir', | 48 parser.add_option('--device-dir', |
| 39 help='Device directory to push the libraries to.') | 49 help='Device directory to push the libraries to.') |
| 40 parser.add_option('--libraries-json', | 50 parser.add_option('--libraries-json', |
| 41 help='Path to the json list of native libraries.') | 51 help='Path to the json list of native libraries.') |
| 42 parser.add_option('--stamp', help='Path to touch on success.') | 52 parser.add_option('--stamp', help='Path to touch on success.') |
| 43 options, _ = parser.parse_args() | 53 options, _ = parser.parse_args() |
| 44 | 54 |
| 45 required_options = ['libraries_dir', 'device_dir', 'libraries_json'] | 55 required_options = ['libraries_dir', 'device_dir', 'libraries_json'] |
| 46 build_utils.CheckOptions(options, parser, required=required_options) | 56 build_utils.CheckOptions(options, parser, required=required_options) |
| 47 | 57 |
| 48 DoPush(options) | 58 DoPush(options) |
| 49 | 59 |
| 50 if options.stamp: | 60 if options.stamp: |
| 51 build_utils.Touch(options.stamp) | 61 build_utils.Touch(options.stamp) |
| 52 | 62 |
| 53 | 63 |
| 54 if __name__ == '__main__': | 64 if __name__ == '__main__': |
| 55 sys.exit(main(sys.argv)) | 65 sys.exit(main(sys.argv)) |
| OLD | NEW |