| 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 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 def _CopyRuntime2013(target_dir, source_dir, dll_pattern): | 202 def _CopyRuntime2013(target_dir, source_dir, dll_pattern): |
| 203 """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 |
| 204 exist, but the target directory does exist.""" | 204 exist, but the target directory does exist.""" |
| 205 for file_part in ('p', 'r'): | 205 for file_part in ('p', 'r'): |
| 206 dll = dll_pattern % file_part | 206 dll = dll_pattern % file_part |
| 207 target = os.path.join(target_dir, dll) | 207 target = os.path.join(target_dir, dll) |
| 208 source = os.path.join(source_dir, dll) | 208 source = os.path.join(source_dir, dll) |
| 209 _CopyRuntimeImpl(target, source) | 209 _CopyRuntimeImpl(target, source) |
| 210 | 210 |
| 211 | 211 |
| 212 def _CopyUCRTRuntime(target_dir, source_dir, dll_pattern, suffix): | 212 def _CopyUCRTRuntime(target_dir, source_dir, target_cpu, dll_pattern, suffix): |
| 213 """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 |
| 214 exist, but the target directory does exist.""" | 214 exist, but the target directory does exist.""" |
| 215 for file_part in ('msvcp', 'vccorlib', 'vcruntime'): | 215 for file_part in ('msvcp', 'vccorlib', 'vcruntime'): |
| 216 dll = dll_pattern % file_part | 216 dll = dll_pattern % file_part |
| 217 target = os.path.join(target_dir, dll) | 217 target = os.path.join(target_dir, dll) |
| 218 source = os.path.join(source_dir, dll) | 218 source = os.path.join(source_dir, dll) |
| 219 _CopyRuntimeImpl(target, source) | 219 _CopyRuntimeImpl(target, source) |
| 220 # OS installs of Visual Studio (and all installs of Windows 10) put the | 220 # Copy the UCRT files needed by VS 2015 from the Windows SDK. This location |
| 221 # universal CRT files in c:\Windows\System32\downlevel - look for them there | 221 # includes the api-ms-win-crt-*.dll files that are not found in the Windows |
| 222 # to support DEPOT_TOOLS_WIN_TOOLCHAIN=0. | 222 # directory. These files are needed for component builds. |
| 223 if os.path.exists(os.path.join(source_dir, 'downlevel')): | 223 # If WINDOWSSDKDIR is not set use the default SDK path. This will be the case |
| 224 ucrt_src_glob = os.path.join(source_dir, 'downlevel', 'api-ms-win-*.dll') | 224 # when DEPOT_TOOLS_WIN_TOOLCHAIN=0 and vcvarsall.bat has not been run. |
| 225 else: | 225 win_sdk_dir = os.path.normpath( |
| 226 ucrt_src_glob = os.path.join(source_dir, 'api-ms-win-*.dll') | 226 os.environ.get('WINDOWSSDKDIR', |
| 227 ucrt_files = glob.glob(ucrt_src_glob) | 227 'C:\\Program Files (x86)\\Windows Kits\\10')) |
| 228 ucrt_dll_dirs = os.path.join(win_sdk_dir, r'Redist\ucrt\DLLs', target_cpu) |
| 229 ucrt_files = glob.glob(os.path.join(ucrt_dll_dirs, 'api-ms-win-*.dll')) |
| 228 assert len(ucrt_files) > 0 | 230 assert len(ucrt_files) > 0 |
| 229 for ucrt_src_file in ucrt_files: | 231 for ucrt_src_file in ucrt_files: |
| 230 file_part = os.path.basename(ucrt_src_file) | 232 file_part = os.path.basename(ucrt_src_file) |
| 231 ucrt_dst_file = os.path.join(target_dir, file_part) | 233 ucrt_dst_file = os.path.join(target_dir, file_part) |
| 232 _CopyRuntimeImpl(ucrt_dst_file, ucrt_src_file, False) | 234 _CopyRuntimeImpl(ucrt_dst_file, ucrt_src_file, False) |
| 233 _CopyRuntimeImpl(os.path.join(target_dir, 'ucrtbase' + suffix), | 235 _CopyRuntimeImpl(os.path.join(target_dir, 'ucrtbase' + suffix), |
| 234 os.path.join(source_dir, 'ucrtbase' + suffix)) | 236 os.path.join(source_dir, 'ucrtbase' + suffix)) |
| 235 | 237 |
| 236 | 238 |
| 237 def _CopyRuntime(target_dir, source_dir, target_cpu, debug): | 239 def _CopyRuntime(target_dir, source_dir, target_cpu, debug): |
| 238 """Copy the VS runtime DLLs, only if the target doesn't exist, but the target | 240 """Copy the VS runtime DLLs, only if the target doesn't exist, but the target |
| 239 directory does exist. Handles VS 2013, VS 2015, and VS 2017.""" | 241 directory does exist. Handles VS 2013, VS 2015, and VS 2017.""" |
| 240 suffix = "d.dll" if debug else ".dll" | 242 suffix = "d.dll" if debug else ".dll" |
| 241 if GetVisualStudioVersion() in ['2015', '2017']: | 243 if GetVisualStudioVersion() in ['2015', '2017']: |
| 242 # VS 2017 uses the same CRT DLLs as VS 2015. | 244 # VS 2017 uses the same CRT DLLs as VS 2015. |
| 243 _CopyUCRTRuntime(target_dir, source_dir, '%s140' + suffix, suffix) | 245 _CopyUCRTRuntime(target_dir, source_dir, target_cpu, '%s140' + suffix, |
| 246 suffix) |
| 244 else: | 247 else: |
| 245 _CopyRuntime2013(target_dir, source_dir, 'msvc%s120' + suffix) | 248 _CopyRuntime2013(target_dir, source_dir, 'msvc%s120' + suffix) |
| 246 | 249 |
| 247 # Copy the PGO runtime library to the release directories. | 250 # Copy the PGO runtime library to the release directories. |
| 248 if not debug and os.environ.get('GYP_MSVS_OVERRIDE_PATH'): | 251 if not debug and os.environ.get('GYP_MSVS_OVERRIDE_PATH'): |
| 249 pgo_x86_runtime_dir = os.path.join(os.environ.get('GYP_MSVS_OVERRIDE_PATH'), | 252 pgo_x86_runtime_dir = os.path.join(os.environ.get('GYP_MSVS_OVERRIDE_PATH'), |
| 250 'VC', 'bin') | 253 'VC', 'bin') |
| 251 pgo_x64_runtime_dir = os.path.join(pgo_x86_runtime_dir, 'amd64') | 254 pgo_x64_runtime_dir = os.path.join(pgo_x86_runtime_dir, 'amd64') |
| 252 pgo_runtime_dll = 'pgort' + _VersionNumber() + '.dll' | 255 pgo_runtime_dll = 'pgort' + _VersionNumber() + '.dll' |
| 253 if target_cpu == "x86": | 256 if target_cpu == "x86": |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 'copy_dlls': CopyDlls, | 445 'copy_dlls': CopyDlls, |
| 443 } | 446 } |
| 444 if len(sys.argv) < 2 or sys.argv[1] not in commands: | 447 if len(sys.argv) < 2 or sys.argv[1] not in commands: |
| 445 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) | 448 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) |
| 446 return 1 | 449 return 1 |
| 447 return commands[sys.argv[1]](*sys.argv[2:]) | 450 return commands[sys.argv[1]](*sys.argv[2:]) |
| 448 | 451 |
| 449 | 452 |
| 450 if __name__ == '__main__': | 453 if __name__ == '__main__': |
| 451 sys.exit(main()) | 454 sys.exit(main()) |
| OLD | NEW |