Home | History | Annotate | Download | only in win_toolchain
      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 """
     10 Create an updated VS toolchain
     11 
     12 Before you can run this script, you need a collated VC toolchain + Windows SDK.
     13 To generate that, run depot_tools/win_toolchain/package_from_installed.py
     14 That script pulls all of the compiler and SDK bits from your locally installed
     15 version of Visual Studio. The comments in that script include instructions on
     16 which components need to be installed (C++, ARM64, etc...)
     17 
     18 That script produces a .zip file with a SHA filename. Unzip that file, then
     19 pass the unzipped directory as the src_dir to this script.
     20 """
     21 
     22 import argparse
     23 import common
     24 import os
     25 import shlex
     26 import shutil
     27 import subprocess
     28 import sys
     29 import 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.
     34 IGNORE_LIST = [
     35   'WindowsMobile',
     36   'App Certification Kit',
     37   'Debuggers',
     38   'Extension SDKs',
     39   'DesignTime',
     40   'AccChecker',
     41 ]
     42 
     43 def 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 
     52 def 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 
     65 if __name__ == '__main__':
     66   main()
     67