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 """Creates symlinks to native libraries for an APK. | 7 """Creates symlinks to native libraries for an APK. |
8 | 8 |
9 The native libraries should have previously been pushed to the device (in | 9 The native libraries should have previously been pushed to the device (in |
10 options.target_dir). This script then creates links in an apk's lib/ folder to | 10 options.target_dir). This script then creates links in an apk's lib/ folder to |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 | 41 |
42 def CreateLinks(options): | 42 def CreateLinks(options): |
43 libraries = build_utils.ReadJson(options.libraries_json) | 43 libraries = build_utils.ReadJson(options.libraries_json) |
44 apk_package = apk_helper.GetPackageName(options.apk) | 44 apk_package = apk_helper.GetPackageName(options.apk) |
45 | 45 |
46 adb = android_commands.AndroidCommands() | 46 adb = android_commands.AndroidCommands() |
47 serial_number = adb.Adb().GetSerialNumber() | 47 serial_number = adb.Adb().GetSerialNumber() |
48 for lib in libraries: | 48 for lib in libraries: |
49 host_path = os.path.join(options.libraries_dir, lib) | 49 host_path = os.path.join(options.libraries_dir, lib) |
50 | 50 def CreateLink(): |
51 md5_stamp = '%s.%s.link.md5' % (host_path, serial_number) | |
52 md5_checker = md5_check.Md5Checker(stamp=md5_stamp, inputs=[host_path]) | |
53 if md5_checker.IsStale(): | |
54 link = '/data/data/' + apk_package + '/lib/' + lib | 51 link = '/data/data/' + apk_package + '/lib/' + lib |
55 target = options.target_dir + '/' + lib | 52 target = options.target_dir + '/' + lib |
56 RunLinkCommand(adb, target, link) | 53 RunLinkCommand(adb, target, link) |
57 md5_checker.Write() | 54 |
| 55 record_path = '%s.%s.link.md5.stamp' % (host_path, serial_number) |
| 56 md5_check.CallAndRecordIfStale( |
| 57 CreateLink, |
| 58 record_path=record_path, |
| 59 input_paths=[host_path]) |
58 | 60 |
59 | 61 |
60 def main(argv): | 62 def main(argv): |
61 parser = optparse.OptionParser() | 63 parser = optparse.OptionParser() |
62 parser.add_option('--apk', help='Path to the apk.') | 64 parser.add_option('--apk', help='Path to the apk.') |
63 parser.add_option('--libraries-json', | 65 parser.add_option('--libraries-json', |
64 help='Path to the json list of native libraries.') | 66 help='Path to the json list of native libraries.') |
65 parser.add_option('--target-dir', | 67 parser.add_option('--target-dir', |
66 help='Device directory that contains the target libraries for symlinks.') | 68 help='Device directory that contains the target libraries for symlinks.') |
67 parser.add_option('--libraries-dir', | 69 parser.add_option('--libraries-dir', |
68 help='Directory that contains stripped libraries ' | 70 help='Directory that contains stripped libraries ' |
69 '(used to determine if a library has changed since last push).') | 71 '(used to determine if a library has changed since last push).') |
70 parser.add_option('--stamp', help='Path to touch on success.') | 72 parser.add_option('--stamp', help='Path to touch on success.') |
71 options, _ = parser.parse_args() | 73 options, _ = parser.parse_args() |
72 | 74 |
73 required_options = ['apk', 'libraries_json', 'target_dir', 'libraries_dir'] | 75 required_options = ['apk', 'libraries_json', 'target_dir', 'libraries_dir'] |
74 build_utils.CheckOptions(options, parser, required=required_options) | 76 build_utils.CheckOptions(options, parser, required=required_options) |
75 | 77 |
76 CreateLinks(options) | 78 CreateLinks(options) |
77 | 79 |
78 if options.stamp: | 80 if options.stamp: |
79 build_utils.Touch(options.stamp) | 81 build_utils.Touch(options.stamp) |
80 | 82 |
81 | 83 |
82 if __name__ == '__main__': | 84 if __name__ == '__main__': |
83 sys.exit(main(sys.argv)) | 85 sys.exit(main(sys.argv)) |
OLD | NEW |