diff options
author | borenet <borenet@chromium.org> | 2016-03-11 04:54:42 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-11 04:54:42 -0800 |
commit | 2f56b1aba22ad79a5e63587e4bca3001ab7ab0ba (patch) | |
tree | ce30ddb73a716cdc25ac2cc8c7f159d3168a8792 /infra | |
parent | 7fb4f8bd031eda87e1da9bc0f749968c0e872e6f (diff) |
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
Diffstat (limited to 'infra')
-rw-r--r-- | infra/bots/bootstrap_win_toolchain_json.py | 26 | ||||
-rw-r--r-- | infra/bots/isolate_win_toolchain.py | 19 | ||||
-rw-r--r-- | infra/bots/win_toolchain.isolate | 6 | ||||
-rw-r--r-- | infra/bots/win_toolchain_hash.json | 6 | ||||
-rw-r--r-- | infra/bots/win_toolchain_utils.py | 53 |
5 files changed, 105 insertions, 5 deletions
diff --git a/infra/bots/bootstrap_win_toolchain_json.py b/infra/bots/bootstrap_win_toolchain_json.py new file mode 100644 index 0000000000..199abe01bb --- /dev/null +++ b/infra/bots/bootstrap_win_toolchain_json.py @@ -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() diff --git a/infra/bots/isolate_win_toolchain.py b/infra/bots/isolate_win_toolchain.py index ff01bd60d8..696077992f 100644 --- a/infra/bots/isolate_win_toolchain.py +++ b/infra/bots/isolate_win_toolchain.py @@ -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] diff --git a/infra/bots/win_toolchain.isolate b/infra/bots/win_toolchain.isolate index d9505bab27..a2c91db0bb 100644 --- a/infra/bots/win_toolchain.isolate +++ b/infra/bots/win_toolchain.isolate @@ -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)/', ], }, diff --git a/infra/bots/win_toolchain_hash.json b/infra/bots/win_toolchain_hash.json index 337fd4fe6e..ad756934ea 100644 --- a/infra/bots/win_toolchain_hash.json +++ b/infra/bots/win_toolchain_hash.json @@ -1,4 +1,4 @@ { - "2013": "d6b889963f8a6896d03457c52392f7f97d6cb94c", - "2015": "081ab2320c1f76e234696dd2fc8aab44fa569a8a" -}
\ No newline at end of file + "2013": "705384d88f80da637eb367e5acc6f315c0e1db2f", + "2015": "38380d77eec9164e5818ae45e2915a6f22d60e85" +} diff --git a/infra/bots/win_toolchain_utils.py b/infra/bots/win_toolchain_utils.py new file mode 100644 index 0000000000..43f62863cd --- /dev/null +++ b/infra/bots/win_toolchain_utils.py @@ -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) |