Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # | |
| 3 # Copyright 2016 Google Inc. | |
| 4 # | |
| 5 # Use of this source code is governed by a BSD-style license that can be | |
| 6 # found in the LICENSE file. | |
| 7 | |
| 8 | |
| 9 """Isolate a locally-managed Android SDK.""" | |
| 10 | |
| 11 | |
| 12 import argparse | |
| 13 import os | |
| 14 import shlex | |
| 15 import shutil | |
| 16 import subprocess | |
| 17 import sys | |
| 18 import utils | |
| 19 | |
| 20 | |
| 21 ISOLATE_FILE_NAME = 'android_sdk.isolate' | |
| 22 REPO_SKIA = 'https://skia.googlesource.com/skia.git' | |
| 23 SDK_DIR_NAME = 'android-sdk' | |
| 24 | |
| 25 | |
| 26 def isolate_android_sdk(android_sdk_root): | |
| 27 """Isolate the Android SDK and return the isolated hash.""" | |
| 28 repo_isolate_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), | |
| 29 ISOLATE_FILE_NAME) | |
| 30 with utils.tmp_dir(): | |
| 31 # Copy the SDK dir contents into a directory with a known name. | |
| 32 sdk_dir = os.path.join(os.getcwd(), SDK_DIR_NAME) | |
| 33 shutil.copytree(android_sdk_root, sdk_dir) | |
| 34 isolate_file = os.path.join(os.getcwd(), ISOLATE_FILE_NAME) | |
| 35 shutil.copyfile(repo_isolate_file, isolate_file) | |
| 36 | |
| 37 # Isolate the SDK. | |
| 38 isolate = 'isolate' # TODO(borenet): Don't assume this is in PATH. | |
| 39 android_sdk_relpath = os.path.relpath( | |
| 40 sdk_dir, os.path.dirname(isolate_file)) | |
| 41 isolate_cmd = [isolate, 'archive', '--quiet', | |
|
kjlubick
2016/05/13 15:10:21
This command assumes you have authenticated with t
borenet
2016/05/13 15:15:17
Yes, and it assumes that you have the Go binary in
| |
| 42 '--isolate-server', 'https://isolateserver.appspot.com', | |
| 43 '-i', isolate_file, | |
| 44 '-s', 'android_sdk.isolated', | |
| 45 '--extra-variable', 'ANDROID_SDK_DIR=%s' % android_sdk_relpath] | |
| 46 isolate_out = subprocess.check_output(isolate_cmd).rstrip() | |
| 47 return shlex.split(isolate_out)[0] | |
| 48 | |
| 49 | |
| 50 | |
| 51 def update_sdk_file(skia_path, isolated_hash): | |
| 52 """Edit the android_sdk_hash file, upload a CL.""" | |
| 53 with utils.chdir(skia_path): | |
| 54 with utils.git_branch(): | |
| 55 hash_file = os.path.join('infra', 'bots', 'android_sdk_hash') | |
| 56 with open(hash_file, 'w') as f: | |
| 57 f.write(isolated_hash) | |
| 58 subprocess.check_call([utils.GIT, 'add', hash_file]) | |
| 59 subprocess.check_call([utils.GIT, 'commit', '-m', 'Update Android SDK']) | |
| 60 subprocess.check_call([utils.GIT, 'cl', 'upload', '--bypass-hooks']) | |
| 61 | |
| 62 | |
| 63 def main(): | |
| 64 parser = argparse.ArgumentParser() | |
| 65 parser.add_argument('--android_sdk_root', required=True) | |
| 66 args = parser.parse_args() | |
| 67 skia_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), | |
| 68 os.pardir, os.pardir) | |
| 69 | |
| 70 with utils.print_timings(): | |
| 71 isolated_hash = isolate_android_sdk(args.android_sdk_root) | |
| 72 update_sdk_file(skia_path, isolated_hash) | |
| 73 | |
| 74 | |
| 75 if __name__ == '__main__': | |
| 76 main() | |
| OLD | NEW |