1
0
mirror of https://github.com/dart-lang/sdk synced 2024-07-01 07:14:29 +00:00

[build] Update Windows SDK to 10.0.22621.0.

Sync setup_toolchain.py, vs_toolchain.py, find_depot_tools.py with chromium tot 2a6e67243533df4913d06814019b99a8b3ea385b

BUG=https://github.com/dart-lang/sdk/issues/54630

Change-Id: I42f79900951f228d8c9711fee3cab7db22f96e19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350655
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Alexander Aprelev 2024-02-08 16:06:50 +00:00 committed by Commit Queue
parent 26aa50fdbf
commit 6ab194a95b
4 changed files with 174 additions and 168 deletions

View File

@ -1,81 +1,74 @@
#!/usr/bin/env python3
# Copyright (c) 2011 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.
#
# For Dart/Flutter developers:
# This file is copied from Chromium:
# https://cs.chromium.org/chromium/src/build/find_depot_tools.py
# When updating replace reference to python on the first line with python3.
#
"""Small utility function to find depot_tools and add it to the python path.
Will throw an ImportError exception if depot_tools can't be found since it
imports breakpad.
This can also be used as a standalone script to print out the depot_tools
directory location.
"""
from __future__ import print_function
import os
import sys
# Path to //src
SRC = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
def IsRealDepotTools(path):
expanded_path = os.path.expanduser(path)
return os.path.isfile(os.path.join(expanded_path, 'gclient.py'))
def add_depot_tools_to_path():
"""Search for depot_tools and add it to sys.path."""
# First, check if we have a DEPS'd in "depot_tools".
deps_depot_tools = os.path.join(SRC, 'third_party', 'depot_tools')
if IsRealDepotTools(deps_depot_tools):
# Put the pinned version at the start of the sys.path, in case there
# are other non-pinned versions already on the sys.path.
sys.path.insert(0, deps_depot_tools)
return deps_depot_tools
# Then look if depot_tools is already in PYTHONPATH.
for i in sys.path:
if i.rstrip(os.sep).endswith('depot_tools') and IsRealDepotTools(i):
return i
# Then look if depot_tools is in PATH, common case.
for i in os.environ['PATH'].split(os.pathsep):
if IsRealDepotTools(i):
sys.path.append(i.rstrip(os.sep))
return i
# Rare case, it's not even in PATH, look upward up to root.
root_dir = os.path.dirname(os.path.abspath(__file__))
previous_dir = os.path.abspath(__file__)
while root_dir and root_dir != previous_dir:
i = os.path.join(root_dir, 'depot_tools')
if IsRealDepotTools(i):
sys.path.append(i)
return i
previous_dir = root_dir
root_dir = os.path.dirname(root_dir)
print('Failed to find depot_tools', file=sys.stderr)
return None
DEPOT_TOOLS_PATH = add_depot_tools_to_path()
# pylint: disable=W0611
import breakpad
def main():
if DEPOT_TOOLS_PATH is None:
return 1
print(DEPOT_TOOLS_PATH)
return 0
if __name__ == '__main__':
sys.exit(main())
#!/usr/bin/env python3
# Copyright 2011 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Small utility function to find depot_tools and add it to the python path.
Will throw an ImportError exception if depot_tools can't be found since it
imports breakpad.
This can also be used as a standalone script to print out the depot_tools
directory location.
"""
import os
import sys
# Path to //src
SRC = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
def IsRealDepotTools(path):
expanded_path = os.path.expanduser(path)
return os.path.isfile(os.path.join(expanded_path, 'gclient.py'))
def add_depot_tools_to_path():
"""Search for depot_tools and add it to sys.path."""
# First, check if we have a DEPS'd in "depot_tools".
deps_depot_tools = os.path.join(SRC, 'third_party', 'depot_tools')
if IsRealDepotTools(deps_depot_tools):
# Put the pinned version at the start of the sys.path, in case there
# are other non-pinned versions already on the sys.path.
sys.path.insert(0, deps_depot_tools)
return deps_depot_tools
# Then look if depot_tools is already in PYTHONPATH.
for i in sys.path:
if i.rstrip(os.sep).endswith('depot_tools') and IsRealDepotTools(i):
return i
# Then look if depot_tools is in PATH, common case.
for i in os.environ['PATH'].split(os.pathsep):
if IsRealDepotTools(i):
sys.path.append(i.rstrip(os.sep))
return i
# Rare case, it's not even in PATH, look upward up to root.
root_dir = os.path.dirname(os.path.abspath(__file__))
previous_dir = os.path.abspath(__file__)
while root_dir and root_dir != previous_dir:
i = os.path.join(root_dir, 'depot_tools')
if IsRealDepotTools(i):
sys.path.append(i)
return i
previous_dir = root_dir
root_dir = os.path.dirname(root_dir)
print('Failed to find depot_tools', file=sys.stderr)
return None
DEPOT_TOOLS_PATH = add_depot_tools_to_path()
# pylint: disable=W0611
import breakpad
def main():
if DEPOT_TOOLS_PATH is None:
return 1
print(DEPOT_TOOLS_PATH)
return 0
if __name__ == '__main__':
sys.exit(main())

View File

@ -1,4 +1,4 @@
# Copyright (c) 2013 The Chromium Authors. All rights reserved.
# Copyright 2013 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
@ -10,7 +10,6 @@
# win tool. The script assumes that the root build directory is the current dir
# and the files will be written to the current directory.
from __future__ import print_function
import errno
import json
@ -23,6 +22,8 @@ sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
import gn_helpers
SCRIPT_DIR = os.path.dirname(__file__)
SDK_VERSION = '10.0.22621.0'
def _ExtractImportantEnvironment(output_of_set):
"""Extracts environment variables required for the toolchain to run from
@ -184,7 +185,7 @@ def _LoadToolchainEnv(cpu, toolchain_root, sdk_dir, target_store):
# Explicitly specifying the SDK version to build with to avoid accidentally
# building with a new and untested SDK. This should stay in sync with the
# packaged toolchain in build/vs_toolchain.py.
args.append('10.0.20348.0')
args.append(SDK_VERSION)
variables = _LoadEnvFromBat(args)
return _ExtractImportantEnvironment(variables)
@ -283,32 +284,44 @@ def main():
lib = [p.replace('"', r'\"') for p in env['LIB'].split(';') if p]
lib = list(map(relflag, lib))
include_I = ' '.join([q('/I' + i) for i in include])
include_imsvc = ' '.join([q('-imsvc' + i) for i in include])
libpath_flags = ' '.join([q('-libpath:' + i) for i in lib])
include_I = ['/I' + i for i in include]
include_imsvc = ['-imsvc' + i for i in include]
libpath_flags = ['-libpath:' + i for i in lib]
if (environment_block_name != ''):
env_block = _FormatAsEnvironmentBlock(env)
with open(environment_block_name, 'w') as f:
with open(environment_block_name, 'w', encoding='utf8') as f:
f.write(env_block)
def ListToArgString(x):
return gn_helpers.ToGNString(' '.join(q(i) for i in x))
def ListToArgList(x):
return f'[{", ".join(gn_helpers.ToGNString(i) for i in x)}]'
print('vc_bin_dir = ' + gn_helpers.ToGNString(vc_bin_dir))
assert include_I
print('include_flags_I = ' + gn_helpers.ToGNString(include_I))
print(f'include_flags_I = {ListToArgString(include_I)}')
print(f'include_flags_I_list = {ListToArgList(include_I)}')
assert include_imsvc
if bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', 1))) and win_sdk_path:
print('include_flags_imsvc = ' +
gn_helpers.ToGNString(q('/winsysroot' + relflag(toolchain_root))))
flags = ['/winsysroot' + relflag(toolchain_root)]
print(f'include_flags_imsvc = {ListToArgString(flags)}')
print(f'include_flags_imsvc_list = {ListToArgList(flags)}')
else:
print('include_flags_imsvc = ' + gn_helpers.ToGNString(include_imsvc))
print(f'include_flags_imsvc = {ListToArgString(include_imsvc)}')
print(f'include_flags_imsvc_list = {ListToArgList(include_imsvc)}')
print('paths = ' + gn_helpers.ToGNString(env['PATH']))
assert libpath_flags
print('libpath_flags = ' + gn_helpers.ToGNString(libpath_flags))
print(f'libpath_flags = {ListToArgString(libpath_flags)}')
print(f'libpath_flags_list = {ListToArgList(libpath_flags)}')
if bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', 1))) and win_sdk_path:
print('libpath_lldlink_flags = ' +
gn_helpers.ToGNString(q('/winsysroot:' + relflag(toolchain_root))))
flags = ['/winsysroot:' + relflag(toolchain_root)]
print(f'libpath_lldlink_flags = {ListToArgString(flags)}')
print(f'libpath_lldlink_flags_list = {ListToArgList(flags)}')
else:
print('libpath_lldlink_flags = ' + gn_helpers.ToGNString(libpath_flags))
print(f'libpath_lldlink_flags = {ListToArgString(libpath_flags)}')
print(f'libpath_lldlink_flags_list = {ListToArgList(libpath_flags)}')
if __name__ == '__main__':

View File

@ -1,14 +1,8 @@
#!/usr/bin/env python3
# Copyright 2014 The Chromium Authors. All rights reserved.
# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# For Dart/Flutter developers:
# This file is copied from Chromium:
# https://cs.chromium.org/chromium/src/build/vs_toolchain.py
# When updating replace reference to python on the first line with python3.
#
from __future__ import print_function
import collections
import glob
@ -23,8 +17,7 @@ import sys
from gn_helpers import ToGNString
# VS 2019 16.61 with 10.0.20348.0 SDK, 10.0.19041 version of Debuggers
# with ARM64 libraries and UWP support.
# VS 2022 17.4 with 10.0.22621.0 SDK with ARM64 libraries and UWP support.
# See go/chromium-msvc-toolchain for instructions about how to update the
# toolchain.
#
@ -33,11 +26,21 @@ from gn_helpers import ToGNString
#
# * //base/win/windows_version.cc NTDDI preprocessor check
# Triggers a compiler error if the available SDK is older than the minimum.
# * SDK_VERSION in this file
# Must match the packaged/required SDK version.
# * SDK_VERSION in build/toolchain/win/setup_toolchain.py.
# * //build/config/win/BUILD.gn NTDDI_VERSION value
# Affects the availability of APIs in the toolchain headers.
# * //docs/windows_build_instructions.md mentions of VS or Windows SDK.
# Keeps the document consistent with the toolchain version.
TOOLCHAIN_HASH = '1023ce2e82'
# * //tools/win/setenv.py
# Add/remove VS versions when upgrading to a new VS version.
# * MSVC_TOOLSET_VERSION in this file
# Maps between Visual Studio version and MSVC toolset
# * MSVS_VERSIONS in this file
# Records the packaged and default version of Visual Studio
TOOLCHAIN_HASH = '27370823e7'
SDK_VERSION = '10.0.22621.0'
script_dir = os.path.dirname(os.path.realpath(__file__))
json_data_file = os.path.join(script_dir, 'win_toolchain.json')
@ -46,8 +49,8 @@ json_data_file = os.path.join(script_dir, 'win_toolchain.json')
# The first version is assumed by this script to be the one that is packaged,
# which makes a difference for the arm64 runtime.
MSVS_VERSIONS = collections.OrderedDict([
('2019', '16.0'), # Default and packaged version of Visual Studio.
('2022', '17.0'),
('2022', '17.0'), # Default and packaged version of Visual Studio.
('2019', '16.0'),
('2017', '15.0'),
])
@ -305,47 +308,28 @@ def _CopyUCRTRuntime(target_dir, source_dir, target_cpu, suffix):
target = os.path.join(target_dir, dll)
source = os.path.join(source_dir, dll)
_CopyRuntimeImpl(target, source)
# Copy the UCRT files from the Windows SDK. This location includes the
# api-ms-win-crt-*.dll files that are not found in the Windows directory.
# These files are needed for component builds. 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',
os.path.expandvars('%ProgramFiles(x86)%'
'\\Windows Kits\\10')))
# ARM64 doesn't have a redist for the ucrt DLLs because they are always
# present in the OS.
if target_cpu != 'arm64':
# 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:
_SortByHighestVersionNumberFirst(version_dirs)
redist_dir = version_dirs[0]
ucrt_dll_dirs = os.path.join(redist_dir, 'ucrt', 'DLLs', target_cpu)
ucrt_files = glob.glob(os.path.join(ucrt_dll_dirs, 'api-ms-win-*.dll'))
assert len(ucrt_files) > 0
for ucrt_src_file in ucrt_files:
file_part = os.path.basename(ucrt_src_file)
ucrt_dst_file = os.path.join(target_dir, file_part)
_CopyRuntimeImpl(ucrt_dst_file, ucrt_src_file, False)
# We must copy ucrtbase.dll for x64/x86, and ucrtbased.dll for all CPU types.
if target_cpu != 'arm64' or not suffix.startswith('.'):
if not suffix.startswith('.'):
# ucrtbased.dll is located at {win_sdk_dir}/bin/{a.b.c.d}/{target_cpu}/
# ucrt/.
sdk_bin_root = os.path.join(win_sdk_dir, 'bin')
sdk_bin_sub_dirs = glob.glob(os.path.join(sdk_bin_root, '10.*'))
# Select the most recent SDK if there are multiple versions installed.
_SortByHighestVersionNumberFirst(sdk_bin_sub_dirs)
for directory in sdk_bin_sub_dirs:
sdk_redist_root_version = os.path.join(sdk_bin_root, directory)
if not os.path.isdir(sdk_redist_root_version):
continue
source_dir = os.path.join(sdk_redist_root_version, target_cpu, 'ucrt')
break
# We must copy ucrtbased.dll for all CPU types. The rest of the Universal CRT
# is installed as part of the OS in Windows 10 and beyond.
if not suffix.startswith('.'):
win_sdk_dir = os.path.normpath(
os.environ.get(
'WINDOWSSDKDIR',
os.path.expandvars('%ProgramFiles(x86)%'
'\\Windows Kits\\10')))
# ucrtbased.dll is located at {win_sdk_dir}/bin/{a.b.c.d}/{target_cpu}/
# ucrt/.
sdk_bin_root = os.path.join(win_sdk_dir, 'bin')
sdk_bin_sub_dirs = glob.glob(os.path.join(sdk_bin_root, '10.*'))
# Select the most recent SDK if there are multiple versions installed.
_SortByHighestVersionNumberFirst(sdk_bin_sub_dirs)
for directory in sdk_bin_sub_dirs:
sdk_redist_root_version = os.path.join(sdk_bin_root, directory)
if not os.path.isdir(sdk_redist_root_version):
continue
source_dir = os.path.join(sdk_redist_root_version, target_cpu, 'ucrt')
if not os.path.isdir(source_dir):
continue
break
_CopyRuntimeImpl(os.path.join(target_dir, 'ucrtbase' + suffix),
os.path.join(source_dir, 'ucrtbase' + suffix))
@ -414,20 +398,33 @@ def CopyDlls(target_dir, configuration, target_cpu):
if configuration == 'Debug':
_CopyRuntime(target_dir, runtime_dir, target_cpu, debug=True)
_CopyDebugger(target_dir, target_cpu)
if target_cpu == 'arm64':
target_dir = os.path.join(target_dir, 'win_clang_x64')
target_cpu = 'x64'
runtime_dir = x64_runtime
os.makedirs(target_dir, exist_ok=True)
_CopyRuntime(target_dir, runtime_dir, target_cpu, debug=False)
if configuration == 'Debug':
_CopyRuntime(target_dir, runtime_dir, target_cpu, debug=True)
_CopyDebugger(target_dir, target_cpu)
def _CopyDebugger(target_dir, target_cpu):
"""Copy dbghelp.dll and dbgcore.dll into the requested directory as needed.
"""Copy dbghelp.dll, dbgcore.dll, and msdia140.dll into the requested
directory.
target_cpu is one of 'x86', 'x64' or 'arm64'.
dbghelp.dll is used when Chrome needs to symbolize stacks. Copying this file
from the SDK directory avoids using the system copy of dbghelp.dll which then
ensures compatibility with recent debug information formats, such as VS
2017 /debug:fastlink PDBs.
ensures compatibility with recent debug information formats, such as
large-page PDBs. Note that for these DLLs to be deployed to swarming bots they
also need to be listed in group("runtime_libs").
dbgcore.dll is needed when using some functions from dbghelp.dll (like
MinidumpWriteDump).
msdia140.dll is needed for tools like symupload.exe and dump_syms.exe.
"""
win_sdk_dir = SetEnvironmentAndGetSDKDir()
if not win_sdk_dir:
@ -436,10 +433,6 @@ def _CopyDebugger(target_dir, target_cpu):
# List of debug files that should be copied, the first element of the tuple is
# the name of the file and the second indicates if it's optional.
debug_files = [('dbghelp.dll', False), ('dbgcore.dll', True)]
# The UCRT is not a redistributable component on arm64.
if target_cpu != 'arm64':
debug_files.extend([('api-ms-win-downlevel-kernel32-l2-1-0.dll', False),
('api-ms-win-eventing-provider-l1-1-0.dll', False)])
for debug_file, is_optional in debug_files:
full_path = os.path.join(win_sdk_dir, 'Debuggers', target_cpu, debug_file)
if not os.path.exists(full_path):
@ -447,12 +440,18 @@ def _CopyDebugger(target_dir, target_cpu):
continue
else:
raise Exception('%s not found in "%s"\r\nYou must install '
'Windows 10 SDK version 10.0.20348.0 including the '
'Windows 10 SDK version %s including the '
'"Debugging Tools for Windows" feature.' %
(debug_file, full_path))
(debug_file, full_path, SDK_VERSION))
target_path = os.path.join(target_dir, debug_file)
_CopyRuntimeImpl(target_path, full_path)
# The x64 version of msdia140.dll is always used because symupload and
# dump_syms are always built as x64 binaries.
dia_path = os.path.join(NormalizePath(os.environ['GYP_MSVS_OVERRIDE_PATH']),
'DIA SDK', 'bin', 'amd64', 'msdia140.dll')
_CopyRuntimeImpl(os.path.join(target_dir, 'msdia140.dll'), dia_path)
def _GetDesiredVsToolchainHashes():
"""Load a list of SHA1s corresponding to the toolchains that we want installed
@ -503,8 +502,7 @@ def Update(force=False, no_download=False):
# For testing this block, unmount existing mounts with
# fusermount -u third_party/depot_tools/win_toolchain/vs_files
if sys.platform.startswith('linux') and not os.path.ismount(toolchain_dir):
import distutils.spawn
ciopfs = distutils.spawn.find_executable('ciopfs')
ciopfs = shutil.which('ciopfs')
if not ciopfs:
# ciopfs not found in PATH; try the one downloaded from the DEPS hook.
ciopfs = os.path.join(script_dir, 'ciopfs')
@ -563,11 +561,13 @@ def GetToolchainDir():
win_sdk_dir = SetEnvironmentAndGetSDKDir()
print('''vs_path = %s
sdk_version = %s
sdk_path = %s
vs_version = %s
wdk_dir = %s
runtime_dirs = %s
''' % (ToGNString(NormalizePath(os.environ['GYP_MSVS_OVERRIDE_PATH'])),
''' % (ToGNString(NormalizePath(
os.environ['GYP_MSVS_OVERRIDE_PATH'])), ToGNString(SDK_VERSION),
ToGNString(win_sdk_dir), ToGNString(GetVisualStudioVersion()),
ToGNString(NormalizePath(os.environ.get('WDK_DIR', ''))),
ToGNString(os.path.pathsep.join(runtime_dll_dirs or ['None']))))

View File

@ -84,12 +84,12 @@ def GenerateCompileCommands(options):
# Add sysroot from out\DebugX64\environment.x64 on Windows.
# TODO(dacoharkes): Fetch the paths from that file.
windowsSysroots = [
'C:\\src\\depot_tools\\win_toolchain\\vs_files\\1023ce2e82\\Windows Kits\\10\\Include\\10.0.20348.0\\um',
'C:\\src\\depot_tools\\win_toolchain\\vs_files\\1023ce2e82\\Windows Kits\\10\\Include\\10.0.20348.0\\shared',
'C:\\src\\depot_tools\\win_toolchain\\vs_files\\1023ce2e82\\Windows Kits\\10\\Include\\10.0.20348.0\\winrt',
'C:\\src\\depot_tools\\win_toolchain\\vs_files\\1023ce2e82\\Windows Kits\\10\\Include\\10.0.20348.0\\ucrt',
'C:\\src\\depot_tools\\win_toolchain\\vs_files\\1023ce2e82\\VC\\Tools\\MSVC\\14.29.30133\\include',
'C:\\src\\depot_tools\\win_toolchain\\vs_files\\1023ce2e82\\VC\\Tools\\MSVC\\14.29.30133\\atlmfc\\include',
'C:\\src\\depot_tools\\win_toolchain\\vs_files\\27370823e7\\Windows Kits\\10\\Include\\10.0.22621.0\\um',
'C:\\src\\depot_tools\\win_toolchain\\vs_files\\27370823e7\\Windows Kits\\10\\Include\\10.0.22621.0\\shared',
'C:\\src\\depot_tools\\win_toolchain\\vs_files\\27370823e7\\Windows Kits\\10\\Include\\10.0.22621.0\\winrt',
'C:\\src\\depot_tools\\win_toolchain\\vs_files\\27370823e7\\Windows Kits\\10\\Include\\10.0.22621.0\\ucrt',
'C:\\src\\depot_tools\\win_toolchain\\vs_files\\27370823e7\\VC\\Tools\\MSVC\\14.34.31933\\include',
'C:\\src\\depot_tools\\win_toolchain\\vs_files\\27370823e7\\VC\\Tools\\MSVC\\14.34.31933\\atlmfc\\include',
]
for windowsSysroot in windowsSysroots:
command = command.replace(