| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2016 Google Inc. | 3 # Copyright 2016 Google Inc. |
| 4 # | 4 # |
| 5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
| 6 # found in the LICENSE file. | 6 # found in the LICENSE file. |
| 7 | 7 |
| 8 | 8 |
| 9 """Download an updated VS toolchain, isolate it, upload a CL to update Skia.""" |
| 10 |
| 11 |
| 9 import argparse | 12 import argparse |
| 10 import json | 13 import json |
| 11 import os | 14 import os |
| 12 import shlex | 15 import shlex |
| 13 import shutil | 16 import shutil |
| 14 import subprocess | 17 import subprocess |
| 15 import sys | 18 import sys |
| 16 import utils | 19 import utils |
| 17 | 20 |
| 21 import win_toolchain_utils |
| 22 |
| 18 | 23 |
| 19 REPO_CHROME = 'https://chromium.googlesource.com/chromium/src.git' | 24 REPO_CHROME = 'https://chromium.googlesource.com/chromium/src.git' |
| 20 REPO_SKIA = 'https://skia.googlesource.com/skia.git' | 25 REPO_SKIA = 'https://skia.googlesource.com/skia.git' |
| 21 | 26 |
| 22 | 27 |
| 23 def get_toolchain_dir(toolchain_dir_output): | 28 def get_toolchain_dir(toolchain_dir_output): |
| 24 """Find the toolchain directory.""" | 29 """Find the toolchain directory.""" |
| 25 prefix = 'vs_path = ' | 30 prefix = 'vs_path = ' |
| 26 for line in toolchain_dir_output.splitlines(): | 31 for line in toolchain_dir_output.splitlines(): |
| 27 if line.startswith(prefix): | 32 if line.startswith(prefix): |
| 28 return line[len(prefix):].strip('"') | 33 return line[len(prefix):].strip('"') |
| 29 raise Exception('Unable to find toolchain dir in output:\n%s' % ( | 34 raise Exception('Unable to find toolchain dir in output:\n%s' % ( |
| 30 toolchain_dir_output)) | 35 toolchain_dir_output)) |
| 31 | 36 |
| 32 | 37 |
| 33 def gen_toolchain(chrome_path, msvs_version, isolate_file): | 38 def gen_toolchain(chrome_path, msvs_version, isolate_file): |
| 34 """Update the VS toolchain, isolate it, and return the isolated hash.""" | 39 """Update the VS toolchain, isolate it, and return the isolated hash.""" |
| 35 with utils.chdir(chrome_path): | 40 with utils.chdir(chrome_path): |
| 36 subprocess.check_call([utils.GCLIENT, 'sync']) | 41 subprocess.check_call([utils.GCLIENT, 'sync']) |
| 42 depot_tools = subprocess.check_output([ |
| 43 'python', os.path.join('build', 'find_depot_tools.py')]).rstrip() |
| 37 with utils.git_branch(): | 44 with utils.git_branch(): |
| 38 vs_toolchain_py = os.path.join('build', 'vs_toolchain.py') | 45 vs_toolchain_py = os.path.join('build', 'vs_toolchain.py') |
| 39 env = os.environ.copy() | 46 env = os.environ.copy() |
| 40 env['GYP_MSVS_VERSION'] = msvs_version | 47 env['GYP_MSVS_VERSION'] = msvs_version |
| 41 subprocess.check_call(['python', vs_toolchain_py, 'update'], env=env) | 48 subprocess.check_call(['python', vs_toolchain_py, 'update'], env=env) |
| 42 output = subprocess.check_output(['python', vs_toolchain_py, | 49 output = subprocess.check_output(['python', vs_toolchain_py, |
| 43 'get_toolchain_dir'], env=env).rstrip() | 50 'get_toolchain_dir'], env=env).rstrip() |
| 44 src_dir = get_toolchain_dir(output) | 51 src_dir = get_toolchain_dir(output) |
| 52 # Mock out absolute paths in win_toolchain.json. |
| 53 win_toolchain_utils.abstract(os.path.join('build', 'win_toolchain.json'), |
| 54 os.path.dirname(depot_tools)) |
| 45 | 55 |
| 46 # Isolate the toolchain. Assumes we're running on Windows, since the above | 56 # Isolate the toolchain. Assumes we're running on Windows, since the above |
| 47 # would fail otherwise. | 57 # would fail otherwise. |
| 48 rel_path = os.path.relpath(src_dir, os.path.dirname(isolate_file)) | 58 isolate_file_dirname = os.path.dirname(isolate_file) |
| 59 toolchain_relpath = os.path.relpath(src_dir, isolate_file_dirname) |
| 60 chrome_relpath = os.path.relpath(os.getcwd(), isolate_file_dirname) |
| 61 depot_tools_relpath = os.path.relpath(depot_tools, isolate_file_dirname) |
| 49 isolate = os.path.join( | 62 isolate = os.path.join( |
| 50 os.curdir, 'tools', 'luci-go', 'win64', 'isolate.exe') | 63 os.curdir, 'tools', 'luci-go', 'win64', 'isolate.exe') |
| 51 isolate_cmd = [isolate, 'archive', '--quiet', | 64 isolate_cmd = [isolate, 'archive', '--quiet', |
| 52 '--isolate-server', 'https://isolateserver.appspot.com', | 65 '--isolate-server', 'https://isolateserver.appspot.com', |
| 53 '-i', isolate_file, | 66 '-i', isolate_file, |
| 54 '-s', 'win_toolchain_%s.isolated' % msvs_version, | 67 '-s', 'win_toolchain_%s.isolated' % msvs_version, |
| 55 '--extra-variable', 'WIN_TOOLCHAIN_DIR=%s' % rel_path] | 68 '--extra-variable', 'WIN_TOOLCHAIN_DIR=%s' % toolchain_relpath, |
| 69 '--extra-variable', 'DEPOT_TOOLS_DIR=%s' % depot_tools_relpath, |
| 70 '--extra-variable', 'CHROME_DIR=%s' % chrome_relpath] |
| 56 isolate_out = subprocess.check_output(isolate_cmd).rstrip() | 71 isolate_out = subprocess.check_output(isolate_cmd).rstrip() |
| 57 return shlex.split(isolate_out)[0] | 72 return shlex.split(isolate_out)[0] |
| 58 | 73 |
| 59 | 74 |
| 60 def update_toolchain_file(skia_path, msvs_version, isolated_hash): | 75 def update_toolchain_file(skia_path, msvs_version, isolated_hash): |
| 61 """Edit the win_toolchain_hash file, upload a CL.""" | 76 """Edit the win_toolchain_hash file, upload a CL.""" |
| 62 with utils.chdir(skia_path): | 77 with utils.chdir(skia_path): |
| 63 with utils.git_branch(): | 78 with utils.git_branch(): |
| 64 hash_file = os.path.join('infra', 'bots', 'win_toolchain_hash.json') | 79 hash_file = os.path.join('infra', 'bots', 'win_toolchain_hash.json') |
| 65 with open(hash_file) as f: | 80 with open(hash_file) as f: |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 if not os.path.isdir(skia_path): | 115 if not os.path.isdir(skia_path): |
| 101 utils.git_clone(REPO_SKIA, skia_path) | 116 utils.git_clone(REPO_SKIA, skia_path) |
| 102 | 117 |
| 103 isolated_hash = gen_toolchain(chrome_path, args.msvs_version, | 118 isolated_hash = gen_toolchain(chrome_path, args.msvs_version, |
| 104 isolate_file) | 119 isolate_file) |
| 105 update_toolchain_file(skia_path, args.msvs_version, isolated_hash) | 120 update_toolchain_file(skia_path, args.msvs_version, isolated_hash) |
| 106 | 121 |
| 107 | 122 |
| 108 if __name__ == '__main__': | 123 if __name__ == '__main__': |
| 109 main() | 124 main() |
| OLD | NEW |