chromium-src-build/win/copy_cdb_to_output.py

128 строки
4.7 KiB
Python
Исходник Обычный вид История

#!/usr/bin/env python
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from __future__ import print_function
Switch to VS 2015 Update 3 VS 2015 Update 3 offers numerous improvements such as improved language conformance, fixes to avoid linker crashes, and improved code-gen for faster performance. Update 3 also resolves some problems with incremental linking silently falling back to a full link. It also fixes an internal compiler error in /analyze builds. The landmines change is needed because otherwise things like the out\Release\cdb directory do not get regenerated. The process for creating this package is: - Create a clean Windows VM running Windows Server 2012 R2 (en_windows_server_2012_r2_vl_with_update_x64_dvd_6052766.iso, SHA1: 247EAEE5628850A41F0C51471656AAFB2492EA08, Standard Edition) - Install depot tools, run ‘gclient’, and add depot_tools to the path - Install VS 2015 Professional Update 3 - must have been installed after July 12th to get the latest fixes - with these settings and nothing else: * Visual C++ and make sure the three nodes underneath are also selected * Under Universal Windows App Development Tools make sure the "Tools (1.4.1) and Windows 10 SDK (10.0.14393)" and the "Windows 10 SDK (10.0.10586)" nodes are selected and nothing else - Copy the *Debugger and Tools*.msi installers from another machine and run them. The 10.0.14393 versions (Anniversary Edition) should be used. - Then run: python depot_tools\win_toolchain\package_from_installed.py 2015 It is also possible to package the 14393 SDK by running this command, but that change is being saved for later: python depot_tools\win_toolchain\package_from_installed.py 2015 -w 10.0.14393.0 BUG=627216,636468,427616,637456 Review-Url: https://codereview.chromium.org/2106203002 Cr-Original-Commit-Position: refs/heads/master@{#417157} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 02343c661ee0482cb73ad0cf861999f2c57eeb11
2016-09-08 04:53:00 +03:00
import glob
import hashlib
import os
import shutil
import sys
script_dir = os.path.dirname(os.path.realpath(__file__))
src_build_dir = os.path.abspath(os.path.join(script_dir, os.pardir))
sys.path.insert(0, src_build_dir)
import vs_toolchain
def _HexDigest(file_name):
hasher = hashlib.sha256()
afile = open(file_name, 'rb')
blocksize = 65536
buf = afile.read(blocksize)
while len(buf) > 0:
hasher.update(buf)
buf = afile.read(blocksize)
afile.close()
return hasher.hexdigest()
def _CopyImpl(file_name, target_dir, source_dir, verbose=False):
"""Copy |source| to |target| if it doesn't already exist or if it
needs to be updated.
"""
target = os.path.join(target_dir, file_name)
source = os.path.join(source_dir, file_name)
if (os.path.isdir(os.path.dirname(target)) and
((not os.path.isfile(target)) or
_HexDigest(source) != _HexDigest(target))):
if verbose:
print('Copying %s to %s...' % (source, target))
if os.path.exists(target):
os.unlink(target)
shutil.copy(source, target)
def _ConditionalMkdir(output_dir):
if not os.path.isdir(output_dir):
os.makedirs(output_dir)
def _CopyCDBToOutput(output_dir, target_arch):
"""Copies the Windows debugging executable cdb.exe to the output
directory, which is created if it does not exist. The output
directory, and target architecture that should be copied, are
passed. Supported values for the target architecture are the GYP
values "ia32", "x64", "arm64" and the GN values "x86", "x64", "arm64".
"""
_ConditionalMkdir(output_dir)
vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
# If WINDOWSSDKDIR is not set use the default SDK path. This will be the case
# when DEPOT_TOOLS_WIN_TOOLCHAIN=0 and vcvarsall.bat has not been run.
win_sdk_dir = os.path.normpath(
os.environ.get('WINDOWSSDKDIR',
Reland "Fixed SDK lookup for non C:\ Windows installation." This reverts commit 864136ef9686128f4afbfe6146cd3e2d08182d52. Reason for revert: While it seems this did trigger the cdb failures in crbug.com/846313, it was not the root cause and reverting it didn't actually help. Original change's description: > Revert "Fixed SDK lookup for non C:\ Windows installation." > > This reverts commit 57fd44c74e13be05a3091976f9bcee39ee8f703e. > > Reason for revert: suspect for messing up symbols on Win7 bot > @ crbug.com/846313 > > Original change's description: > > Fixed SDK lookup for non C:\ Windows installation. > > > > Bug: None > > Change-Id: Ia0aa186d1d39b1beac8ce0152683f774ad5d2eaf > > Reviewed-on: https://chromium-review.googlesource.com/1066065 > > Reviewed-by: Jochen Eisinger <jochen@chromium.org> > > Commit-Queue: Jochen Eisinger <jochen@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#561063} > > TBR=jochen@chromium.org,yura.yaroshevich@gmail.com > > # Not skipping CQ checks because original CL landed > 1 day ago. > > Bug: 846313 > Change-Id: Id93a965aea5555961c539d47e05e79410894eff8 > Reviewed-on: https://chromium-review.googlesource.com/1072307 > Commit-Queue: Gabriel Charette <gab@chromium.org> > Reviewed-by: Gabriel Charette <gab@chromium.org> > Cr-Commit-Position: refs/heads/master@{#561609} TBR=gab@chromium.org,jochen@chromium.org,yura.yaroshevich@gmail.com Bug: 846313 Change-Id: I9955a47bbe8a81a0dcf7befebfc422560f8a1cc4 Reviewed-on: https://chromium-review.googlesource.com/1073314 Reviewed-by: Hans Wennborg <hans@chromium.org> Commit-Queue: Hans Wennborg <hans@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#561873} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 2e7257da41fbc81029fae5f306ae8123ec975f0c
2018-05-25 17:41:24 +03:00
os.path.expandvars('%ProgramFiles(x86)%'
'\\Windows Kits\\10')))
if target_arch == 'ia32' or target_arch == 'x86':
src_arch = 'x86'
elif target_arch in ['x64', 'arm64']:
src_arch = target_arch
else:
print('copy_cdb_to_output.py: unknown target_arch %s' % target_arch)
sys.exit(1)
# We need to copy multiple files, so cache the computed source directory.
src_dir = os.path.join(win_sdk_dir, 'Debuggers', src_arch)
# We need to copy some helper DLLs to get access to the !uniqstack
# command to dump all threads' stacks.
src_winext_dir = os.path.join(src_dir, 'winext')
dst_winext_dir = os.path.join(output_dir, 'winext')
src_winxp_dir = os.path.join(src_dir, 'winxp')
dst_winxp_dir = os.path.join(output_dir, 'winxp')
# Starting with the 10.0.17763 SDK the ucrt files are in a version-named
# directory - this handles both cases.
redist_dir = os.path.join(win_sdk_dir, 'Redist')
version_dirs = glob.glob(os.path.join(redist_dir, '10.*'))
if len(version_dirs) > 0:
version_dirs.sort(reverse=True)
redist_dir = version_dirs[0]
src_crt_dir = os.path.join(redist_dir, 'ucrt', 'DLLs', src_arch)
_ConditionalMkdir(dst_winext_dir)
_ConditionalMkdir(dst_winxp_dir)
# Note that the outputs from the "copy_cdb_to_output" target need to
# be kept in sync with this list.
_CopyImpl('cdb.exe', output_dir, src_dir)
_CopyImpl('dbgeng.dll', output_dir, src_dir)
_CopyImpl('dbghelp.dll', output_dir, src_dir)
_CopyImpl('dbgmodel.dll', output_dir, src_dir)
_CopyImpl('ext.dll', dst_winext_dir, src_winext_dir)
_CopyImpl('uext.dll', dst_winext_dir, src_winext_dir)
_CopyImpl('exts.dll', dst_winxp_dir, src_winxp_dir)
_CopyImpl('ntsdexts.dll', dst_winxp_dir, src_winxp_dir)
if src_arch in ['x64', 'x86']:
# Copy all UCRT files from the debuggers directory, for compatibility with
# the Windows 10 18362 SDK (one UCRT file) and later versions (two UCRT
# files). The new file is api-ms-win-downlevel-kernel32-l2-1-0.dll and
# should be added to the copy_cdb_to_output outputs when we require a newer
# SDK.
for file in glob.glob(os.path.join(src_dir, 'api-ms-win*.dll')):
_CopyImpl(os.path.split(file)[1], output_dir, src_dir)
_CopyImpl('ucrtbase.dll', output_dir, src_crt_dir)
Switch to VS 2015 Update 3 VS 2015 Update 3 offers numerous improvements such as improved language conformance, fixes to avoid linker crashes, and improved code-gen for faster performance. Update 3 also resolves some problems with incremental linking silently falling back to a full link. It also fixes an internal compiler error in /analyze builds. The landmines change is needed because otherwise things like the out\Release\cdb directory do not get regenerated. The process for creating this package is: - Create a clean Windows VM running Windows Server 2012 R2 (en_windows_server_2012_r2_vl_with_update_x64_dvd_6052766.iso, SHA1: 247EAEE5628850A41F0C51471656AAFB2492EA08, Standard Edition) - Install depot tools, run ‘gclient’, and add depot_tools to the path - Install VS 2015 Professional Update 3 - must have been installed after July 12th to get the latest fixes - with these settings and nothing else: * Visual C++ and make sure the three nodes underneath are also selected * Under Universal Windows App Development Tools make sure the "Tools (1.4.1) and Windows 10 SDK (10.0.14393)" and the "Windows 10 SDK (10.0.10586)" nodes are selected and nothing else - Copy the *Debugger and Tools*.msi installers from another machine and run them. The 10.0.14393 versions (Anniversary Edition) should be used. - Then run: python depot_tools\win_toolchain\package_from_installed.py 2015 It is also possible to package the 14393 SDK by running this command, but that change is being saved for later: python depot_tools\win_toolchain\package_from_installed.py 2015 -w 10.0.14393.0 BUG=627216,636468,427616,637456 Review-Url: https://codereview.chromium.org/2106203002 Cr-Original-Commit-Position: refs/heads/master@{#417157} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 02343c661ee0482cb73ad0cf861999f2c57eeb11
2016-09-08 04:53:00 +03:00
for dll_path in glob.glob(os.path.join(src_crt_dir, 'api-ms-win-*.dll')):
_CopyImpl(os.path.split(dll_path)[1], output_dir, src_crt_dir)
return 0
def main():
if len(sys.argv) < 2:
print('Usage: copy_cdb_to_output.py <output_dir> ' + \
'<target_arch>', file=sys.stderr)
return 1
return _CopyCDBToOutput(sys.argv[1], sys.argv[2])
if __name__ == '__main__':
sys.exit(main())