| 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 optparse | 11 import optparse |
| 12 import os | 12 import os |
| 13 import sys | 13 import sys |
| 14 | 14 |
| 15 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), os.pardir) | 15 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), os.pardir) |
| 16 sys.path.append(BUILD_ANDROID_DIR) | 16 sys.path.append(BUILD_ANDROID_DIR) |
| 17 | 17 |
| 18 from pylib import constants | 18 from pylib import constants |
| 19 | 19 |
| 20 from util import build_device | 20 from util import build_device |
| 21 from util import build_utils | 21 from util import build_utils |
| 22 from util import md5_check | 22 from util import md5_check |
| 23 | 23 |
| 24 def DoPush(options): | 24 def DoPush(options): |
| 25 libraries = build_utils.ReadJson(options.libraries_json) | 25 libraries = build_utils.ParseGypList(options.libraries) |
| 26 | 26 |
| 27 device = build_device.GetBuildDeviceFromPath( | 27 device = build_device.GetBuildDeviceFromPath( |
| 28 options.build_device_configuration) | 28 options.build_device_configuration) |
| 29 if not device: | 29 if not device: |
| 30 return | 30 return |
| 31 | 31 |
| 32 serial_number = device.GetSerialNumber() | 32 serial_number = device.GetSerialNumber() |
| 33 # A list so that it is modifiable in Push below. | 33 # A list so that it is modifiable in Push below. |
| 34 needs_directory = [True] | 34 needs_directory = [True] |
| 35 for lib in libraries: | 35 for lib in libraries: |
| 36 device_path = os.path.join(options.device_dir, lib) | 36 device_path = os.path.join(options.device_dir, lib) |
| 37 host_path = os.path.join(options.libraries_dir, lib) | 37 host_path = os.path.join(options.libraries_dir, lib) |
| 38 | 38 |
| 39 def Push(): | 39 def Push(): |
| 40 if needs_directory: | 40 if needs_directory: |
| 41 device.RunShellCommand('mkdir -p ' + options.device_dir) | 41 device.RunShellCommand('mkdir -p ' + options.device_dir) |
| 42 needs_directory[:] = [] # = False | 42 needs_directory[:] = [] # = False |
| 43 device.PushChangedFiles(host_path, device_path) | 43 device.PushChangedFiles(host_path, device_path) |
| 44 | 44 |
| 45 record_path = '%s.%s.push.md5.stamp' % (host_path, serial_number) | 45 record_path = '%s.%s.push.md5.stamp' % (host_path, serial_number) |
| 46 md5_check.CallAndRecordIfStale( | 46 md5_check.CallAndRecordIfStale( |
| 47 Push, | 47 Push, |
| 48 record_path=record_path, | 48 record_path=record_path, |
| 49 input_paths=[host_path], | 49 input_paths=[host_path], |
| 50 input_strings=[device_path]) | 50 input_strings=[device_path]) |
| 51 | 51 |
| 52 | 52 |
| 53 def main(): | 53 def main(args): |
| 54 args = build_utils.ExpandFileArgs(args) |
| 54 parser = optparse.OptionParser() | 55 parser = optparse.OptionParser() |
| 55 parser.add_option('--libraries-dir', | 56 parser.add_option('--libraries-dir', |
| 56 help='Directory that contains stripped libraries.') | 57 help='Directory that contains stripped libraries.') |
| 57 parser.add_option('--device-dir', | 58 parser.add_option('--device-dir', |
| 58 help='Device directory to push the libraries to.') | 59 help='Device directory to push the libraries to.') |
| 59 parser.add_option('--libraries-json', | 60 parser.add_option('--libraries', |
| 60 help='Path to the json list of native libraries.') | 61 help='List of native libraries.') |
| 61 parser.add_option('--stamp', help='Path to touch on success.') | 62 parser.add_option('--stamp', help='Path to touch on success.') |
| 62 parser.add_option('--build-device-configuration', | 63 parser.add_option('--build-device-configuration', |
| 63 help='Path to build device configuration.') | 64 help='Path to build device configuration.') |
| 64 parser.add_option('--configuration-name', | 65 parser.add_option('--configuration-name', |
| 65 help='The build CONFIGURATION_NAME') | 66 help='The build CONFIGURATION_NAME') |
| 66 options, _ = parser.parse_args() | 67 options, _ = parser.parse_args(args) |
| 67 | 68 |
| 68 required_options = ['libraries_dir', 'device_dir', 'libraries_json'] | 69 required_options = ['libraries', 'device_dir', 'libraries'] |
| 69 build_utils.CheckOptions(options, parser, required=required_options) | 70 build_utils.CheckOptions(options, parser, required=required_options) |
| 70 constants.SetBuildType(options.configuration_name) | 71 constants.SetBuildType(options.configuration_name) |
| 71 | 72 |
| 72 DoPush(options) | 73 DoPush(options) |
| 73 | 74 |
| 74 if options.stamp: | 75 if options.stamp: |
| 75 build_utils.Touch(options.stamp) | 76 build_utils.Touch(options.stamp) |
| 76 | 77 |
| 77 | 78 |
| 78 if __name__ == '__main__': | 79 if __name__ == '__main__': |
| 79 sys.exit(main()) | 80 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |