Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: infra/bots/isolate_win_toolchain.py

Issue 2111713003: Convert Win toolchain to CIPD package (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: New, stripped down, toolchain Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « infra/bots/assets/win_toolchain/upload.py ('k') | infra/bots/win_toolchain.isolate » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 """Download an updated VS toolchain, isolate it, upload a CL to update Skia."""
10
11
12 import argparse
13 import json
14 import os
15 import shlex
16 import shutil
17 import subprocess
18 import sys
19 import utils
20
21 import win_toolchain_utils
22
23
24 REPO_CHROME = 'https://chromium.googlesource.com/chromium/src.git'
25 REPO_SKIA = 'https://skia.googlesource.com/skia.git'
26
27
28 def get_toolchain_dir(toolchain_dir_output):
29 """Find the toolchain directory."""
30 prefix = 'vs_path = '
31 for line in toolchain_dir_output.splitlines():
32 if line.startswith(prefix):
33 return line[len(prefix):].strip('"')
34 raise Exception('Unable to find toolchain dir in output:\n%s' % (
35 toolchain_dir_output))
36
37
38 def gen_toolchain(chrome_path, msvs_version, isolate_file):
39 """Update the VS toolchain, isolate it, and return the isolated hash."""
40 with utils.chdir(chrome_path):
41 subprocess.check_call([utils.GCLIENT, 'sync'])
42 depot_tools = subprocess.check_output([
43 'python', os.path.join('build', 'find_depot_tools.py')]).rstrip()
44 with utils.git_branch():
45 vs_toolchain_py = os.path.join('build', 'vs_toolchain.py')
46 env = os.environ.copy()
47 env['GYP_MSVS_VERSION'] = msvs_version
48 subprocess.check_call(['python', vs_toolchain_py, 'update'], env=env)
49 output = subprocess.check_output(['python', vs_toolchain_py,
50 'get_toolchain_dir'], env=env).rstrip()
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))
55
56 # Isolate the toolchain. Assumes we're running on Windows, since the above
57 # would fail otherwise.
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)
62 isolate = os.path.join(
63 os.curdir, 'tools', 'luci-go', 'win64', 'isolate.exe')
64 isolate_cmd = [isolate, 'archive', '--quiet',
65 '--isolate-server', 'https://isolateserver.appspot.com',
66 '-i', isolate_file,
67 '-s', 'win_toolchain_%s.isolated' % msvs_version,
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]
71 isolate_out = subprocess.check_output(isolate_cmd).rstrip()
72 return shlex.split(isolate_out)[0]
73
74
75 def update_toolchain_file(skia_path, msvs_version, isolated_hash):
76 """Edit the win_toolchain_hash file, upload a CL."""
77 with utils.chdir(skia_path):
78 with utils.git_branch():
79 hash_file = os.path.join('infra', 'bots', 'win_toolchain_hash.json')
80 with open(hash_file) as f:
81 hashes = json.load(f)
82 hashes[msvs_version] = isolated_hash
83 with open(hash_file, 'w') as f:
84 json.dump(hashes, f, indent=4, sort_keys=True)
85 subprocess.check_call([utils.GIT, 'add', hash_file])
86 subprocess.check_call([utils.GIT, 'commit', '-m', 'Update Win toolchain'])
87 subprocess.check_call([utils.GIT, 'cl', 'upload', '--bypass-hooks'])
88
89
90 def main():
91 parser = argparse.ArgumentParser()
92 parser.add_argument('--msvs_version', required=True)
93 parser.add_argument('--chrome_path')
94 parser.add_argument('--skia_path')
95 args = parser.parse_args()
96
97 isolate_file = os.path.join(os.path.dirname(os.path.realpath(__file__)),
98 'win_toolchain.isolate')
99
100 with utils.print_timings():
101 with utils.tmp_dir() as tmp_dir:
102 chrome_path = args.chrome_path
103 if not chrome_path:
104 print ('Syncing Chrome from scratch. If you already have a checkout, '
105 'specify --chrome_path to save time.')
106 chrome_path = os.path.join(tmp_dir.name, 'src')
107 if not os.path.isdir(chrome_path):
108 utils.git_clone(REPO_CHROME, chrome_path)
109
110 skia_path = args.skia_path
111 if not skia_path:
112 print ('Syncing Skia from scratch. If you already have a checkout, '
113 'specify --chrome_path to save time.')
114 skia_path = os.path.join(tmp_dir.name, 'skia')
115 if not os.path.isdir(skia_path):
116 utils.git_clone(REPO_SKIA, skia_path)
117
118 isolated_hash = gen_toolchain(chrome_path, args.msvs_version,
119 isolate_file)
120 update_toolchain_file(skia_path, args.msvs_version, isolated_hash)
121
122
123 if __name__ == '__main__':
124 main()
OLDNEW
« no previous file with comments | « infra/bots/assets/win_toolchain/upload.py ('k') | infra/bots/win_toolchain.isolate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698