Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: build/vs_toolchain.py

Issue 2653473002: Allow building Chrome with local VC++ 2017 install (Closed)
Patch Set: Rename _CopyRuntime2015 to _CopyUCRTRuntime Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/toolchain/win/setup_toolchain.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 def DetectVisualStudioPath(): 128 def DetectVisualStudioPath():
129 """Return path to the GYP_MSVS_VERSION of Visual Studio. 129 """Return path to the GYP_MSVS_VERSION of Visual Studio.
130 """ 130 """
131 131
132 # Note that this code is used from 132 # Note that this code is used from
133 # build/toolchain/win/setup_toolchain.py as well. 133 # build/toolchain/win/setup_toolchain.py as well.
134 version_as_year = GetVisualStudioVersion() 134 version_as_year = GetVisualStudioVersion()
135 year_to_version = { 135 year_to_version = {
136 '2013': '12.0', 136 '2013': '12.0',
137 '2015': '14.0', 137 '2015': '14.0',
138 '2017': '15.0',
138 } 139 }
139 if version_as_year not in year_to_version: 140 if version_as_year not in year_to_version:
140 raise Exception(('Visual Studio version %s (from GYP_MSVS_VERSION)' 141 raise Exception(('Visual Studio version %s (from GYP_MSVS_VERSION)'
141 ' not supported. Supported versions are: %s') % ( 142 ' not supported. Supported versions are: %s') % (
142 version_as_year, ', '.join(year_to_version.keys()))) 143 version_as_year, ', '.join(year_to_version.keys())))
143 version = year_to_version[version_as_year] 144 version = year_to_version[version_as_year]
144 keys = [r'HKLM\Software\Microsoft\VisualStudio\%s' % version, 145 if version_as_year == '2017':
145 r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\%s' % version] 146 # The VC++ 2017 install location needs to be located using COM instead of
146 for key in keys: 147 # the registry. For details see:
147 path = _RegistryGetValue(key, 'InstallDir') 148 # https://blogs.msdn.microsoft.com/heaths/2016/09/15/changes-to-visual-studi o-15-setup/
148 if not path: 149 # For now we use a hardcoded default with an environment variable override.
149 continue 150 path = r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional'
150 path = os.path.normpath(os.path.join(path, '..', '..')) 151 path = os.environ.get('vs2017_install', path)
151 return path 152 if os.path.exists(path):
153 return path
154 else:
155 keys = [r'HKLM\Software\Microsoft\VisualStudio\%s' % version,
156 r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\%s' % version]
157 for key in keys:
158 path = _RegistryGetValue(key, 'InstallDir')
159 if not path:
160 continue
161 path = os.path.normpath(os.path.join(path, '..', '..'))
162 return path
152 163
153 raise Exception(('Visual Studio Version %s (from GYP_MSVS_VERSION)' 164 raise Exception(('Visual Studio Version %s (from GYP_MSVS_VERSION)'
154 ' not found.') % (version_as_year)) 165 ' not found.') % (version_as_year))
155 166
156 167
157 def _VersionNumber(): 168 def _VersionNumber():
158 """Gets the standard version number ('120', '140', etc.) based on 169 """Gets the standard version number ('120', '140', etc.) based on
159 GYP_MSVS_VERSION.""" 170 GYP_MSVS_VERSION."""
160 vs_version = GetVisualStudioVersion() 171 vs_version = GetVisualStudioVersion()
161 if vs_version == '2013': 172 if vs_version == '2013':
162 return '120' 173 return '120'
163 elif vs_version == '2015': 174 elif vs_version == '2015':
164 return '140' 175 return '140'
176 elif vs_version == '2017':
177 return '150'
Sébastien Marchand 2017/05/10 21:23:49 Is it true? The files in 4e8a360587a3c8ff3fa46aa92
brucedawson 2017/05/10 21:32:32 I think VS 2017 uses 140, 141, and 150, depending
165 else: 178 else:
166 raise ValueError('Unexpected GYP_MSVS_VERSION') 179 raise ValueError('Unexpected GYP_MSVS_VERSION')
167 180
168 181
169 def _CopyRuntimeImpl(target, source, verbose=True): 182 def _CopyRuntimeImpl(target, source, verbose=True):
170 """Copy |source| to |target| if it doesn't already exist or if it needs to be 183 """Copy |source| to |target| if it doesn't already exist or if it needs to be
171 updated (comparing last modified time as an approximate float match as for 184 updated (comparing last modified time as an approximate float match as for
172 some reason the values tend to differ by ~1e-07 despite being copies of the 185 some reason the values tend to differ by ~1e-07 despite being copies of the
173 same file... https://crbug.com/603603). 186 same file... https://crbug.com/603603).
174 """ 187 """
(...skipping 14 matching lines...) Expand all
189 def _CopyRuntime2013(target_dir, source_dir, dll_pattern): 202 def _CopyRuntime2013(target_dir, source_dir, dll_pattern):
190 """Copy both the msvcr and msvcp runtime DLLs, only if the target doesn't 203 """Copy both the msvcr and msvcp runtime DLLs, only if the target doesn't
191 exist, but the target directory does exist.""" 204 exist, but the target directory does exist."""
192 for file_part in ('p', 'r'): 205 for file_part in ('p', 'r'):
193 dll = dll_pattern % file_part 206 dll = dll_pattern % file_part
194 target = os.path.join(target_dir, dll) 207 target = os.path.join(target_dir, dll)
195 source = os.path.join(source_dir, dll) 208 source = os.path.join(source_dir, dll)
196 _CopyRuntimeImpl(target, source) 209 _CopyRuntimeImpl(target, source)
197 210
198 211
199 def _CopyRuntime2015(target_dir, source_dir, dll_pattern, suffix): 212 def _CopyUCRTRuntime(target_dir, source_dir, dll_pattern, suffix):
200 """Copy both the msvcp and vccorlib runtime DLLs, only if the target doesn't 213 """Copy both the msvcp and vccorlib runtime DLLs, only if the target doesn't
201 exist, but the target directory does exist.""" 214 exist, but the target directory does exist."""
202 for file_part in ('msvcp', 'vccorlib', 'vcruntime'): 215 for file_part in ('msvcp', 'vccorlib', 'vcruntime'):
203 dll = dll_pattern % file_part 216 dll = dll_pattern % file_part
204 target = os.path.join(target_dir, dll) 217 target = os.path.join(target_dir, dll)
205 source = os.path.join(source_dir, dll) 218 source = os.path.join(source_dir, dll)
206 _CopyRuntimeImpl(target, source) 219 _CopyRuntimeImpl(target, source)
207 # OS installs of Visual Studio (and all installs of Windows 10) put the 220 # OS installs of Visual Studio (and all installs of Windows 10) put the
208 # universal CRT files in c:\Windows\System32\downlevel - look for them there 221 # universal CRT files in c:\Windows\System32\downlevel - look for them there
209 # to support DEPOT_TOOLS_WIN_TOOLCHAIN=0. 222 # to support DEPOT_TOOLS_WIN_TOOLCHAIN=0.
210 if os.path.exists(os.path.join(source_dir, 'downlevel')): 223 if os.path.exists(os.path.join(source_dir, 'downlevel')):
211 ucrt_src_glob = os.path.join(source_dir, 'downlevel', 'api-ms-win-*.dll') 224 ucrt_src_glob = os.path.join(source_dir, 'downlevel', 'api-ms-win-*.dll')
212 else: 225 else:
213 ucrt_src_glob = os.path.join(source_dir, 'api-ms-win-*.dll') 226 ucrt_src_glob = os.path.join(source_dir, 'api-ms-win-*.dll')
214 ucrt_files = glob.glob(ucrt_src_glob) 227 ucrt_files = glob.glob(ucrt_src_glob)
215 assert len(ucrt_files) > 0 228 assert len(ucrt_files) > 0
216 for ucrt_src_file in ucrt_files: 229 for ucrt_src_file in ucrt_files:
217 file_part = os.path.basename(ucrt_src_file) 230 file_part = os.path.basename(ucrt_src_file)
218 ucrt_dst_file = os.path.join(target_dir, file_part) 231 ucrt_dst_file = os.path.join(target_dir, file_part)
219 _CopyRuntimeImpl(ucrt_dst_file, ucrt_src_file, False) 232 _CopyRuntimeImpl(ucrt_dst_file, ucrt_src_file, False)
220 _CopyRuntimeImpl(os.path.join(target_dir, 'ucrtbase' + suffix), 233 _CopyRuntimeImpl(os.path.join(target_dir, 'ucrtbase' + suffix),
221 os.path.join(source_dir, 'ucrtbase' + suffix)) 234 os.path.join(source_dir, 'ucrtbase' + suffix))
222 235
223 236
224 def _CopyRuntime(target_dir, source_dir, target_cpu, debug): 237 def _CopyRuntime(target_dir, source_dir, target_cpu, debug):
225 """Copy the VS runtime DLLs, only if the target doesn't exist, but the target 238 """Copy the VS runtime DLLs, only if the target doesn't exist, but the target
226 directory does exist. Handles VS 2013 and VS 2015.""" 239 directory does exist. Handles VS 2013, VS 2015, and VS 2017."""
227 suffix = "d.dll" if debug else ".dll" 240 suffix = "d.dll" if debug else ".dll"
228 if GetVisualStudioVersion() == '2015': 241 if GetVisualStudioVersion() == '2015' or GetVisualStudioVersion() == '2017':
229 _CopyRuntime2015(target_dir, source_dir, '%s140' + suffix, suffix) 242 # VS 2017 RC uses the same CRT DLLs as VS 2015.
243 _CopyUCRTRuntime(target_dir, source_dir, '%s140' + suffix, suffix)
230 else: 244 else:
231 _CopyRuntime2013(target_dir, source_dir, 'msvc%s120' + suffix) 245 _CopyRuntime2013(target_dir, source_dir, 'msvc%s120' + suffix)
232 246
233 # Copy the PGO runtime library to the release directories. 247 # Copy the PGO runtime library to the release directories.
234 if not debug and os.environ.get('GYP_MSVS_OVERRIDE_PATH'): 248 if not debug and os.environ.get('GYP_MSVS_OVERRIDE_PATH'):
235 pgo_x86_runtime_dir = os.path.join(os.environ.get('GYP_MSVS_OVERRIDE_PATH'), 249 pgo_x86_runtime_dir = os.path.join(os.environ.get('GYP_MSVS_OVERRIDE_PATH'),
236 'VC', 'bin') 250 'VC', 'bin')
237 pgo_x64_runtime_dir = os.path.join(pgo_x86_runtime_dir, 'amd64') 251 pgo_x64_runtime_dir = os.path.join(pgo_x86_runtime_dir, 'amd64')
238 pgo_runtime_dll = 'pgort' + _VersionNumber() + '.dll' 252 pgo_runtime_dll = 'pgort' + _VersionNumber() + '.dll'
239 if target_cpu == "x86": 253 if target_cpu == "x86":
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 'copy_dlls': CopyDlls, 409 'copy_dlls': CopyDlls,
396 } 410 }
397 if len(sys.argv) < 2 or sys.argv[1] not in commands: 411 if len(sys.argv) < 2 or sys.argv[1] not in commands:
398 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) 412 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands)
399 return 1 413 return 1
400 return commands[sys.argv[1]](*sys.argv[2:]) 414 return commands[sys.argv[1]](*sys.argv[2:])
401 415
402 416
403 if __name__ == '__main__': 417 if __name__ == '__main__':
404 sys.exit(main()) 418 sys.exit(main())
OLDNEW
« no previous file with comments | « build/toolchain/win/setup_toolchain.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698