Commit 3fe941c4 authored by Nico Weber's avatar Nico Weber Committed by LUCI CQ

win toolchain packager: Put win sdk in "Windows Kits/10/" instead of "win_sdk/"

This is so that the packaged toolchain can be used with clang-cl's
new /winsysroot flag added in https://reviews.llvm.org/rG82847436e.
No impact yet on the chrome build yet -- the tooling should
transparently get the new Windows Sdk path via the generated SetEnv
json file and use it with -imsvc. (I tested this locally by tweaking
my installed hermetic win package to look like the one generated
by this CL.)

Once this is deployed, we can switch the chrome build to use
/winsysroot if we want to -- it'd make compile command lines
a bit shorter and easier to work with.

Depends on https://chromium-review.googlesource.com/c/chromium/src/+/2665866

Bug: 1173176
Change-Id: I04c435f2323f26e3c26ed82656929809a7e0b5e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2655836Reviewed-by: 's avatarBruce Dawson <brucedawson@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Auto-Submit: Nico Weber <thakis@chromium.org>
parent a4612847
...@@ -81,8 +81,9 @@ def BuildRepackageFileList(src_dir): ...@@ -81,8 +81,9 @@ def BuildRepackageFileList(src_dir):
if src_dir.endswith('\\'): if src_dir.endswith('\\'):
src_dir = src_dir[:-1] src_dir = src_dir[:-1]
# Ensure .\win_sdk\Debuggers exists and fail to repackage if it doesn't. # Ensure .\Windows Kits\10\Debuggers exists and fail to repackage if it
debuggers_path = os.path.join(src_dir, 'win_sdk', 'Debuggers') # doesn't.
debuggers_path = os.path.join(src_dir, 'Windows Kits', '10', 'Debuggers')
if not os.path.exists(debuggers_path): if not os.path.exists(debuggers_path):
raise Exception('Repacking failed. Missing %s.' % (debuggers_path)) raise Exception('Repacking failed. Missing %s.' % (debuggers_path))
...@@ -124,13 +125,15 @@ def BuildFileList(override_dir, include_arm): ...@@ -124,13 +125,15 @@ def BuildFileList(override_dir, include_arm):
paths += [ paths += [
('VC/redist/MSVC/14.*.*/x86/Microsoft.VC*.CRT', 'sys32'), ('VC/redist/MSVC/14.*.*/x86/Microsoft.VC*.CRT', 'sys32'),
('VC/redist/MSVC/14.*.*/x86/Microsoft.VC*.CRT', 'win_sdk/bin/x86'), ('VC/redist/MSVC/14.*.*/x86/Microsoft.VC*.CRT',
'Windows Kits/10//bin/x86'),
('VC/redist/MSVC/14.*.*/debug_nonredist/x86/Microsoft.VC*.DebugCRT', ('VC/redist/MSVC/14.*.*/debug_nonredist/x86/Microsoft.VC*.DebugCRT',
'sys32'), 'sys32'),
('VC/redist/MSVC/14.*.*/x64/Microsoft.VC*.CRT', 'sys64'), ('VC/redist/MSVC/14.*.*/x64/Microsoft.VC*.CRT', 'sys64'),
('VC/redist/MSVC/14.*.*/x64/Microsoft.VC*.CRT', 'VC/bin/amd64_x86'), ('VC/redist/MSVC/14.*.*/x64/Microsoft.VC*.CRT', 'VC/bin/amd64_x86'),
('VC/redist/MSVC/14.*.*/x64/Microsoft.VC*.CRT', 'VC/bin/amd64'), ('VC/redist/MSVC/14.*.*/x64/Microsoft.VC*.CRT', 'VC/bin/amd64'),
('VC/redist/MSVC/14.*.*/x64/Microsoft.VC*.CRT', 'win_sdk/bin/x64'), ('VC/redist/MSVC/14.*.*/x64/Microsoft.VC*.CRT',
'Windows Kits/10/bin/x64'),
('VC/redist/MSVC/14.*.*/debug_nonredist/x64/Microsoft.VC*.DebugCRT', ('VC/redist/MSVC/14.*.*/debug_nonredist/x64/Microsoft.VC*.DebugCRT',
'sys64'), 'sys64'),
] ]
...@@ -139,7 +142,8 @@ def BuildFileList(override_dir, include_arm): ...@@ -139,7 +142,8 @@ def BuildFileList(override_dir, include_arm):
('VC/redist/MSVC/14.*.*/arm64/Microsoft.VC*.CRT', 'sysarm64'), ('VC/redist/MSVC/14.*.*/arm64/Microsoft.VC*.CRT', 'sysarm64'),
('VC/redist/MSVC/14.*.*/arm64/Microsoft.VC*.CRT', 'VC/bin/amd64_arm64'), ('VC/redist/MSVC/14.*.*/arm64/Microsoft.VC*.CRT', 'VC/bin/amd64_arm64'),
('VC/redist/MSVC/14.*.*/arm64/Microsoft.VC*.CRT', 'VC/bin/arm64'), ('VC/redist/MSVC/14.*.*/arm64/Microsoft.VC*.CRT', 'VC/bin/arm64'),
('VC/redist/MSVC/14.*.*/arm64/Microsoft.VC*.CRT', 'win_sdk/bin/arm64'), ('VC/redist/MSVC/14.*.*/arm64/Microsoft.VC*.CRT',
'Windows Kits/10/bin/arm64'),
('VC/redist/MSVC/14.*.*/debug_nonredist/arm64/Microsoft.VC*.DebugCRT', ('VC/redist/MSVC/14.*.*/debug_nonredist/arm64/Microsoft.VC*.DebugCRT',
'sysarm64'), 'sysarm64'),
] ]
...@@ -201,7 +205,7 @@ def BuildFileList(override_dir, include_arm): ...@@ -201,7 +205,7 @@ def BuildFileList(override_dir, include_arm):
tail.startswith('Source\\') or tail.startswith('bin\\')): tail.startswith('Source\\') or tail.startswith('bin\\')):
if tail.count(WIN_VERSION) == 0: if tail.count(WIN_VERSION) == 0:
continue continue
to = os.path.join('win_sdk', tail) to = os.path.join('Windows Kits', '10', tail)
result.append((combined, to)) result.append((combined, to))
# Copy the x86 ucrt DLLs to all directories with x86 binaries that are # Copy the x86 ucrt DLLs to all directories with x86 binaries that are
...@@ -214,7 +218,7 @@ def BuildFileList(override_dir, include_arm): ...@@ -214,7 +218,7 @@ def BuildFileList(override_dir, include_arm):
assert(len(ucrt_paths) > 0) assert(len(ucrt_paths) > 0)
for ucrt_path in ucrt_paths: for ucrt_path in ucrt_paths:
ucrt_file = os.path.split(ucrt_path)[1] ucrt_file = os.path.split(ucrt_path)[1]
for dest_dir in [ r'win_sdk\bin\x86', 'sys32' ]: for dest_dir in [ r'Windows Kits\10\bin\x86', 'sys32' ]:
result.append((ucrt_path, os.path.join(dest_dir, ucrt_file))) result.append((ucrt_path, os.path.join(dest_dir, ucrt_file)))
# Copy the x64 ucrt DLLs to all directories with x64 binaries that are # Copy the x64 ucrt DLLs to all directories with x64 binaries that are
...@@ -227,7 +231,7 @@ def BuildFileList(override_dir, include_arm): ...@@ -227,7 +231,7 @@ def BuildFileList(override_dir, include_arm):
for ucrt_path in ucrt_paths: for ucrt_path in ucrt_paths:
ucrt_file = os.path.split(ucrt_path)[1] ucrt_file = os.path.split(ucrt_path)[1]
for dest_dir in [ r'VC\bin\amd64_x86', r'VC\bin\amd64', for dest_dir in [ r'VC\bin\amd64_x86', r'VC\bin\amd64',
r'win_sdk\bin\x64', 'sys64']: r'Windows Kits\10\bin\x64', 'sys64']:
result.append((ucrt_path, os.path.join(dest_dir, ucrt_file))) result.append((ucrt_path, os.path.join(dest_dir, ucrt_file)))
system_crt_files = [ system_crt_files = [
...@@ -268,21 +272,20 @@ def GenerateSetEnvCmd(target_dir): ...@@ -268,21 +272,20 @@ def GenerateSetEnvCmd(target_dir):
do it here manually since we do not do a full install.""" do it here manually since we do not do a full install."""
vc_tools_parts = VC_TOOLS.split('/') vc_tools_parts = VC_TOOLS.split('/')
# All these paths are relative to the grandparent of the directory containing # All these paths are relative to the root of the toolchain package.
# SetEnv.cmd.
include_dirs = [ include_dirs = [
['win_sdk', 'Include', WIN_VERSION, 'um'], ['Windows Kits', '10', 'Include', WIN_VERSION, 'um'],
['win_sdk', 'Include', WIN_VERSION, 'shared'], ['Windows Kits', '10', 'Include', WIN_VERSION, 'shared'],
['win_sdk', 'Include', WIN_VERSION, 'winrt'], ['Windows Kits', '10', 'Include', WIN_VERSION, 'winrt'],
] ]
include_dirs.append(['win_sdk', 'Include', WIN_VERSION, 'ucrt']) include_dirs.append(['Windows Kits', '10', 'Include', WIN_VERSION, 'ucrt'])
include_dirs.extend([ include_dirs.extend([
vc_tools_parts + ['include'], vc_tools_parts + ['include'],
vc_tools_parts + ['atlmfc', 'include'], vc_tools_parts + ['atlmfc', 'include'],
]) ])
libpath_dirs = [ libpath_dirs = [
vc_tools_parts + ['lib', 'x86', 'store', 'references'], vc_tools_parts + ['lib', 'x86', 'store', 'references'],
['win_sdk', 'UnionMetadata', WIN_VERSION], ['Windows Kits', '10', 'UnionMetadata', WIN_VERSION],
] ]
# Common to x86, x64, and arm64 # Common to x86, x64, and arm64
env = collections.OrderedDict([ env = collections.OrderedDict([
...@@ -301,15 +304,15 @@ def GenerateSetEnvCmd(target_dir): ...@@ -301,15 +304,15 @@ def GenerateSetEnvCmd(target_dir):
( (
'PATH', 'PATH',
[ [
['win_sdk', 'bin', WIN_VERSION, 'x64'], ['Windows Kits', '10', 'bin', WIN_VERSION, 'x64'],
vc_tools_parts + ['bin', 'HostX64', 'x86'], vc_tools_parts + ['bin', 'HostX64', 'x86'],
vc_tools_parts + ['bin', 'HostX64', 'x64' vc_tools_parts + ['bin', 'HostX64', 'x64'
], # Needed for mspdb1x0.dll. ], # Needed for mspdb1x0.dll.
]), ]),
('LIB', [ ('LIB', [
vc_tools_parts + ['lib', 'x86'], vc_tools_parts + ['lib', 'x86'],
['win_sdk', 'Lib', WIN_VERSION, 'um', 'x86'], ['Windows Kits', '10', 'Lib', WIN_VERSION, 'um', 'x86'],
['win_sdk', 'Lib', WIN_VERSION, 'ucrt', 'x86'], ['Windows Kits', '10', 'Lib', WIN_VERSION, 'ucrt', 'x86'],
vc_tools_parts + ['atlmfc', 'lib', 'x86'], vc_tools_parts + ['atlmfc', 'lib', 'x86'],
]), ]),
]) ])
...@@ -317,13 +320,13 @@ def GenerateSetEnvCmd(target_dir): ...@@ -317,13 +320,13 @@ def GenerateSetEnvCmd(target_dir):
# x64. # x64.
env_x64 = collections.OrderedDict([ env_x64 = collections.OrderedDict([
('PATH', [ ('PATH', [
['win_sdk', 'bin', WIN_VERSION, 'x64'], ['Windows Kits', '10', 'bin', WIN_VERSION, 'x64'],
vc_tools_parts + ['bin', 'HostX64', 'x64'], vc_tools_parts + ['bin', 'HostX64', 'x64'],
]), ]),
('LIB', [ ('LIB', [
vc_tools_parts + ['lib', 'x64'], vc_tools_parts + ['lib', 'x64'],
['win_sdk', 'Lib', WIN_VERSION, 'um', 'x64'], ['Windows Kits', '10', 'Lib', WIN_VERSION, 'um', 'x64'],
['win_sdk', 'Lib', WIN_VERSION, 'ucrt', 'x64'], ['Windows Kits', '10', 'Lib', WIN_VERSION, 'ucrt', 'x64'],
vc_tools_parts + ['atlmfc', 'lib', 'x64'], vc_tools_parts + ['atlmfc', 'lib', 'x64'],
]), ]),
]) ])
...@@ -331,27 +334,28 @@ def GenerateSetEnvCmd(target_dir): ...@@ -331,27 +334,28 @@ def GenerateSetEnvCmd(target_dir):
# arm64. # arm64.
env_arm64 = collections.OrderedDict([ env_arm64 = collections.OrderedDict([
('PATH', [ ('PATH', [
['win_sdk', 'bin', WIN_VERSION, 'x64'], ['Windows Kits', '10', 'bin', WIN_VERSION, 'x64'],
vc_tools_parts + ['bin', 'HostX64', 'arm64'], vc_tools_parts + ['bin', 'HostX64', 'arm64'],
vc_tools_parts + ['bin', 'HostX64', 'x64'], vc_tools_parts + ['bin', 'HostX64', 'x64'],
]), ]),
('LIB', [ ('LIB', [
vc_tools_parts + ['lib', 'arm64'], vc_tools_parts + ['lib', 'arm64'],
['win_sdk', 'Lib', WIN_VERSION, 'um', 'arm64'], ['Windows Kits', '10', 'Lib', WIN_VERSION, 'um', 'arm64'],
['win_sdk', 'Lib', WIN_VERSION, 'ucrt', 'arm64'], ['Windows Kits', '10', 'Lib', WIN_VERSION, 'ucrt', 'arm64'],
vc_tools_parts + ['atlmfc', 'lib', 'arm64'], vc_tools_parts + ['atlmfc', 'lib', 'arm64'],
]), ]),
]) ])
def BatDirs(dirs): def BatDirs(dirs):
return ';'.join(['%cd%\\' + os.path.join(*d) for d in dirs]) return ';'.join(['%cd%\\' + os.path.join(*d) for d in dirs])
set_env_prefix = os.path.join(target_dir, r'win_sdk\bin\SetEnv') set_env_prefix = os.path.join(target_dir, r'Windows Kits\10\bin\SetEnv')
with open(set_env_prefix + '.cmd', 'w') as f: with open(set_env_prefix + '.cmd', 'w') as f:
# The prologue changes the current directory to the grandparent so that the # The prologue changes the current directory to the root of the toolchain
# path entries can be set up without needing ..\..\ components. # package, so that path entries can be set up without needing ..\..\..\
# components.
f.write('@echo off\n' f.write('@echo off\n'
':: Generated by win_toolchain\\package_from_installed.py.\n' ':: Generated by win_toolchain\\package_from_installed.py.\n'
'pushd %~dp0..\..\n') 'pushd %~dp0..\..\..\n')
for var, dirs in env.items(): for var, dirs in env.items():
f.write('set %s=%s\n' % (var, BatDirs(dirs))) f.write('set %s=%s\n' % (var, BatDirs(dirs)))
f.write('if "%1"=="/x64" goto x64\n') f.write('if "%1"=="/x64" goto x64\n')
...@@ -394,17 +398,21 @@ def AddEnvSetup(files, include_arm): ...@@ -394,17 +398,21 @@ def AddEnvSetup(files, include_arm):
"""We need to generate this file in the same way that the "from pieces" """We need to generate this file in the same way that the "from pieces"
script does, so pull that in here.""" script does, so pull that in here."""
tempdir = tempfile.mkdtemp() tempdir = tempfile.mkdtemp()
os.makedirs(os.path.join(tempdir, 'win_sdk', 'bin')) os.makedirs(os.path.join(tempdir, 'Windows Kits', '10', 'bin'))
GenerateSetEnvCmd(tempdir) GenerateSetEnvCmd(tempdir)
files.append((os.path.join(tempdir, 'win_sdk', 'bin', 'SetEnv.cmd'), files.append((
'win_sdk\\bin\\SetEnv.cmd')) os.path.join(tempdir, 'Windows Kits', '10', 'bin', 'SetEnv.cmd'),
files.append((os.path.join(tempdir, 'win_sdk', 'bin', 'SetEnv.x86.json'), 'Windows Kits\\10\\bin\\SetEnv.cmd'))
'win_sdk\\bin\\SetEnv.x86.json')) files.append((
files.append((os.path.join(tempdir, 'win_sdk', 'bin', 'SetEnv.x64.json'), os.path.join(tempdir, 'Windows Kits', '10', 'bin', 'SetEnv.x86.json'),
'win_sdk\\bin\\SetEnv.x64.json')) 'Windows Kits\\10\\bin\\SetEnv.x86.json'))
files.append((
os.path.join(tempdir, 'Windows Kits', '10', 'bin', 'SetEnv.x64.json'),
'Windows Kits\\10\\bin\\SetEnv.x64.json'))
if include_arm: if include_arm:
files.append((os.path.join(tempdir, 'win_sdk', 'bin', 'SetEnv.arm64.json'), files.append((
'win_sdk\\bin\\SetEnv.arm64.json')) os.path.join(tempdir, 'Windows Kits', '10', 'bin', 'SetEnv.arm64.json'),
'Windows Kits\\10\\bin\\SetEnv.arm64.json'))
vs_version_file = os.path.join(tempdir, 'VS_VERSION') vs_version_file = os.path.join(tempdir, 'VS_VERSION')
with open(vs_version_file, 'wt', newline='') as version: with open(vs_version_file, 'wt', newline='') as version:
print(VS_VERSION, file=version) print(VS_VERSION, file=version)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment