From 98cc028bbe1a9eb57c76a9aeff0ff4bfb6f131ac Mon Sep 17 00:00:00 2001 From: Takuto Ikuta Date: Tue, 2 Feb 2021 04:37:17 +0000 Subject: [PATCH] Revert "win toolchain: Prepare downloader for windows sdk dir switch" This reverts commit e72789f5b4e6e96a6c114133eb7d147da6be656b. 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 > Auto-Submit: Nico Weber > Reviewed-by: Bruce Dawson 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 --- win_toolchain/get_toolchain_if_necessary.py | 42 ++++++++------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/win_toolchain/get_toolchain_if_necessary.py b/win_toolchain/get_toolchain_if_necessary.py index 9ec509266..261f6cd56 100755 --- a/win_toolchain/get_toolchain_if_necessary.py +++ b/win_toolchain/get_toolchain_if_necessary.py @@ -65,7 +65,7 @@ except ImportError: pass -def GetFileList(root, win_sdk_in_windows_kits): +def GetFileList(root): """Gets a normalized list of files under |root|.""" assert not os.path.isabs(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 # 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', - win_sdk + '\\debuggers\\x86\\sym\\', - win_sdk + '\\debuggers\\x64\\sym\\', - win_sdk + '\\debuggers\\x86\\src\\', - win_sdk + '\\debuggers\\x64\\src\\'] + 'win_sdk\\debuggers\\x86\\sym\\', + 'win_sdk\\debuggers\\x64\\sym\\', + 'win_sdk\\debuggers\\x86\\src\\', + 'win_sdk\\debuggers\\x64\\src\\'] for base, _, files in os.walk(root): paths = [os.path.join(base, f) for f in files] for p in paths: @@ -98,7 +97,7 @@ def MakeTimestampsFileName(root, 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 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) else: 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. # If we didn't, or they don't match, then do the full calculation, otherwise # return the saved value. @@ -185,15 +184,14 @@ def CalculateHash(root, expected_hash, win_sdk_in_windows_kits): return digest.hexdigest() -def CalculateToolchainHashes( - root, remove_corrupt_toolchains, win_sdk_in_windows_kits): +def CalculateToolchainHashes(root, remove_corrupt_toolchains): """Calculate the hash of the different toolchains installed in the |root| directory.""" hashes = [] dir_list = [ d for d in os.listdir(root) if os.path.isdir(os.path.join(root, d))] for d in dir_list: - toolchain_hash = CalculateHash(root, d, win_sdk_in_windows_kits) + toolchain_hash = CalculateHash(root, d) if toolchain_hash != d: print('The hash of a version of the toolchain has an unexpected value (' '%s instead of %s)%s.' % (toolchain_hash, d, @@ -205,10 +203,10 @@ def CalculateToolchainHashes( 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 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 = { 'files': [[f, os.path.getmtime(f)] for f in file_list], 'sha1': sha1, @@ -489,19 +487,13 @@ def main(): 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 # 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 # directly calling "gclient runhooks" will also run it, so we cache # based on timestamps to make that case fast. - current_hashes = CalculateToolchainHashes( - target_dir, True, win_sdk_in_windows_kits) + current_hashes = CalculateToolchainHashes(target_dir, True) if desired_hash not in current_hashes: if options.no_download: raise SystemExit('Toolchain is out of date. Run "gclient runhooks" to ' @@ -544,10 +536,7 @@ def main(): got_new_toolchain = True - if win_sdk_in_windows_kits: - win_sdk = os.path.join(abs_toolchain_target_dir, 'Windows Kits', '10') - else: - win_sdk = os.path.join(abs_toolchain_target_dir, 'win_sdk') + win_sdk = os.path.join(abs_toolchain_target_dir, 'win_sdk') try: version_file = os.path.join(toolchain_target_dir, 'VS_VERSION') vc_dir = os.path.join(toolchain_target_dir, 'VC') @@ -579,15 +568,14 @@ def main(): json.dump(data, f) if got_new_toolchain: - current_hashes = CalculateToolchainHashes( - target_dir, False, win_sdk_in_windows_kits) + current_hashes = CalculateToolchainHashes(target_dir, False) if desired_hash not in current_hashes: print( 'Got wrong hash after pulling a new toolchain. ' 'Wanted \'%s\', got one of \'%s\'.' % ( desired_hash, ', '.join(current_hashes)), file=sys.stderr) return 1 - SaveTimestampsAndHash(target_dir, desired_hash, win_sdk_in_windows_kits) + SaveTimestampsAndHash(target_dir, desired_hash) if options.output_json: shutil.copyfile(os.path.join(target_dir, '..', 'data.json'),