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

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

Issue 14263006: [Android] Refactor md5_check + add tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@java_toc
Patch Set: Rebase Created 7 years, 8 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
« no previous file with comments | « build/android/gyp/javac.py ('k') | build/android/gyp/util/md5_check.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_utils 16 from util import build_utils
17 from util import md5_check 17 from util import md5_check
18 18
19 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..') 19 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..')
20 sys.path.append(BUILD_ANDROID_DIR) 20 sys.path.append(BUILD_ANDROID_DIR)
21 21
22 from pylib import android_commands 22 from pylib import android_commands
23 23
24 24
25 def DoPush(options): 25 def DoPush(options):
26 libraries = build_utils.ReadJson(options.libraries_json) 26 libraries = build_utils.ReadJson(options.libraries_json)
27 27
28 adb = android_commands.AndroidCommands() 28 adb = android_commands.AndroidCommands()
29 serial_number = adb.Adb().GetSerialNumber() 29 serial_number = adb.Adb().GetSerialNumber()
30 needs_directory = True 30 # A list so that it is modifiable in Push below.
31 needs_directory = [True]
31 for lib in libraries: 32 for lib in libraries:
32 device_path = os.path.join(options.device_dir, lib) 33 device_path = os.path.join(options.device_dir, lib)
33 host_path = os.path.join(options.libraries_dir, lib) 34 host_path = os.path.join(options.libraries_dir, lib)
34 35
35 md5_stamp = '%s.%s.push.md5' % (host_path, serial_number) 36 def Push():
36 md5_checker = md5_check.Md5Checker(stamp=md5_stamp, inputs=[host_path])
37 if md5_checker.IsStale():
38 if needs_directory: 37 if needs_directory:
39 adb.RunShellCommand('mkdir ' + options.device_dir) 38 adb.RunShellCommand('mkdir ' + options.device_dir)
40 needs_directory = False 39 needs_directory[:] = [] # = False
41 adb.PushIfNeeded(host_path, device_path) 40 adb.PushIfNeeded(host_path, device_path)
42 md5_checker.Write() 41
42 record_path = '%s.%s.push.md5.stamp' % (host_path, serial_number)
43 md5_check.CallAndRecordIfStale(
44 Push, record_path=record_path, input_paths=[host_path])
43 45
44 46
45 def main(argv): 47 def main(argv):
46 parser = optparse.OptionParser() 48 parser = optparse.OptionParser()
47 parser.add_option('--libraries-dir', 49 parser.add_option('--libraries-dir',
48 help='Directory that contains stripped libraries.') 50 help='Directory that contains stripped libraries.')
49 parser.add_option('--device-dir', 51 parser.add_option('--device-dir',
50 help='Device directory to push the libraries to.') 52 help='Device directory to push the libraries to.')
51 parser.add_option('--libraries-json', 53 parser.add_option('--libraries-json',
52 help='Path to the json list of native libraries.') 54 help='Path to the json list of native libraries.')
53 parser.add_option('--stamp', help='Path to touch on success.') 55 parser.add_option('--stamp', help='Path to touch on success.')
54 options, _ = parser.parse_args() 56 options, _ = parser.parse_args()
55 57
56 required_options = ['libraries_dir', 'device_dir', 'libraries_json'] 58 required_options = ['libraries_dir', 'device_dir', 'libraries_json']
57 build_utils.CheckOptions(options, parser, required=required_options) 59 build_utils.CheckOptions(options, parser, required=required_options)
58 60
59 DoPush(options) 61 DoPush(options)
60 62
61 if options.stamp: 63 if options.stamp:
62 build_utils.Touch(options.stamp) 64 build_utils.Touch(options.stamp)
63 65
64 66
65 if __name__ == '__main__': 67 if __name__ == '__main__':
66 sys.exit(main(sys.argv)) 68 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « build/android/gyp/javac.py ('k') | build/android/gyp/util/md5_check.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698