Index: build/android/gyp/create_device_library_links.py |
diff --git a/build/android/gyp/create_device_library_links.py b/build/android/gyp/create_device_library_links.py |
index b6b6742426448c512b289fa18b15aa80819b1b93..e71f72729cb90bf2eee3498bb27c2b79c170756a 100755 |
--- a/build/android/gyp/create_device_library_links.py |
+++ b/build/android/gyp/create_device_library_links.py |
@@ -17,6 +17,7 @@ import os |
import sys |
from util import build_utils |
+from util import md5_check |
BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..') |
sys.path.append(BUILD_ANDROID_DIR) |
@@ -25,23 +26,11 @@ from pylib import android_commands |
from pylib.utils import apk_helper |
-def CreateLinks(options): |
- libraries = build_utils.ReadJson(options.libraries_json) |
- apk_package = apk_helper.GetPackageName(options.apk) |
- |
- # There is a large (~100ms) overhead for each call to adb.RunShellCommand. To |
- # avoid this overhead, craft a single command that creates all the links. |
- link = '/data/data/' + apk_package + '/lib/$f' |
- target = options.target_dir + '/$f' |
- names = ' '.join(libraries) |
+def RunLinkCommand(adb, target, link): |
cmd = ( |
- 'for f in ' + names + '; do \n' + |
- 'rm ' + link + ' > /dev/null 2>&1 \n' + |
- 'ln -s ' + target + ' ' + link + '\n' + |
- 'done' |
+ 'rm ' + link + ' > /dev/null 2>&1 \n' |
+ 'ln -s ' + target + ' ' + link + '\n' |
) |
- |
- adb = android_commands.AndroidCommands() |
result = adb.RunShellCommand(cmd) |
if result: |
@@ -50,6 +39,24 @@ def CreateLinks(options): |
'\n'.join(result)) |
+def CreateLinks(options): |
+ libraries = build_utils.ReadJson(options.libraries_json) |
+ apk_package = apk_helper.GetPackageName(options.apk) |
+ |
+ adb = android_commands.AndroidCommands() |
+ serial_number = adb.Adb().GetSerialNumber() |
+ for lib in libraries: |
+ host_path = os.path.join(options.libraries_dir, lib) |
+ |
+ md5_stamp = '%s.%s.link.md5' % (host_path, serial_number) |
+ md5_checker = md5_check.Md5Checker(stamp=md5_stamp, inputs=[host_path]) |
+ if md5_checker.IsStale(): |
+ link = '/data/data/' + apk_package + '/lib/' + lib |
+ target = options.target_dir + '/' + lib |
+ RunLinkCommand(adb, target, link) |
+ md5_checker.Write() |
+ |
+ |
def main(argv): |
parser = optparse.OptionParser() |
parser.add_option('--apk', help='Path to the apk.') |
@@ -57,10 +64,13 @@ def main(argv): |
help='Path to the json list of native libraries.') |
parser.add_option('--target-dir', |
help='Device directory that contains the target libraries for symlinks.') |
+ parser.add_option('--libraries-dir', |
+ help='Directory that contains stripped libraries ' |
+ '(used to determine if a library has changed since last push).') |
parser.add_option('--stamp', help='Path to touch on success.') |
options, _ = parser.parse_args() |
- required_options = ['apk', 'libraries_json', 'target_dir'] |
+ required_options = ['apk', 'libraries_json', 'target_dir', 'libraries_dir'] |
build_utils.CheckOptions(options, parser, required=required_options) |
CreateLinks(options) |