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 optparse | 12 import optparse |
12 import os | 13 import os |
13 import sys | 14 import sys |
14 | 15 |
15 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), os.pardir) | 16 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), os.pardir) |
16 sys.path.append(BUILD_ANDROID_DIR) | 17 sys.path.append(BUILD_ANDROID_DIR) |
17 | 18 |
18 from pylib import constants | 19 from pylib import constants |
19 | 20 |
20 # pylint: disable=F0401 | |
21 from util import build_device | 21 from util import build_device |
22 from util import build_utils | 22 from util import build_utils |
23 from util import md5_check | 23 from util import md5_check |
24 # pylint: disable=F0401 | |
25 | 24 |
26 def DoPush(options): | 25 def DoPush(options): |
27 libraries = build_utils.ReadJson(options.libraries_json) | 26 libraries = build_utils.ReadJson(options.libraries_json) |
28 | 27 |
29 device = build_device.GetBuildDeviceFromPath( | 28 device = build_device.GetBuildDeviceFromPath( |
30 options.build_device_configuration) | 29 options.build_device_configuration) |
31 if not device: | 30 if not device: |
32 return | 31 return |
33 | 32 |
34 serial_number = device.GetSerialNumber() | 33 serial_number = device.GetSerialNumber() |
(...skipping 10 matching lines...) Expand all Loading... |
45 device.PushIfNeeded(host_path, device_path) | 44 device.PushIfNeeded(host_path, device_path) |
46 | 45 |
47 record_path = '%s.%s.push.md5.stamp' % (host_path, serial_number) | 46 record_path = '%s.%s.push.md5.stamp' % (host_path, serial_number) |
48 md5_check.CallAndRecordIfStale( | 47 md5_check.CallAndRecordIfStale( |
49 Push, | 48 Push, |
50 record_path=record_path, | 49 record_path=record_path, |
51 input_paths=[host_path], | 50 input_paths=[host_path], |
52 input_strings=[device_path]) | 51 input_strings=[device_path]) |
53 | 52 |
54 | 53 |
55 def main(): | 54 def main(argv): |
56 parser = optparse.OptionParser() | 55 parser = optparse.OptionParser() |
57 parser.add_option('--libraries-dir', | 56 parser.add_option('--libraries-dir', |
58 help='Directory that contains stripped libraries.') | 57 help='Directory that contains stripped libraries.') |
59 parser.add_option('--device-dir', | 58 parser.add_option('--device-dir', |
60 help='Device directory to push the libraries to.') | 59 help='Device directory to push the libraries to.') |
61 parser.add_option('--libraries-json', | 60 parser.add_option('--libraries-json', |
62 help='Path to the json list of native libraries.') | 61 help='Path to the json list of native libraries.') |
63 parser.add_option('--stamp', help='Path to touch on success.') | 62 parser.add_option('--stamp', help='Path to touch on success.') |
64 parser.add_option('--build-device-configuration', | 63 parser.add_option('--build-device-configuration', |
65 help='Path to build device configuration.') | 64 help='Path to build device configuration.') |
66 parser.add_option('--configuration-name', | 65 parser.add_option('--configuration-name', |
67 help='The build CONFIGURATION_NAME') | 66 help='The build CONFIGURATION_NAME') |
68 options, _ = parser.parse_args() | 67 options, _ = parser.parse_args() |
69 | 68 |
70 required_options = ['libraries_dir', 'device_dir', 'libraries_json'] | 69 required_options = ['libraries_dir', 'device_dir', 'libraries_json'] |
71 build_utils.CheckOptions(options, parser, required=required_options) | 70 build_utils.CheckOptions(options, parser, required=required_options) |
72 constants.SetBuildType(options.configuration_name) | 71 constants.SetBuildType(options.configuration_name) |
73 | 72 |
74 DoPush(options) | 73 DoPush(options) |
75 | 74 |
76 if options.stamp: | 75 if options.stamp: |
77 build_utils.Touch(options.stamp) | 76 build_utils.Touch(options.stamp) |
78 | 77 |
79 | 78 |
80 if __name__ == '__main__': | 79 if __name__ == '__main__': |
81 sys.exit(main()) | 80 sys.exit(main(sys.argv)) |
OLD | NEW |