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 22 23from __future__ import print_function 24import argparse 25import common 26import os 27import shlex 28import shutil 29import subprocess 30import sys 31import utils 32 33 34# By default the toolchain includes a bunch of unnecessary stuff with long path 35# names. Trim out directories with these names. 36IGNORE_LIST = [ 37 'WindowsMobile', 38 'App Certification Kit', 39 'Debuggers', 40 'Extension SDKs', 41 'DesignTime', 42 'AccChecker', 43] 44 45def filter_toolchain_files(dirname, files): 46 """Callback for shutil.copytree. Return lists of files to skip.""" 47 split = dirname.split(os.path.sep) 48 for ign in IGNORE_LIST: 49 if ign in split: 50 print('Ignoring dir %s' % dirname) 51 return files 52 return [] 53 54def main(): 55 if sys.platform != 'win32': 56 print('This script only runs on Windows.', file=sys.stderr) 57 sys.exit(1) 58 59 parser = argparse.ArgumentParser() 60 parser.add_argument('--src_dir', '-s', required=True) 61 parser.add_argument('--target_dir', '-t', required=True) 62 args = parser.parse_args() 63 src_dir = os.path.abspath(args.src_dir) 64 target_dir = os.path.abspath(args.target_dir) 65 shutil.copytree(src_dir, target_dir, ignore=filter_toolchain_files) 66 67if __name__ == '__main__': 68 main() 69