From 1ba41357663bb27bead6f72f88eb9bf24ffce483 Mon Sep 17 00:00:00 2001 From: Chris Blume Date: Thu, 17 Feb 2022 11:32:27 +0000 Subject: [PATCH] Replace hard-coded Windows SDK path Currently, the Windows SDK path is hard-coded. This does not work if the SDK is installed in a different path or drive. This CL fetches the actual Windows SDK path and uses it instead. Change-Id: I31808ba0dbe76f47253fc165ccbd8f027bf396ec Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3451982 Reviewed-by: Bruce Dawson Commit-Queue: Chris Blume Auto-Submit: Chris Blume --- win_toolchain/package_from_installed.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/win_toolchain/package_from_installed.py b/win_toolchain/package_from_installed.py index e1a8e7ea8..0666b5790 100644 --- a/win_toolchain/package_from_installed.py +++ b/win_toolchain/package_from_installed.py @@ -177,7 +177,19 @@ def BuildFileList(override_dir, include_arm): dest = final_from[len(vs_path) + 1:] result.append((final_from, dest)) - sdk_path = r'C:\Program Files (x86)\Windows Kits\10' + command = (r'reg query "HKLM\SOFTWARE\Microsoft\Windows Kits\Installed Roots"' + r' /v KitsRoot10') + marker = " KitsRoot10 REG_SZ " + sdk_path = None + output = subprocess.check_output(command, universal_newlines=True) + for line in output.splitlines(): + if line.startswith(marker): + sdk_path = line[len(marker):] + + # Strip off a trailing slash if present + if sdk_path.endswith(os.path.sep): + sdk_path = sdk_path[:len(os.path.sep)] + debuggers_path = os.path.join(sdk_path, 'Debuggers') if not os.path.exists(debuggers_path): raise Exception('Packaging failed. Missing %s.' % (debuggers_path))