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""" 10Create an updated VS toolchain 11 12Before you can run this script, you need a collated VC toolchain + Windows SDK. 13To generate that, run depot_tools/win_toolchain/package_from_installed.py 14That script pulls all of the compiler and SDK bits from your locally installed 15version of Visual Studio. The comments in that script include instructions on 16which components need to be installed (C++, ARM64, etc...) 17 18That script produces a .zip file with a SHA filename. Unzip that file, then 19pass the unzipped directory as the src_dir to this script. 20""" 21 22import argparse 23import common 24import os 25import shlex 26import shutil 27import subprocess 28import sys 29import utils 30 31 32# By default the toolchain includes a bunch of unnecessary stuff with long path 33# names. Trim out directories with these names. 34IGNORE_LIST = [ 35 'WindowsMobile', 36 'App Certification Kit', 37 'Debuggers', 38 'Extension SDKs', 39 'DesignTime', 40 'AccChecker', 41] 42 43def filter_toolchain_files(dirname, files): 44 """Callback for shutil.copytree. Return lists of files to skip.""" 45 split = dirname.split(os.path.sep) 46 for ign in IGNORE_LIST: 47 if ign in split: 48 print 'Ignoring dir %s' % dirname 49 return files 50 return [] 51 52def main(): 53 if sys.platform != 'win32': 54 print >> sys.stderr, 'This script only runs on Windows.' 55 sys.exit(1) 56 57 parser = argparse.ArgumentParser() 58 parser.add_argument('--src_dir', '-s', required=True) 59 parser.add_argument('--target_dir', '-t', required=True) 60 args = parser.parse_args() 61 src_dir = os.path.abspath(args.src_dir) 62 target_dir = os.path.abspath(args.target_dir) 63 shutil.copytree(src_dir, target_dir, ignore=filter_toolchain_files) 64 65if __name__ == '__main__': 66 main() 67