summaryrefslogtreecommitdiffstats
path: root/build/toolchain/win
diff options
context:
space:
mode:
authorbrucedawson <brucedawson@chromium.org>2015-12-08 18:29:33 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-09 02:30:30 +0000
commit5e289be0b06d4781610d16daec9064f6f811ce18 (patch)
treebb647871115295954550fc176e5d97d5e1735c65 /build/toolchain/win
parent646bc5c547a48ee19d5640500f05273cde148a17 (diff)
downloadchromium_src-5e289be0b06d4781610d16daec9064f6f811ce18.zip
chromium_src-5e289be0b06d4781610d16daec9064f6f811ce18.tar.gz
chromium_src-5e289be0b06d4781610d16daec9064f6f811ce18.tar.bz2
Error checking to clarify SYSTEMROOT errors
Occasionally developers hit this cryptic error: Exception: Environment variable "SYSTEMROOT" required to be set to valid path The error message is well intentioned but inevitably misleading. The problem is rarely if ever caused by SYSTEMROOT not being set. In the most recent case it was caused by the "SetEnv.cmd && set" command failing. This change adds two bits of error checking - checking the error code of the Popen command, and ensuring that the results coming in to _ExtractImportantEnvironment are plausible. Both of these checks can detect this particular error, and one or both of them should detect future problems. This was initially done for gyp in crrev.com/1501673004, this makes the same fix for gn builds. R=jam@chromium.org Review URL: https://codereview.chromium.org/1502183004 Cr-Commit-Position: refs/heads/master@{#363930}
Diffstat (limited to 'build/toolchain/win')
-rw-r--r--build/toolchain/win/setup_toolchain.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/build/toolchain/win/setup_toolchain.py b/build/toolchain/win/setup_toolchain.py
index f395044..4e79cd9 100644
--- a/build/toolchain/win/setup_toolchain.py
+++ b/build/toolchain/win/setup_toolchain.py
@@ -32,6 +32,10 @@ def _ExtractImportantEnvironment(output_of_set):
'tmp',
)
env = {}
+ # This occasionally happens and leads to misleading SYSTEMROOT error messages
+ # if not caught here.
+ if output_of_set.count('=') == 0:
+ raise Exception('Invalid output_of_set. Value is:\n%s' % output_of_set)
for line in output_of_set.splitlines():
for envvar in envvars_to_save:
if re.match(envvar + '=', line.lower()):
@@ -123,6 +127,8 @@ def main():
popen = subprocess.Popen(
args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
variables, _ = popen.communicate()
+ if popen.returncode != 0:
+ raise Exception('"%s" failed with error %d' % (args, popen.returncode))
env = _ExtractImportantEnvironment(variables)
env['PATH'] = runtime_dirs + ';' + env['PATH']