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

Side by Side Diff: build/vs_toolchain.py

Issue 2021353003: Copy local CRT DLLs to gn output directories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing quotes Created 4 years, 6 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 | « no previous file | 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 shutil 10 import shutil
11 import stat
11 import subprocess 12 import subprocess
12 import sys 13 import sys
13 14
14 15
15 script_dir = os.path.dirname(os.path.realpath(__file__)) 16 script_dir = os.path.dirname(os.path.realpath(__file__))
16 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) 17 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__))) 18 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')) 19 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib'))
19 json_data_file = os.path.join(script_dir, 'win_toolchain.json') 20 json_data_file = os.path.join(script_dir, 'win_toolchain.json')
20 21
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 os.environ['WINDOWSSDKDIR'] = win_sdk 68 os.environ['WINDOWSSDKDIR'] = win_sdk
68 os.environ['WDK_DIR'] = wdk 69 os.environ['WDK_DIR'] = wdk
69 # Include the VS runtime in the PATH in case it's not machine-installed. 70 # Include the VS runtime in the PATH in case it's not machine-installed.
70 runtime_path = os.path.pathsep.join(vs_runtime_dll_dirs) 71 runtime_path = os.path.pathsep.join(vs_runtime_dll_dirs)
71 os.environ['PATH'] = runtime_path + os.path.pathsep + os.environ['PATH'] 72 os.environ['PATH'] = runtime_path + os.path.pathsep + os.environ['PATH']
72 elif sys.platform == 'win32' and not depot_tools_win_toolchain: 73 elif sys.platform == 'win32' and not depot_tools_win_toolchain:
73 if not 'GYP_MSVS_OVERRIDE_PATH' in os.environ: 74 if not 'GYP_MSVS_OVERRIDE_PATH' in os.environ:
74 os.environ['GYP_MSVS_OVERRIDE_PATH'] = DetectVisualStudioPath() 75 os.environ['GYP_MSVS_OVERRIDE_PATH'] = DetectVisualStudioPath()
75 if not 'GYP_MSVS_VERSION' in os.environ: 76 if not 'GYP_MSVS_VERSION' in os.environ:
76 os.environ['GYP_MSVS_VERSION'] = GetVisualStudioVersion() 77 os.environ['GYP_MSVS_VERSION'] = GetVisualStudioVersion()
78 # When using an installed toolchain these files aren't needed in the output
79 # directory in order to run binaries locally, but they are needed in order
80 # to create isolates or the mini_installer. Copying them to the output
81 # directory ensures that they are available when needed.
82 if os.access('C:/Windows/SysWOW64', os.F_OK):
83 # Default 64-bit and 32-bit system directories on 64-bit Windows.
84 vs_runtime_dll_dirs = [ 'C:/Windows/System32', 'C:/Windows/SysWOW64' ]
scottmg 2016/05/31 21:57:44 Hmm, I'm confused. I would have thought it was x86
brucedawson 2016/05/31 23:32:18 I'm not sure. That's worrisome that gyp and gn beh
85 else:
86 # Default 32-bit system directories on 32-bit Windows.
87 vs_runtime_dll_dirs = [ None, 'C:/Windows/System32' ]
77 88
78 return vs_runtime_dll_dirs 89 return vs_runtime_dll_dirs
79 90
80 91
81 def _RegistryGetValueUsingWinReg(key, value): 92 def _RegistryGetValueUsingWinReg(key, value):
82 """Use the _winreg module to obtain the value of a registry key. 93 """Use the _winreg module to obtain the value of a registry key.
83 94
84 Args: 95 Args:
85 key: The registry key. 96 key: The registry key.
86 value: The particular registry value to read. 97 value: The particular registry value to read.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 updated (comparing last modified time as an approximate float match as for 168 updated (comparing last modified time as an approximate float match as for
158 some reason the values tend to differ by ~1e-07 despite being copies of the 169 some reason the values tend to differ by ~1e-07 despite being copies of the
159 same file... https://crbug.com/603603). 170 same file... https://crbug.com/603603).
160 """ 171 """
161 if (os.path.isdir(os.path.dirname(target)) and 172 if (os.path.isdir(os.path.dirname(target)) and
162 (not os.path.isfile(target) or 173 (not os.path.isfile(target) or
163 abs(os.stat(target).st_mtime - os.stat(source).st_mtime) >= 0.01)): 174 abs(os.stat(target).st_mtime - os.stat(source).st_mtime) >= 0.01)):
164 if verbose: 175 if verbose:
165 print 'Copying %s to %s...' % (source, target) 176 print 'Copying %s to %s...' % (source, target)
166 if os.path.exists(target): 177 if os.path.exists(target):
178 # Make the file writable so that we can delete it now.
179 os.chmod(target, stat.S_IWRITE)
167 os.unlink(target) 180 os.unlink(target)
168 shutil.copy2(source, target) 181 shutil.copy2(source, target)
182 # Make the file writable so that we can overwrite or delete it later.
183 os.chmod(target, stat.S_IWRITE)
169 184
170 185
171 def _CopyRuntime2013(target_dir, source_dir, dll_pattern): 186 def _CopyRuntime2013(target_dir, source_dir, dll_pattern):
172 """Copy both the msvcr and msvcp runtime DLLs, only if the target doesn't 187 """Copy both the msvcr and msvcp runtime DLLs, only if the target doesn't
173 exist, but the target directory does exist.""" 188 exist, but the target directory does exist."""
174 for file_part in ('p', 'r'): 189 for file_part in ('p', 'r'):
175 dll = dll_pattern % file_part 190 dll = dll_pattern % file_part
176 target = os.path.join(target_dir, dll) 191 target = os.path.join(target_dir, dll)
177 source = os.path.join(source_dir, dll) 192 source = os.path.join(source_dir, dll)
178 _CopyRuntimeImpl(target, source) 193 _CopyRuntimeImpl(target, source)
179 194
180 195
181 def _CopyRuntime2015(target_dir, source_dir, dll_pattern, suffix): 196 def _CopyRuntime2015(target_dir, source_dir, dll_pattern, suffix):
182 """Copy both the msvcp and vccorlib runtime DLLs, only if the target doesn't 197 """Copy both the msvcp and vccorlib runtime DLLs, only if the target doesn't
183 exist, but the target directory does exist.""" 198 exist, but the target directory does exist."""
184 for file_part in ('msvcp', 'vccorlib', 'vcruntime'): 199 for file_part in ('msvcp', 'vccorlib', 'vcruntime'):
185 dll = dll_pattern % file_part 200 dll = dll_pattern % file_part
186 target = os.path.join(target_dir, dll) 201 target = os.path.join(target_dir, dll)
187 source = os.path.join(source_dir, dll) 202 source = os.path.join(source_dir, dll)
188 _CopyRuntimeImpl(target, source) 203 _CopyRuntimeImpl(target, source)
189 ucrt_src_dir = os.path.join(source_dir, 'api-ms-win-*.dll') 204 # OS installs of Visual Studio (and all installs of Windows 10) put the
190 for ucrt_src_file in glob.glob(ucrt_src_dir): 205 # universal CRT files in c:\Windows\System32\downlevel - look for them there
206 # to support DEPOT_TOOLS_WIN_TOOLCHAIN=0.
207 if os.path.exists(os.path.join(source_dir, 'downlevel')):
208 ucrt_src_dir = os.path.join(source_dir, 'downlevel', 'api-ms-win-*.dll')
scottmg 2016/05/31 21:57:44 Maybe ucrt_src_pattern or _glob instead.
brucedawson 2016/05/31 23:32:18 Done.
209 else:
210 ucrt_src_dir = os.path.join(source_dir, 'api-ms-win-*.dll')
211 ucrt_files = glob.glob(ucrt_src_dir)
212 assert len(ucrt_files) > 0
213 for ucrt_src_file in ucrt_files:
191 file_part = os.path.basename(ucrt_src_file) 214 file_part = os.path.basename(ucrt_src_file)
192 ucrt_dst_file = os.path.join(target_dir, file_part) 215 ucrt_dst_file = os.path.join(target_dir, file_part)
193 _CopyRuntimeImpl(ucrt_dst_file, ucrt_src_file, False) 216 _CopyRuntimeImpl(ucrt_dst_file, ucrt_src_file, False)
194 _CopyRuntimeImpl(os.path.join(target_dir, 'ucrtbase' + suffix), 217 _CopyRuntimeImpl(os.path.join(target_dir, 'ucrtbase' + suffix),
195 os.path.join(source_dir, 'ucrtbase' + suffix)) 218 os.path.join(source_dir, 'ucrtbase' + suffix))
196 219
197 220
198 def _CopyRuntime(target_dir, source_dir, target_cpu, debug): 221 def _CopyRuntime(target_dir, source_dir, target_cpu, debug):
199 """Copy the VS runtime DLLs, only if the target doesn't exist, but the target 222 """Copy the VS runtime DLLs, only if the target doesn't exist, but the target
200 directory does exist. Handles VS 2013 and VS 2015.""" 223 directory does exist. Handles VS 2013 and VS 2015."""
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 'copy_dlls': CopyDlls, 396 'copy_dlls': CopyDlls,
374 } 397 }
375 if len(sys.argv) < 2 or sys.argv[1] not in commands: 398 if len(sys.argv) < 2 or sys.argv[1] not in commands:
376 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) 399 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands)
377 return 1 400 return 1
378 return commands[sys.argv[1]](*sys.argv[2:]) 401 return commands[sys.argv[1]](*sys.argv[2:])
379 402
380 403
381 if __name__ == '__main__': 404 if __name__ == '__main__':
382 sys.exit(main()) 405 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698