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 platform | 10 import platform |
11 import shutil | 11 import shutil |
12 import stat | 12 import stat |
13 import subprocess | 13 import subprocess |
14 import sys | 14 import sys |
15 | 15 |
16 | 16 |
17 script_dir = os.path.dirname(os.path.realpath(__file__)) | 17 script_dir = os.path.dirname(os.path.realpath(__file__)) |
18 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) | 18 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) |
19 SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 19 SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
20 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) | 20 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) |
21 json_data_file = os.path.join(script_dir, 'win_toolchain.json') | 21 json_data_file = os.path.join(script_dir, 'win_toolchain.json') |
22 | 22 |
23 | 23 |
24 import gyp | |
25 | |
26 | |
27 # Use MSVS2015 as the default toolchain. | 24 # Use MSVS2015 as the default toolchain. |
28 CURRENT_DEFAULT_TOOLCHAIN_VERSION = '2015' | 25 CURRENT_DEFAULT_TOOLCHAIN_VERSION = '2015' |
29 | 26 |
30 | 27 |
31 def SetEnvironmentAndGetRuntimeDllDirs(): | 28 def SetEnvironmentAndGetRuntimeDllDirs(): |
32 """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 |
33 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 |
34 the output directory after gyp generation. | 31 the output directory after gyp generation. |
35 | 32 |
36 Return value is [x64path, x86path] or None | 33 Return value is [x64path, x86path] or None |
(...skipping 20 matching lines...) Expand all Loading... | |
57 # split into separate keys for x86 and x64. (See CopyVsRuntimeDlls call | 54 # split into separate keys for x86 and x64. (See CopyVsRuntimeDlls call |
58 # below). http://crbug.com/345992 | 55 # below). http://crbug.com/345992 |
59 vs_runtime_dll_dirs = toolchain_data['runtime_dirs'] | 56 vs_runtime_dll_dirs = toolchain_data['runtime_dirs'] |
60 | 57 |
61 os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain | 58 os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain |
62 os.environ['GYP_MSVS_VERSION'] = version | 59 os.environ['GYP_MSVS_VERSION'] = version |
63 # We need to make sure windows_sdk_path is set to the automated | 60 # We need to make sure windows_sdk_path is set to the automated |
64 # toolchain values in GYP_DEFINES, but don't want to override any | 61 # toolchain values in GYP_DEFINES, but don't want to override any |
65 # otheroptions.express | 62 # otheroptions.express |
66 # values there. | 63 # values there. |
64 import gyp | |
brucedawson
2017/03/10 23:31:49
Feels like the comment above applies to this line,
Lei Zhang
2017/03/10 23:43:07
Done.
| |
67 gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES')) | 65 gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES')) |
68 gyp_defines_dict['windows_sdk_path'] = win_sdk | 66 gyp_defines_dict['windows_sdk_path'] = win_sdk |
69 os.environ['GYP_DEFINES'] = ' '.join('%s=%s' % (k, pipes.quote(str(v))) | 67 os.environ['GYP_DEFINES'] = ' '.join('%s=%s' % (k, pipes.quote(str(v))) |
70 for k, v in gyp_defines_dict.iteritems()) | 68 for k, v in gyp_defines_dict.iteritems()) |
71 os.environ['WINDOWSSDKDIR'] = win_sdk | 69 os.environ['WINDOWSSDKDIR'] = win_sdk |
72 os.environ['WDK_DIR'] = wdk | 70 os.environ['WDK_DIR'] = wdk |
73 # Include the VS runtime in the PATH in case it's not machine-installed. | 71 # Include the VS runtime in the PATH in case it's not machine-installed. |
74 runtime_path = os.path.pathsep.join(vs_runtime_dll_dirs) | 72 runtime_path = os.path.pathsep.join(vs_runtime_dll_dirs) |
75 os.environ['PATH'] = runtime_path + os.path.pathsep + os.environ['PATH'] | 73 os.environ['PATH'] = runtime_path + os.path.pathsep + os.environ['PATH'] |
76 elif sys.platform == 'win32' and not depot_tools_win_toolchain: | 74 elif sys.platform == 'win32' and not depot_tools_win_toolchain: |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 raise Exception(('Visual Studio Version %s (from GYP_MSVS_VERSION)' | 162 raise Exception(('Visual Studio Version %s (from GYP_MSVS_VERSION)' |
165 ' not found.') % (version_as_year)) | 163 ' not found.') % (version_as_year)) |
166 | 164 |
167 | 165 |
168 def _VersionNumber(): | 166 def _VersionNumber(): |
169 """Gets the standard version number ('120', '140', etc.) based on | 167 """Gets the standard version number ('120', '140', etc.) based on |
170 GYP_MSVS_VERSION.""" | 168 GYP_MSVS_VERSION.""" |
171 vs_version = GetVisualStudioVersion() | 169 vs_version = GetVisualStudioVersion() |
172 if vs_version == '2013': | 170 if vs_version == '2013': |
173 return '120' | 171 return '120' |
174 elif vs_version == '2015': | 172 if vs_version == '2015': |
175 return '140' | 173 return '140' |
176 elif vs_version == '2017': | 174 if vs_version == '2017': |
177 return '150' | 175 return '150' |
178 else: | 176 raise ValueError('Unexpected GYP_MSVS_VERSION') |
179 raise ValueError('Unexpected GYP_MSVS_VERSION') | |
180 | 177 |
181 | 178 |
182 def _CopyRuntimeImpl(target, source, verbose=True): | 179 def _CopyRuntimeImpl(target, source, verbose=True): |
183 """Copy |source| to |target| if it doesn't already exist or if it needs to be | 180 """Copy |source| to |target| if it doesn't already exist or if it needs to be |
184 updated (comparing last modified time as an approximate float match as for | 181 updated (comparing last modified time as an approximate float match as for |
185 some reason the values tend to differ by ~1e-07 despite being copies of the | 182 some reason the values tend to differ by ~1e-07 despite being copies of the |
186 same file... https://crbug.com/603603). | 183 same file... https://crbug.com/603603). |
187 """ | 184 """ |
188 if (os.path.isdir(os.path.dirname(target)) and | 185 if (os.path.isdir(os.path.dirname(target)) and |
189 (not os.path.isfile(target) or | 186 (not os.path.isfile(target) or |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
336 target_path = os.path.join(target_dir, debug_file) | 333 target_path = os.path.join(target_dir, debug_file) |
337 _CopyRuntimeImpl(target_path, full_path) | 334 _CopyRuntimeImpl(target_path, full_path) |
338 | 335 |
339 | 336 |
340 def _GetDesiredVsToolchainHashes(): | 337 def _GetDesiredVsToolchainHashes(): |
341 """Load a list of SHA1s corresponding to the toolchains that we want installed | 338 """Load a list of SHA1s corresponding to the toolchains that we want installed |
342 to build with.""" | 339 to build with.""" |
343 if GetVisualStudioVersion() == '2015': | 340 if GetVisualStudioVersion() == '2015': |
344 # Update 3 final with patches with 10.0.14393.0 SDK. | 341 # Update 3 final with patches with 10.0.14393.0 SDK. |
345 return ['d3cb0e37bdd120ad0ac4650b674b09e81be45616'] | 342 return ['d3cb0e37bdd120ad0ac4650b674b09e81be45616'] |
346 else: | 343 return ['03a4e939cd325d6bc5216af41b92d02dda1366a6'] |
brucedawson
2017/03/10 23:31:49
This is going to conflict with another CL that I j
Lei Zhang
2017/03/10 23:33:15
Please land your CL first. I'm not in any rush her
| |
347 return ['03a4e939cd325d6bc5216af41b92d02dda1366a6'] | |
348 | 344 |
349 | 345 |
350 def ShouldUpdateToolchain(): | 346 def ShouldUpdateToolchain(): |
351 """Check if the toolchain should be upgraded.""" | 347 """Check if the toolchain should be upgraded.""" |
352 if not os.path.exists(json_data_file): | 348 if not os.path.exists(json_data_file): |
353 return True | 349 return True |
354 with open(json_data_file, 'r') as tempf: | 350 with open(json_data_file, 'r') as tempf: |
355 toolchain_data = json.load(tempf) | 351 toolchain_data = json.load(tempf) |
356 version = toolchain_data['version'] | 352 version = toolchain_data['version'] |
357 env_version = GetVisualStudioVersion() | 353 env_version = GetVisualStudioVersion() |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
440 'copy_dlls': CopyDlls, | 436 'copy_dlls': CopyDlls, |
441 } | 437 } |
442 if len(sys.argv) < 2 or sys.argv[1] not in commands: | 438 if len(sys.argv) < 2 or sys.argv[1] not in commands: |
443 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) | 439 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) |
444 return 1 | 440 return 1 |
445 return commands[sys.argv[1]](*sys.argv[2:]) | 441 return commands[sys.argv[1]](*sys.argv[2:]) |
446 | 442 |
447 | 443 |
448 if __name__ == '__main__': | 444 if __name__ == '__main__': |
449 sys.exit(main()) | 445 sys.exit(main()) |
OLD | NEW |