Windows: Explicitly specify the SDK version in setup_toolchain.py

Avoid building with a new and untested SDK version. See
https://crbug.com/1089996 for background.
This commit is contained in:
Marshall Greenblatt
2020-07-13 16:28:31 -04:00
parent babcf94317
commit a4a78d1254

View File

@@ -1,8 +1,8 @@
diff --git build/toolchain/win/setup_toolchain.py build/toolchain/win/setup_toolchain.py
index 2ab240da4548..b8eec0aa2383 100644
index 2ab240da4548..81e69abe1ecd 100644
--- build/toolchain/win/setup_toolchain.py
+++ build/toolchain/win/setup_toolchain.py
@@ -142,22 +142,25 @@ def _LoadToolchainEnv(cpu, sdk_dir, target_store):
@@ -142,21 +142,29 @@ def _LoadToolchainEnv(cpu, sdk_dir, target_store):
# variable.
if 'VSINSTALLDIR' in os.environ:
del os.environ['VSINSTALLDIR']
@@ -14,34 +14,31 @@ index 2ab240da4548..b8eec0aa2383 100644
- raise Exception('%s is missing - make sure VC++ tools are installed.' %
- script_path)
- script_path = other_path
- cpu_arg = "amd64"
- if (cpu != 'x64'):
- # x64 is default target CPU thus any other CPU requires a target set
- cpu_arg += '_' + cpu
- args = [script_path, cpu_arg]
- # Store target must come before any SDK version declaration
- if (target_store):
- args.append(['store'])
- variables = _LoadEnvFromBat(args)
+ if os.path.exists(script_path):
+ cpu_arg = "amd64"
+ if (cpu != 'x64'):
+ # x64 is default target CPU thus any other CPU requires a target set
+ cpu_arg += '_' + cpu
+ args = [script_path, cpu_arg]
+ # Store target must come before any SDK version declaration
+ if (target_store):
+ args.append(['store'])
+ variables = _LoadEnvFromBat(args)
+ else:
+ if not os.path.exists(script_path):
+ # Compiler environment variables must already be specified.
+ variables = []
+ for k in sorted(os.environ.keys()):
+ variables.append('%s=%s' % (str(k), str(os.environ[k])))
+ variables = '\n'.join(variables)
+ return _ExtractImportantEnvironment(variables)
+
cpu_arg = "amd64"
if (cpu != 'x64'):
# x64 is default target CPU thus any other CPU requires a target set
cpu_arg += '_' + cpu
- args = [script_path, cpu_arg]
+ args = [script_path, cpu_arg, ]
# Store target must come before any SDK version declaration
if (target_store):
- args.append(['store'])
+ args.append('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.18362.0')
variables = _LoadEnvFromBat(args)
return _ExtractImportantEnvironment(variables)
diff --git build/vs_toolchain.py build/vs_toolchain.py
index 97600e73ba10..36773b159453 100755
--- build/vs_toolchain.py