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 glob | 6 import glob |
7 import json | 7 import json |
8 import os | 8 import os |
9 import pipes | 9 import pipes |
10 import shutil | 10 import shutil |
11 import subprocess | 11 import subprocess |
12 import sys | 12 import sys |
13 | 13 |
14 | 14 |
15 script_dir = os.path.dirname(os.path.realpath(__file__)) | 15 script_dir = os.path.dirname(os.path.realpath(__file__)) |
16 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) | 16 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) |
17 SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 17 SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
18 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) | 18 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) |
19 json_data_file = os.path.join(script_dir, 'win_toolchain.json') | 19 json_data_file = os.path.join(script_dir, 'win_toolchain.json') |
20 | 20 |
21 | 21 |
22 import gyp | 22 import gyp |
23 | 23 |
24 | 24 |
25 # Use MSVS2015 as the default toolchain. | 25 # Use MSVS2013 as the default toolchain. |
26 CURRENT_DEFAULT_TOOLCHAIN_VERSION = '2015' | 26 CURRENT_DEFAULT_TOOLCHAIN_VERSION = '2013' |
27 | 27 |
28 | 28 |
29 def SetEnvironmentAndGetRuntimeDllDirs(): | 29 def SetEnvironmentAndGetRuntimeDllDirs(): |
30 """Sets up os.environ to use the depot_tools VS toolchain with gyp, and | 30 """Sets up os.environ to use the depot_tools VS toolchain with gyp, and |
31 returns the location of the VS runtime DLLs so they can be copied into | 31 returns the location of the VS runtime DLLs so they can be copied into |
32 the output directory after gyp generation. | 32 the output directory after gyp generation. |
33 """ | 33 """ |
34 vs_runtime_dll_dirs = None | 34 vs_runtime_dll_dirs = None |
35 depot_tools_win_toolchain = \ | 35 depot_tools_win_toolchain = \ |
36 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))) | 36 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))) |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 _CopyRuntime(target_dir, runtime_dir, target_cpu, debug=True) | 274 _CopyRuntime(target_dir, runtime_dir, target_cpu, debug=True) |
275 | 275 |
276 | 276 |
277 def _GetDesiredVsToolchainHashes(): | 277 def _GetDesiredVsToolchainHashes(): |
278 """Load a list of SHA1s corresponding to the toolchains that we want installed | 278 """Load a list of SHA1s corresponding to the toolchains that we want installed |
279 to build with.""" | 279 to build with.""" |
280 if GetVisualStudioVersion() == '2015': | 280 if GetVisualStudioVersion() == '2015': |
281 # Update 1 with hot fixes. | 281 # Update 1 with hot fixes. |
282 return ['b349b3cc596d5f7e13d649532ddd7e8db39db0cb'] | 282 return ['b349b3cc596d5f7e13d649532ddd7e8db39db0cb'] |
283 else: | 283 else: |
| 284 # Default to VS2013. |
284 return ['4087e065abebdca6dbd0caca2910c6718d2ec67f'] | 285 return ['4087e065abebdca6dbd0caca2910c6718d2ec67f'] |
285 | 286 |
286 | 287 |
287 def ShouldUpdateToolchain(): | 288 def ShouldUpdateToolchain(): |
288 """Check if the toolchain should be upgraded.""" | 289 """Check if the toolchain should be upgraded.""" |
289 if not os.path.exists(json_data_file): | 290 if not os.path.exists(json_data_file): |
290 return True | 291 return True |
291 with open(json_data_file, 'r') as tempf: | 292 with open(json_data_file, 'r') as tempf: |
292 toolchain_data = json.load(tempf) | 293 toolchain_data = json.load(tempf) |
293 version = toolchain_data['version'] | 294 version = toolchain_data['version'] |
(...skipping 13 matching lines...) Expand all Loading... |
307 return 1 | 308 return 1 |
308 if force == '--force' or os.path.exists(json_data_file): | 309 if force == '--force' or os.path.exists(json_data_file): |
309 force = True | 310 force = True |
310 | 311 |
311 depot_tools_win_toolchain = \ | 312 depot_tools_win_toolchain = \ |
312 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))) | 313 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))) |
313 if ((sys.platform in ('win32', 'cygwin') or force) and | 314 if ((sys.platform in ('win32', 'cygwin') or force) and |
314 depot_tools_win_toolchain): | 315 depot_tools_win_toolchain): |
315 import find_depot_tools | 316 import find_depot_tools |
316 depot_tools_path = find_depot_tools.add_depot_tools_to_path() | 317 depot_tools_path = find_depot_tools.add_depot_tools_to_path() |
317 # Necessary so that get_toolchain_if_necessary.py will put the VS toolkit | |
318 # in the correct directory. | |
319 os.environ['GYP_MSVS_VERSION'] = GetVisualStudioVersion() | |
320 get_toolchain_args = [ | 318 get_toolchain_args = [ |
321 sys.executable, | 319 sys.executable, |
322 os.path.join(depot_tools_path, | 320 os.path.join(depot_tools_path, |
323 'win_toolchain', | 321 'win_toolchain', |
324 'get_toolchain_if_necessary.py'), | 322 'get_toolchain_if_necessary.py'), |
325 '--output-json', json_data_file, | 323 '--output-json', json_data_file, |
326 ] + _GetDesiredVsToolchainHashes() | 324 ] + _GetDesiredVsToolchainHashes() |
327 if force: | 325 if force: |
328 get_toolchain_args.append('--force') | 326 get_toolchain_args.append('--force') |
329 subprocess.check_call(get_toolchain_args) | 327 subprocess.check_call(get_toolchain_args) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 'copy_dlls': CopyDlls, | 360 'copy_dlls': CopyDlls, |
363 } | 361 } |
364 if len(sys.argv) < 2 or sys.argv[1] not in commands: | 362 if len(sys.argv) < 2 or sys.argv[1] not in commands: |
365 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) | 363 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) |
366 return 1 | 364 return 1 |
367 return commands[sys.argv[1]](*sys.argv[2:]) | 365 return commands[sys.argv[1]](*sys.argv[2:]) |
368 | 366 |
369 | 367 |
370 if __name__ == '__main__': | 368 if __name__ == '__main__': |
371 sys.exit(main()) | 369 sys.exit(main()) |
OLD | NEW |