| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import json | 6 import json |
| 7 import os | 7 import os |
| 8 import pipes | 8 import pipes |
| 9 import shutil | 9 import shutil |
| 10 import subprocess | 10 import subprocess |
| 11 import sys | 11 import sys |
| 12 | 12 |
| 13 | 13 |
| 14 script_dir = os.path.dirname(os.path.realpath(__file__)) | 14 script_dir = os.path.dirname(os.path.realpath(__file__)) |
| 15 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) | 15 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) |
| 16 SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 16 SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
| 17 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) | 17 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) |
| 18 json_data_file = os.path.join(script_dir, 'win_toolchain.json') | 18 json_data_file = os.path.join(script_dir, 'win_toolchain.json') |
| 19 | 19 |
| 20 | 20 |
| 21 import gyp | 21 import gyp |
| 22 | 22 |
| 23 | 23 |
| 24 # Use MSVS2015 as the default toolchain. | 24 # Use MSVS2013 as the default toolchain. |
| 25 CURRENT_DEFAULT_TOOLCHAIN_VERSION = '2015' | 25 CURRENT_DEFAULT_TOOLCHAIN_VERSION = '2013' |
| 26 | 26 |
| 27 | 27 |
| 28 def SetEnvironmentAndGetRuntimeDllDirs(): | 28 def SetEnvironmentAndGetRuntimeDllDirs(): |
| 29 """Sets up os.environ to use the depot_tools VS toolchain with gyp, and | 29 """Sets up os.environ to use the depot_tools VS toolchain with gyp, and |
| 30 returns the location of the VS runtime DLLs so they can be copied into | 30 returns the location of the VS runtime DLLs so they can be copied into |
| 31 the output directory after gyp generation. | 31 the output directory after gyp generation. |
| 32 """ | 32 """ |
| 33 vs_runtime_dll_dirs = None | 33 vs_runtime_dll_dirs = None |
| 34 depot_tools_win_toolchain = \ | 34 depot_tools_win_toolchain = \ |
| 35 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))) | 35 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))) |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 _CopyRuntime(target_dir, runtime_dir, target_cpu, debug=True) | 267 _CopyRuntime(target_dir, runtime_dir, target_cpu, debug=True) |
| 268 | 268 |
| 269 | 269 |
| 270 def _GetDesiredVsToolchainHashes(): | 270 def _GetDesiredVsToolchainHashes(): |
| 271 """Load a list of SHA1s corresponding to the toolchains that we want installed | 271 """Load a list of SHA1s corresponding to the toolchains that we want installed |
| 272 to build with.""" | 272 to build with.""" |
| 273 if GetVisualStudioVersion() == '2015': | 273 if GetVisualStudioVersion() == '2015': |
| 274 # Update 1 with Debuggers, UCRT installers and ucrtbased.dll | 274 # Update 1 with Debuggers, UCRT installers and ucrtbased.dll |
| 275 return ['523b6c2d3df300b2c8538cdc0beac404726af051'] | 275 return ['523b6c2d3df300b2c8538cdc0beac404726af051'] |
| 276 else: | 276 else: |
| 277 # Default to VS2013. |
| 277 return ['4087e065abebdca6dbd0caca2910c6718d2ec67f'] | 278 return ['4087e065abebdca6dbd0caca2910c6718d2ec67f'] |
| 278 | 279 |
| 279 | 280 |
| 280 def ShouldUpdateToolchain(): | 281 def ShouldUpdateToolchain(): |
| 281 """Check if the toolchain should be upgraded.""" | 282 """Check if the toolchain should be upgraded.""" |
| 282 if not os.path.exists(json_data_file): | 283 if not os.path.exists(json_data_file): |
| 283 return True | 284 return True |
| 284 with open(json_data_file, 'r') as tempf: | 285 with open(json_data_file, 'r') as tempf: |
| 285 toolchain_data = json.load(tempf) | 286 toolchain_data = json.load(tempf) |
| 286 version = toolchain_data['version'] | 287 version = toolchain_data['version'] |
| (...skipping 13 matching lines...) Expand all Loading... |
| 300 return 1 | 301 return 1 |
| 301 if force == '--force' or os.path.exists(json_data_file): | 302 if force == '--force' or os.path.exists(json_data_file): |
| 302 force = True | 303 force = True |
| 303 | 304 |
| 304 depot_tools_win_toolchain = \ | 305 depot_tools_win_toolchain = \ |
| 305 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))) | 306 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))) |
| 306 if ((sys.platform in ('win32', 'cygwin') or force) and | 307 if ((sys.platform in ('win32', 'cygwin') or force) and |
| 307 depot_tools_win_toolchain): | 308 depot_tools_win_toolchain): |
| 308 import find_depot_tools | 309 import find_depot_tools |
| 309 depot_tools_path = find_depot_tools.add_depot_tools_to_path() | 310 depot_tools_path = find_depot_tools.add_depot_tools_to_path() |
| 310 # Necessary so that get_toolchain_if_necessary.py will put the VS toolkit | |
| 311 # in the correct directory. | |
| 312 os.environ['GYP_MSVS_VERSION'] = GetVisualStudioVersion() | |
| 313 get_toolchain_args = [ | 311 get_toolchain_args = [ |
| 314 sys.executable, | 312 sys.executable, |
| 315 os.path.join(depot_tools_path, | 313 os.path.join(depot_tools_path, |
| 316 'win_toolchain', | 314 'win_toolchain', |
| 317 'get_toolchain_if_necessary.py'), | 315 'get_toolchain_if_necessary.py'), |
| 318 '--output-json', json_data_file, | 316 '--output-json', json_data_file, |
| 319 ] + _GetDesiredVsToolchainHashes() | 317 ] + _GetDesiredVsToolchainHashes() |
| 320 if force: | 318 if force: |
| 321 get_toolchain_args.append('--force') | 319 get_toolchain_args.append('--force') |
| 322 subprocess.check_call(get_toolchain_args) | 320 subprocess.check_call(get_toolchain_args) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 'copy_dlls': CopyDlls, | 353 'copy_dlls': CopyDlls, |
| 356 } | 354 } |
| 357 if len(sys.argv) < 2 or sys.argv[1] not in commands: | 355 if len(sys.argv) < 2 or sys.argv[1] not in commands: |
| 358 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) | 356 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) |
| 359 return 1 | 357 return 1 |
| 360 return commands[sys.argv[1]](*sys.argv[2:]) | 358 return commands[sys.argv[1]](*sys.argv[2:]) |
| 361 | 359 |
| 362 | 360 |
| 363 if __name__ == '__main__': | 361 if __name__ == '__main__': |
| 364 sys.exit(main()) | 362 sys.exit(main()) |
| OLD | NEW |