From 5d17b921db263ade03b09a3a1716fda3edba99c0 Mon Sep 17 00:00:00 2001 From: "scottmg@chromium.org" Date: Sat, 22 Feb 2014 01:47:53 +0000 Subject: [PATCH] Move toolchain update control into src, but keep download logic in depot_tools Moves the update functionality out of update_depot_tools into src/ in https://codereview.chromium.org/175573004 . get_toolchain_if_required.py now expects a list of hashes on the command line, and makes sure that it gets one of those. toolchain2013.py saves a .json which contains information relevant to the interests of the caller, so that it can set up the parent environment. This is returned via the --output-json command line argument to get_...py R=iannucci@chromium.org BUG=323300 Review URL: https://codereview.chromium.org/168603004 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@252725 0039d316-1c4b-4281-b951-d872f2087c98 --- update_depot_tools.bat | 9 +-------- win_toolchain/get_toolchain_if_necessary.py | 20 +++++++++++--------- win_toolchain/toolchain2013.py | 15 +++++++++++++-- win_toolchain/toolchain_vs2013.hash | 2 -- 4 files changed, 25 insertions(+), 21 deletions(-) delete mode 100644 win_toolchain/toolchain_vs2013.hash diff --git a/update_depot_tools.bat b/update_depot_tools.bat index e4981f018..fd3e9a22e 100644 --- a/update_depot_tools.bat +++ b/update_depot_tools.bat @@ -30,13 +30,6 @@ if errorlevel 1 goto :EOF :: Now clear errorlevel so it can be set by other programs later. set errorlevel= -:: Opt-in for now. -IF "%DEPOT_TOOLS_WIN_TOOLCHAIN%" == "" GOTO :NOTOOLCHAIN -call python %~dp0win_toolchain\get_toolchain_if_necessary.py -if errorlevel 1 goto :EOF -set errorlevel= -:NOTOOLCHAIN - :: Shall skip automatic update? IF "%DEPOT_TOOLS_UPDATE%" == "0" GOTO :EOF @@ -74,4 +67,4 @@ goto :EOF :GIT_SVN_UPDATE cd /d "%DEPOT_TOOLS_DIR%." call git svn rebase -q -q -goto :EOF \ No newline at end of file +goto :EOF diff --git a/win_toolchain/get_toolchain_if_necessary.py b/win_toolchain/get_toolchain_if_necessary.py index 3ac6689c6..4af2e7f7a 100755 --- a/win_toolchain/get_toolchain_if_necessary.py +++ b/win_toolchain/get_toolchain_if_necessary.py @@ -29,7 +29,9 @@ maintained, and a new 2015 script would be added. import ctypes.wintypes import hashlib import json +import optparse import os +import shutil import subprocess import sys import time @@ -145,9 +147,12 @@ def main(): if not sys.platform.startswith(('cygwin', 'win32')): return 0 - if len(sys.argv) != 1: - print >> sys.stderr, 'Unexpected arguments.' - return 1 + parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) + parser.add_option('--output-json', metavar='FILE', + help='write information about toolchain to FILE') + options, args = parser.parse_args() + + desired_hashes = set(args) # Move to depot_tools\win_toolchain where we'll store our files, and where # the downloader script is. @@ -155,12 +160,6 @@ def main(): toolchain_dir = '.' target_dir = os.path.normpath(os.path.join(toolchain_dir, 'vs2013_files')) - sha1path = os.path.join(toolchain_dir, 'toolchain_vs2013.hash') - desired_hashes = set() - if os.path.isfile(sha1path): - with open(sha1path, 'rb') as f: - desired_hashes = set(f.read().strip().splitlines()) - # If the current hash doesn't match what we want in the file, nuke and pave. # Typically this script is only run when the .sha1 one file is updated, but # directly calling "gclient runhooks" will also run it, so we cache @@ -195,6 +194,9 @@ def main(): return 1 SaveTimestampsAndHash(target_dir, current_hash) + if options.output_json: + shutil.copyfile(os.path.join(target_dir, 'data.json'), options.output_json) + return 0 diff --git a/win_toolchain/toolchain2013.py b/win_toolchain/toolchain2013.py index 147c9d3cf..1ed216cd4 100755 --- a/win_toolchain/toolchain2013.py +++ b/win_toolchain/toolchain2013.py @@ -7,6 +7,7 @@ import ctypes +import json import optparse import os import shutil @@ -456,8 +457,18 @@ def main(): CopyToFinalLocation(extracted, target_dir) GenerateSetEnvCmd(target_dir, not options.express) - with open(os.path.join(target_dir, '.version'), 'w') as f: - f.write('express' if options.express else 'pro') + data = { + 'path': target_dir, + 'version': '2013e' if options.express else '2013', + 'win8sdk': os.path.join(target_dir, 'win8sdk'), + 'wdk': os.path.join(target_dir, 'wdk'), + 'runtime_dirs': [ + os.path.join(target_dir, 'sys64'), + os.path.join(target_dir, 'sys32'), + ], + } + with open(os.path.join(target_dir, 'data.json'), 'w') as f: + json.dump(data, f) finally: if options.clean: DeleteAllTempDirs() diff --git a/win_toolchain/toolchain_vs2013.hash b/win_toolchain/toolchain_vs2013.hash deleted file mode 100644 index 1cec0683b..000000000 --- a/win_toolchain/toolchain_vs2013.hash +++ /dev/null @@ -1,2 +0,0 @@ -0bbca7f56298c3075b183cd9d11b3529c88ce775 -9d48ee27f0d29e02fd89dd5d1d6208bf42fd6e16