Fixes for Win toolchain isolate
NOTRY=true BUG=skia:4763, skia:4553 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1782943002 Review URL: https://codereview.chromium.org/1782943002
This commit is contained in:
parent
7fb4f8bd03
commit
2f56b1aba2
26
infra/bots/bootstrap_win_toolchain_json.py
Normal file
26
infra/bots/bootstrap_win_toolchain_json.py
Normal file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2016 Google Inc.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
|
||||
"""Resolve the path placeholders in the win_toolchain.json file."""
|
||||
|
||||
|
||||
import argparse
|
||||
import win_toolchain_utils
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--win_toolchain_json', required=True)
|
||||
parser.add_argument('--depot_tools_parent_dir', required=True)
|
||||
args = parser.parse_args()
|
||||
win_toolchain_utils.resolve(args.win_toolchain_json,
|
||||
args.depot_tools_parent_dir)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -6,6 +6,9 @@
|
||||
# found in the LICENSE file.
|
||||
|
||||
|
||||
"""Download an updated VS toolchain, isolate it, upload a CL to update Skia."""
|
||||
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
@ -15,6 +18,8 @@ import subprocess
|
||||
import sys
|
||||
import utils
|
||||
|
||||
import win_toolchain_utils
|
||||
|
||||
|
||||
REPO_CHROME = 'https://chromium.googlesource.com/chromium/src.git'
|
||||
REPO_SKIA = 'https://skia.googlesource.com/skia.git'
|
||||
@ -34,6 +39,8 @@ def gen_toolchain(chrome_path, msvs_version, isolate_file):
|
||||
"""Update the VS toolchain, isolate it, and return the isolated hash."""
|
||||
with utils.chdir(chrome_path):
|
||||
subprocess.check_call([utils.GCLIENT, 'sync'])
|
||||
depot_tools = subprocess.check_output([
|
||||
'python', os.path.join('build', 'find_depot_tools.py')]).rstrip()
|
||||
with utils.git_branch():
|
||||
vs_toolchain_py = os.path.join('build', 'vs_toolchain.py')
|
||||
env = os.environ.copy()
|
||||
@ -42,17 +49,25 @@ def gen_toolchain(chrome_path, msvs_version, isolate_file):
|
||||
output = subprocess.check_output(['python', vs_toolchain_py,
|
||||
'get_toolchain_dir'], env=env).rstrip()
|
||||
src_dir = get_toolchain_dir(output)
|
||||
# Mock out absolute paths in win_toolchain.json.
|
||||
win_toolchain_utils.abstract(os.path.join('build', 'win_toolchain.json'),
|
||||
os.path.dirname(depot_tools))
|
||||
|
||||
# Isolate the toolchain. Assumes we're running on Windows, since the above
|
||||
# would fail otherwise.
|
||||
rel_path = os.path.relpath(src_dir, os.path.dirname(isolate_file))
|
||||
isolate_file_dirname = os.path.dirname(isolate_file)
|
||||
toolchain_relpath = os.path.relpath(src_dir, isolate_file_dirname)
|
||||
chrome_relpath = os.path.relpath(os.getcwd(), isolate_file_dirname)
|
||||
depot_tools_relpath = os.path.relpath(depot_tools, isolate_file_dirname)
|
||||
isolate = os.path.join(
|
||||
os.curdir, 'tools', 'luci-go', 'win64', 'isolate.exe')
|
||||
isolate_cmd = [isolate, 'archive', '--quiet',
|
||||
'--isolate-server', 'https://isolateserver.appspot.com',
|
||||
'-i', isolate_file,
|
||||
'-s', 'win_toolchain_%s.isolated' % msvs_version,
|
||||
'--extra-variable', 'WIN_TOOLCHAIN_DIR=%s' % rel_path]
|
||||
'--extra-variable', 'WIN_TOOLCHAIN_DIR=%s' % toolchain_relpath,
|
||||
'--extra-variable', 'DEPOT_TOOLS_DIR=%s' % depot_tools_relpath,
|
||||
'--extra-variable', 'CHROME_DIR=%s' % chrome_relpath]
|
||||
isolate_out = subprocess.check_output(isolate_cmd).rstrip()
|
||||
return shlex.split(isolate_out)[0]
|
||||
|
||||
|
@ -1,6 +1,12 @@
|
||||
{
|
||||
'variables': {
|
||||
'files': [
|
||||
'<(CHROME_DIR)/build/find_depot_tools.py',
|
||||
'<(CHROME_DIR)/build/vs_toolchain.py',
|
||||
'<(CHROME_DIR)/build/win_toolchain.json',
|
||||
'<(CHROME_DIR)/tools/gyp/pylib/',
|
||||
'<(DEPOT_TOOLS_DIR)/gclient.py',
|
||||
'<(DEPOT_TOOLS_DIR)/breakpad.py',
|
||||
'<(WIN_TOOLCHAIN_DIR)/',
|
||||
],
|
||||
},
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"2013": "d6b889963f8a6896d03457c52392f7f97d6cb94c",
|
||||
"2015": "081ab2320c1f76e234696dd2fc8aab44fa569a8a"
|
||||
"2013": "705384d88f80da637eb367e5acc6f315c0e1db2f",
|
||||
"2015": "38380d77eec9164e5818ae45e2915a6f22d60e85"
|
||||
}
|
53
infra/bots/win_toolchain_utils.py
Normal file
53
infra/bots/win_toolchain_utils.py
Normal file
@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2016 Google Inc.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
|
||||
"""Utilities for manipulating the win_toolchain.json file."""
|
||||
|
||||
|
||||
import json
|
||||
|
||||
|
||||
PLACEHOLDER = '<(TOOLCHAIN_BASE_DIR)'
|
||||
|
||||
|
||||
def _replace_prefix(val, before, after):
|
||||
"""Replace the given prefix with the given string."""
|
||||
if val.startswith(before):
|
||||
return val.replace(before, after, 1)
|
||||
return val
|
||||
|
||||
|
||||
def _replace(val, before, after):
|
||||
"""Replace occurrences of one string with another within the data."""
|
||||
if isinstance(val, basestring):
|
||||
return _replace_prefix(val, before, after)
|
||||
elif isinstance(val, (list, tuple)):
|
||||
return [_replace(elem, before, after) for elem in val]
|
||||
elif isinstance(val, dict):
|
||||
return {_replace(k, before, after):
|
||||
_replace(v, before, after) for k, v in val.iteritems()}
|
||||
raise Exception('Cannot replace variable: %s' % val)
|
||||
|
||||
|
||||
def _replace_in_file(filename, before, after):
|
||||
"""Replace occurrences of one string with another within the file."""
|
||||
with open(filename) as f:
|
||||
contents = json.load(f)
|
||||
new_contents = _replace(contents, before, after)
|
||||
with open(filename, 'w') as f:
|
||||
json.dump(new_contents, f)
|
||||
|
||||
|
||||
def abstract(win_toolchain_json, old_path):
|
||||
"""Replace absolute paths in win_toolchain.json with placeholders."""
|
||||
_replace_in_file(win_toolchain_json, old_path, PLACEHOLDER)
|
||||
|
||||
|
||||
def resolve(win_toolchain_json, new_path):
|
||||
"""Replace placeholders in win_toolchain.json with absolute paths."""
|
||||
_replace_in_file(win_toolchain_json, PLACEHOLDER, new_path)
|
Loading…
Reference in New Issue
Block a user