From 78833b819ffbf199141d45d4ed19681a7c6f6651 Mon Sep 17 00:00:00 2001 From: thakis Date: Fri, 11 Mar 2016 09:27:16 -0800 Subject: Automatically download gnu win tools from update.py I put a small zip (1.6MB) on GCS containing just the gnu tools (from GNUWin32) that are required by LLVM's check-all target. If more are needed in the future, we'll need to push a new zip file to GCS with the new tools. This seems better than downloading the full 182MB gnuwin tools from the script. BUG=578306 Review URL: https://codereview.chromium.org/1781113002 Cr-Commit-Position: refs/heads/master@{#380661} --- tools/clang/scripts/package.py | 7 ------- tools/clang/scripts/update.py | 29 ++++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 12 deletions(-) (limited to 'tools') diff --git a/tools/clang/scripts/package.py b/tools/clang/scripts/package.py index 944acee..63ab1a9 100755 --- a/tools/clang/scripts/package.py +++ b/tools/clang/scripts/package.py @@ -110,13 +110,6 @@ def MaybeUpload(args, archive_name, platform): def main(): - if sys.platform == 'win32': - try: - subprocess.check_output(['grep', '--help'], shell=True) - except subprocess.CalledProcessError: - print 'Add gnuwin32 to your PATH, then try again.' - return 1 - parser = argparse.ArgumentParser(description='build and package clang') parser.add_argument('--upload', action='store_true', help='Upload the target archive to Google Cloud Storage.') diff --git a/tools/clang/scripts/update.py b/tools/clang/scripts/update.py index e3fa1b1..b005520 100755 --- a/tools/clang/scripts/update.py +++ b/tools/clang/scripts/update.py @@ -136,19 +136,19 @@ def DownloadAndUnpack(url, output_dir): tarfile.open(mode='r:gz', fileobj=f).extractall(path=output_dir) -def ReadStampFile(): +def ReadStampFile(path=STAMP_FILE): """Return the contents of the stamp file, or '' if it doesn't exist.""" try: - with open(STAMP_FILE, 'r') as f: + with open(path, 'r') as f: return f.read().rstrip() except IOError: return '' -def WriteStampFile(s): +def WriteStampFile(s, path=STAMP_FILE): """Write s to the stamp file.""" - EnsureDirExists(os.path.dirname(STAMP_FILE)) - with open(STAMP_FILE, 'w') as f: + EnsureDirExists(os.path.dirname(path)) + with open(path, 'w') as f: f.write(s) f.write('\n') @@ -305,6 +305,24 @@ def AddCMakeToPath(): os.environ['PATH'] = cmake_dir + os.pathsep + os.environ.get('PATH', '') +def AddGnuWinToPath(): + """Download some GNU win tools and add them to PATH.""" + if sys.platform != 'win32': + return + + gnuwin_dir = os.path.join(LLVM_BUILD_TOOLS_DIR, 'gnuwin') + GNUWIN_VERSION = '1' + GNUWIN_STAMP = os.path.join(gnuwin_dir, 'stamp') + if ReadStampFile(GNUWIN_STAMP) == GNUWIN_VERSION: + print 'GNU Win tools already up to date.' + else: + zip_name = 'gnuwin-%s.zip' % GNUWIN_VERSION + DownloadAndUnpack(CDS_URL + '/tools/' + zip_name, LLVM_BUILD_TOOLS_DIR) + WriteStampFile(GNUWIN_VERSION, GNUWIN_STAMP) + + os.environ['PATH'] = gnuwin_dir + os.pathsep + os.environ.get('PATH', '') + + vs_version = None def GetVSVersion(): global vs_version @@ -381,6 +399,7 @@ def UpdateClang(args): DownloadHostGcc(args) AddCMakeToPath() + AddGnuWinToPath() DeleteChromeToolsShim() -- cgit v1.1