Revert "win toolchain: Prepare downloader for windows sdk dir switch"

This reverts commit e72789f5b4.

Reason for revert: 
This broke goma builder.

Original change's description:
> win toolchain: Prepare downloader for windows sdk dir switch
>
> crrev.com/c/2655836 tries to move the Windows SDK from
> "win_sdk" to "Windows Kits/10".
>
> get_toolchain_if_necessary.py (in depot_tools) saves the path to the SDK to
> third_party/depot_tools/win_toolchain/data.json which then gets copied
> by a script in the chromium repo to build/win_toolchain.json.
> For the SDK move to work, chromium's pinned depot_tools
> must write the new SDK path when rolling in the new toolchain package.
> This change makes depot_tools handle win packages that have the
> windows sdk either win "win_sdk" or in "Windows Kits\10".
>
> The plan is:
>
> 1. Land this change, which can handle both path styles
> 2. Wait for depot_tools in chromium to update
> 3. Then roll to a win toolchain package with the new layout
>
> In a few years, when we no longer need the old layout,
> we can remove this detection code again and assume the new layout.
>
> Bug: 1173176
> Change-Id: Iaefc5c16685d3dbfff87a3e50a7b20b457366e44
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2666429
> Commit-Queue: Nico Weber <thakis@chromium.org>
> Auto-Submit: Nico Weber <thakis@chromium.org>
> Reviewed-by: Bruce Dawson <brucedawson@chromium.org>

TBR=thakis@chromium.org,brucedawson@chromium.org,infra-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I8d133f4fa199f81978f5245bdb2155c62bc9cc88
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1173176
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2666651
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
changes/51/2666651/2
Takuto Ikuta 4 years ago committed by LUCI CQ
parent e72789f5b4
commit 98cc028bbe

@ -65,7 +65,7 @@ except ImportError:
pass pass
def GetFileList(root, win_sdk_in_windows_kits): def GetFileList(root):
"""Gets a normalized list of files under |root|.""" """Gets a normalized list of files under |root|."""
assert not os.path.isabs(root) assert not os.path.isabs(root)
assert os.path.normpath(root) == root assert os.path.normpath(root) == root
@ -79,12 +79,11 @@ def GetFileList(root, win_sdk_in_windows_kits):
# Note: These files are only created on a Windows host, so the # Note: These files are only created on a Windows host, so the
# ignored_directories list isn't relevant on non-Windows hosts. # ignored_directories list isn't relevant on non-Windows hosts.
win_sdk = 'Windows Kits\\10' if win_sdk_in_windows_kits else 'win_sdk'
ignored_directories = ['wer\\reportqueue', ignored_directories = ['wer\\reportqueue',
win_sdk + '\\debuggers\\x86\\sym\\', 'win_sdk\\debuggers\\x86\\sym\\',
win_sdk + '\\debuggers\\x64\\sym\\', 'win_sdk\\debuggers\\x64\\sym\\',
win_sdk + '\\debuggers\\x86\\src\\', 'win_sdk\\debuggers\\x86\\src\\',
win_sdk + '\\debuggers\\x64\\src\\'] 'win_sdk\\debuggers\\x64\\src\\']
for base, _, files in os.walk(root): for base, _, files in os.walk(root):
paths = [os.path.join(base, f) for f in files] paths = [os.path.join(base, f) for f in files]
for p in paths: for p in paths:
@ -98,7 +97,7 @@ def MakeTimestampsFileName(root, sha1):
return os.path.join(root, os.pardir, '%s.timestamps' % sha1) return os.path.join(root, os.pardir, '%s.timestamps' % sha1)
def CalculateHash(root, expected_hash, win_sdk_in_windows_kits): def CalculateHash(root, expected_hash):
"""Calculates the sha1 of the paths to all files in the given |root| and the """Calculates the sha1 of the paths to all files in the given |root| and the
contents of those files, and returns as a hex string. contents of those files, and returns as a hex string.
@ -109,7 +108,7 @@ def CalculateHash(root, expected_hash, win_sdk_in_windows_kits):
full_root_path = os.path.join(root, expected_hash) full_root_path = os.path.join(root, expected_hash)
else: else:
full_root_path = root full_root_path = root
file_list = GetFileList(full_root_path, win_sdk_in_windows_kits) file_list = GetFileList(full_root_path)
# Check whether we previously saved timestamps in $root/../{sha1}.timestamps. # Check whether we previously saved timestamps in $root/../{sha1}.timestamps.
# If we didn't, or they don't match, then do the full calculation, otherwise # If we didn't, or they don't match, then do the full calculation, otherwise
# return the saved value. # return the saved value.
@ -185,15 +184,14 @@ def CalculateHash(root, expected_hash, win_sdk_in_windows_kits):
return digest.hexdigest() return digest.hexdigest()
def CalculateToolchainHashes( def CalculateToolchainHashes(root, remove_corrupt_toolchains):
root, remove_corrupt_toolchains, win_sdk_in_windows_kits):
"""Calculate the hash of the different toolchains installed in the |root| """Calculate the hash of the different toolchains installed in the |root|
directory.""" directory."""
hashes = [] hashes = []
dir_list = [ dir_list = [
d for d in os.listdir(root) if os.path.isdir(os.path.join(root, d))] d for d in os.listdir(root) if os.path.isdir(os.path.join(root, d))]
for d in dir_list: for d in dir_list:
toolchain_hash = CalculateHash(root, d, win_sdk_in_windows_kits) toolchain_hash = CalculateHash(root, d)
if toolchain_hash != d: if toolchain_hash != d:
print('The hash of a version of the toolchain has an unexpected value (' print('The hash of a version of the toolchain has an unexpected value ('
'%s instead of %s)%s.' % (toolchain_hash, d, '%s instead of %s)%s.' % (toolchain_hash, d,
@ -205,10 +203,10 @@ def CalculateToolchainHashes(
return hashes return hashes
def SaveTimestampsAndHash(root, sha1, win_sdk_in_windows_kits): def SaveTimestampsAndHash(root, sha1):
"""Saves timestamps and the final hash to be able to early-out more quickly """Saves timestamps and the final hash to be able to early-out more quickly
next time.""" next time."""
file_list = GetFileList(os.path.join(root, sha1), win_sdk_in_windows_kits) file_list = GetFileList(os.path.join(root, sha1))
timestamps_data = { timestamps_data = {
'files': [[f, os.path.getmtime(f)] for f in file_list], 'files': [[f, os.path.getmtime(f)] for f in file_list],
'sha1': sha1, 'sha1': sha1,
@ -489,19 +487,13 @@ def main():
abs_toolchain_target_dir = os.path.abspath(toolchain_target_dir) abs_toolchain_target_dir = os.path.abspath(toolchain_target_dir)
# The Windows SDK is either in `win_sdk` or in `Windows Kits\10`. This
# script must work with both layouts, so check which one it is.
win_sdk_in_windows_kits = os.path.isdir(
os.path.join(abs_toolchain_target_dir, 'Windows Kits', '10'))
got_new_toolchain = False got_new_toolchain = False
# If the current hash doesn't match what we want in the file, nuke and pave. # If the current hash doesn't match what we want in the file, nuke and pave.
# Typically this script is only run when the .sha1 one file is updated, but # Typically this script is only run when the .sha1 one file is updated, but
# directly calling "gclient runhooks" will also run it, so we cache # directly calling "gclient runhooks" will also run it, so we cache
# based on timestamps to make that case fast. # based on timestamps to make that case fast.
current_hashes = CalculateToolchainHashes( current_hashes = CalculateToolchainHashes(target_dir, True)
target_dir, True, win_sdk_in_windows_kits)
if desired_hash not in current_hashes: if desired_hash not in current_hashes:
if options.no_download: if options.no_download:
raise SystemExit('Toolchain is out of date. Run "gclient runhooks" to ' raise SystemExit('Toolchain is out of date. Run "gclient runhooks" to '
@ -544,10 +536,7 @@ def main():
got_new_toolchain = True got_new_toolchain = True
if win_sdk_in_windows_kits: win_sdk = os.path.join(abs_toolchain_target_dir, 'win_sdk')
win_sdk = os.path.join(abs_toolchain_target_dir, 'Windows Kits', '10')
else:
win_sdk = os.path.join(abs_toolchain_target_dir, 'win_sdk')
try: try:
version_file = os.path.join(toolchain_target_dir, 'VS_VERSION') version_file = os.path.join(toolchain_target_dir, 'VS_VERSION')
vc_dir = os.path.join(toolchain_target_dir, 'VC') vc_dir = os.path.join(toolchain_target_dir, 'VC')
@ -579,15 +568,14 @@ def main():
json.dump(data, f) json.dump(data, f)
if got_new_toolchain: if got_new_toolchain:
current_hashes = CalculateToolchainHashes( current_hashes = CalculateToolchainHashes(target_dir, False)
target_dir, False, win_sdk_in_windows_kits)
if desired_hash not in current_hashes: if desired_hash not in current_hashes:
print( print(
'Got wrong hash after pulling a new toolchain. ' 'Got wrong hash after pulling a new toolchain. '
'Wanted \'%s\', got one of \'%s\'.' % ( 'Wanted \'%s\', got one of \'%s\'.' % (
desired_hash, ', '.join(current_hashes)), file=sys.stderr) desired_hash, ', '.join(current_hashes)), file=sys.stderr)
return 1 return 1
SaveTimestampsAndHash(target_dir, desired_hash, win_sdk_in_windows_kits) SaveTimestampsAndHash(target_dir, desired_hash)
if options.output_json: if options.output_json:
shutil.copyfile(os.path.join(target_dir, '..', 'data.json'), shutil.copyfile(os.path.join(target_dir, '..', 'data.json'),

Loading…
Cancel
Save