| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 with open(options.script_host_path, 'w') as scriptfile: | 52 with open(options.script_host_path, 'w') as scriptfile: |
| 53 scriptfile.write(script) | 53 scriptfile.write(script) |
| 54 | 54 |
| 55 | 55 |
| 56 def TriggerSymlinkScript(options): | 56 def TriggerSymlinkScript(options): |
| 57 device = build_device.GetBuildDeviceFromPath( | 57 device = build_device.GetBuildDeviceFromPath( |
| 58 options.build_device_configuration) | 58 options.build_device_configuration) |
| 59 if not device: | 59 if not device: |
| 60 return | 60 return |
| 61 | 61 |
| 62 apk_package = apk_helper.GetPackageName(options.apk) | 62 apk_package = apk_helper.GetPackageName(options.android_sdk_tools, |
| 63 options.apk_path) |
| 63 apk_libraries_dir = '/data/data/%s/lib' % apk_package | 64 apk_libraries_dir = '/data/data/%s/lib' % apk_package |
| 64 | 65 |
| 65 device_dir = os.path.dirname(options.script_device_path) | 66 device_dir = os.path.dirname(options.script_device_path) |
| 66 mkdir_cmd = ('if [ ! -e %(dir)s ]; then mkdir -p %(dir)s; fi ' % | 67 mkdir_cmd = ('if [ ! -e %(dir)s ]; then mkdir -p %(dir)s; fi ' % |
| 67 { 'dir': device_dir }) | 68 { 'dir': device_dir }) |
| 68 RunShellCommand(device, mkdir_cmd) | 69 RunShellCommand(device, mkdir_cmd) |
| 69 device.PushIfNeeded(options.script_host_path, options.script_device_path) | 70 device.PushIfNeeded(options.script_host_path, options.script_device_path) |
| 70 | 71 |
| 71 trigger_cmd = ( | 72 trigger_cmd = ( |
| 72 'APK_LIBRARIES_DIR=%(apk_libraries_dir)s; ' | 73 'APK_LIBRARIES_DIR=%(apk_libraries_dir)s; ' |
| 73 'STRIPPED_LIBRARIES_DIR=%(target_dir)s; ' | 74 'STRIPPED_LIBRARIES_DIR=%(target_dir)s; ' |
| 74 '. %(script_device_path)s' | 75 '. %(script_device_path)s' |
| 75 ) % { | 76 ) % { |
| 76 'apk_libraries_dir': apk_libraries_dir, | 77 'apk_libraries_dir': apk_libraries_dir, |
| 77 'target_dir': options.target_dir, | 78 'target_dir': options.target_dir, |
| 78 'script_device_path': options.script_device_path | 79 'script_device_path': options.script_device_path |
| 79 } | 80 } |
| 80 RunShellCommand(device, trigger_cmd) | 81 RunShellCommand(device, trigger_cmd) |
| 81 | 82 |
| 82 | 83 |
| 83 def main(argv): | 84 def main(argv): |
| 84 parser = optparse.OptionParser() | 85 parser = optparse.OptionParser() |
| 86 parser.add_option('--android-sdk-tools', |
| 87 help='path to the Android SDK build tools folder') |
| 85 parser.add_option('--apk', help='Path to the apk.') | 88 parser.add_option('--apk', help='Path to the apk.') |
| 86 parser.add_option('--script-host-path', | 89 parser.add_option('--script-host-path', |
| 87 help='Path on the host for the symlink script.') | 90 help='Path on the host for the symlink script.') |
| 88 parser.add_option('--script-device-path', | 91 parser.add_option('--script-device-path', |
| 89 help='Path on the device to push the created symlink script.') | 92 help='Path on the device to push the created symlink script.') |
| 90 parser.add_option('--libraries-json', | 93 parser.add_option('--libraries-json', |
| 91 help='Path to the json list of native libraries.') | 94 help='Path to the json list of native libraries.') |
| 92 parser.add_option('--target-dir', | 95 parser.add_option('--target-dir', |
| 93 help='Device directory that contains the target libraries for symlinks.') | 96 help='Device directory that contains the target libraries for symlinks.') |
| 94 parser.add_option('--stamp', help='Path to touch on success.') | 97 parser.add_option('--stamp', help='Path to touch on success.') |
| (...skipping 10 matching lines...) Expand all Loading... |
| 105 | 108 |
| 106 CreateSymlinkScript(options) | 109 CreateSymlinkScript(options) |
| 107 TriggerSymlinkScript(options) | 110 TriggerSymlinkScript(options) |
| 108 | 111 |
| 109 if options.stamp: | 112 if options.stamp: |
| 110 build_utils.Touch(options.stamp) | 113 build_utils.Touch(options.stamp) |
| 111 | 114 |
| 112 | 115 |
| 113 if __name__ == '__main__': | 116 if __name__ == '__main__': |
| 114 sys.exit(main(sys.argv)) | 117 sys.exit(main(sys.argv)) |
| OLD | NEW |