Skip to content

Commit 81f6cc1

Browse files
Clement SkauCommit Bot
Clement Skau
authored and
Commit Bot
committed
[infra] Error, don't crash setup_toolchain.py
In case the environment is incorrectly set on Windows (e.g. GYP_MSVS_OVERRIDE_PATH pointing to a non-existing path), the setup_toolchain.py script may raise an exception. The script attempts to run a subprocess to gather the environment variables. But it does not check that the process actually succeeded. In case the process fails the environment data will be invalid and the script will ultimately raise an exception. This change adds a check for the process failing, and gracefully warns and exits the script instead. TEST=Manual build on Windows. Change-Id: I3624bdf98e0ebe48b403825a90ce2e86c2ed8008 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242860 Commit-Queue: Clement Skau <[email protected]> Reviewed-by: Tess Strickland <[email protected]>
1 parent b1e453e commit 81f6cc1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

build/toolchain/win/setup_toolchain.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,15 @@ def main():
118118
args.extend(('&&', 'set'))
119119
popen = subprocess.Popen(
120120
args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
121-
variables, _ = popen.communicate()
122-
env = _ExtractImportantEnvironment(variables)
121+
stdout_data, stderr_data = popen.communicate()
122+
if popen.returncode != 0:
123+
print('Error, got returncode:', popen.returncode)
124+
print('## stdout:')
125+
print(stdout_data)
126+
print('## stderr:')
127+
print(stderr_data)
128+
sys.exit(2)
129+
env = _ExtractImportantEnvironment(stdout_data)
123130
env['PATH'] = runtime_dirs + ';' + env['PATH']
124131

125132
if cpu == target_cpu:

0 commit comments

Comments
 (0)