Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: build/android/gyp/push_libraries.py

Issue 16831013: [Android] Add an action to check/record attached devices (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Blah Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « build/android/gyp/get_device_configuration.py ('k') | build/android/gyp/util/build_device.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 build_device
16 from util import build_utils 17 from util import build_utils
17 from util import md5_check 18 from util import md5_check
18 19
19 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..')
20 sys.path.append(BUILD_ANDROID_DIR)
21
22 from pylib import android_commands
23
24
25 def DoPush(options): 20 def DoPush(options):
26 libraries = build_utils.ReadJson(options.libraries_json) 21 libraries = build_utils.ReadJson(options.libraries_json)
27 22
28 adb = android_commands.AndroidCommands() 23 device = build_device.GetBuildDeviceFromPath(
29 serial_number = adb.Adb().GetSerialNumber() 24 options.build_device_configuration)
25 if not device:
26 return
27
28 serial_number = device.GetSerialNumber()
30 # A list so that it is modifiable in Push below. 29 # A list so that it is modifiable in Push below.
31 needs_directory = [True] 30 needs_directory = [True]
32 for lib in libraries: 31 for lib in libraries:
33 device_path = os.path.join(options.device_dir, lib) 32 device_path = os.path.join(options.device_dir, lib)
34 host_path = os.path.join(options.libraries_dir, lib) 33 host_path = os.path.join(options.libraries_dir, lib)
35 34
36 def Push(): 35 def Push():
37 if needs_directory: 36 if needs_directory:
38 adb.RunShellCommand('mkdir -p ' + options.device_dir) 37 device.RunShellCommand('mkdir -p ' + options.device_dir)
39 needs_directory[:] = [] # = False 38 needs_directory[:] = [] # = False
40 adb.PushIfNeeded(host_path, device_path) 39 device.PushIfNeeded(host_path, device_path)
41 40
42 record_path = '%s.%s.push.md5.stamp' % (host_path, serial_number) 41 record_path = '%s.%s.push.md5.stamp' % (host_path, serial_number)
43 md5_check.CallAndRecordIfStale( 42 md5_check.CallAndRecordIfStale(
44 Push, 43 Push,
45 record_path=record_path, 44 record_path=record_path,
46 input_paths=[host_path], 45 input_paths=[host_path],
47 input_strings=[device_path]) 46 input_strings=[device_path])
48 47
49 48
50 def main(argv): 49 def main(argv):
51 if not build_utils.IsDeviceReady():
52 build_utils.PrintBigWarning(
53 'Zero (or multiple) devices attached. Skipping native library push.')
54 return
55
56 parser = optparse.OptionParser() 50 parser = optparse.OptionParser()
57 parser.add_option('--libraries-dir', 51 parser.add_option('--libraries-dir',
58 help='Directory that contains stripped libraries.') 52 help='Directory that contains stripped libraries.')
59 parser.add_option('--device-dir', 53 parser.add_option('--device-dir',
60 help='Device directory to push the libraries to.') 54 help='Device directory to push the libraries to.')
61 parser.add_option('--libraries-json', 55 parser.add_option('--libraries-json',
62 help='Path to the json list of native libraries.') 56 help='Path to the json list of native libraries.')
63 parser.add_option('--stamp', help='Path to touch on success.') 57 parser.add_option('--stamp', help='Path to touch on success.')
58 parser.add_option('--build-device-configuration',
59 help='Path to build device configuration.')
64 options, _ = parser.parse_args() 60 options, _ = parser.parse_args()
65 61
66 required_options = ['libraries_dir', 'device_dir', 'libraries_json'] 62 required_options = ['libraries_dir', 'device_dir', 'libraries_json']
67 build_utils.CheckOptions(options, parser, required=required_options) 63 build_utils.CheckOptions(options, parser, required=required_options)
68 64
69 DoPush(options) 65 DoPush(options)
70 66
71 if options.stamp: 67 if options.stamp:
72 build_utils.Touch(options.stamp) 68 build_utils.Touch(options.stamp)
73 69
74 70
75 if __name__ == '__main__': 71 if __name__ == '__main__':
76 sys.exit(main(sys.argv)) 72 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « build/android/gyp/get_device_configuration.py ('k') | build/android/gyp/util/build_device.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698