Do not lowercase paths in _ExtractImportantEnvironment (win toolchain).

This creates problems when running on a case sensitive file system.

When the path of a checkout contains uppercase characters, the
following command fails:

$ gn gen out/win64 --args='target_os="win" target_cpu="x64"'
ERROR at //build/config/win/BUILD.gn:338:27: Script returned non-zero exit code.
vcvars_toolchain_data = exec_script("../../toolchain/win/setup_toolchain.py",
.... src/build/toolchain/win/setup_toolchain.py", line 240, in main
  assert vc_bin_dir
AssertionError

Bug: None
Change-Id: If4c792e9d04d56987a87a55e824d764a1c4e62ed
Reviewed-on: https://chromium-review.googlesource.com/985835
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Commit-Queue: Mirko Bonadei <mbonadei@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#547994}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 4e699af35744098fc7949942301c9baa1943c162
This commit is contained in:
Mirko Bonadei 2018-04-04 06:06:27 +00:00 коммит произвёл Commit Bot
Родитель e65999a451
Коммит a27ceccabb
1 изменённых файлов: 17 добавлений и 3 удалений

Просмотреть файл

@ -50,7 +50,7 @@ def _ExtractImportantEnvironment(output_of_set):
# path. Add the path to this python here so that if it's not in the
# path when ninja is run later, python will still be found.
setting = os.path.dirname(sys.executable) + os.pathsep + setting
env[var.upper()] = setting.lower()
env[var.upper()] = setting
break
if sys.platform in ('win32', 'cygwin'):
for required in ('SYSTEMROOT', 'TEMP', 'TMP'):
@ -117,8 +117,10 @@ def _LoadToolchainEnv(cpu, sdk_dir, target_store):
# Check that the json file contained the same environment as the .cmd file.
if sys.platform in ('win32', 'cygwin'):
script = os.path.normpath(os.path.join(sdk_dir, 'Bin/SetEnv.cmd'))
assert _ExtractImportantEnvironment(variables) == \
_ExtractImportantEnvironment(_LoadEnvFromBat([script, '/' + cpu]))
arg = '/' + cpu
json_env = _ExtractImportantEnvironment(variables)
cmd_env = _ExtractImportantEnvironment(_LoadEnvFromBat([script, arg]))
assert _LowercaseDict(json_env) == _LowercaseDict(cmd_env)
else:
if 'GYP_MSVS_OVERRIDE_PATH' not in os.environ:
os.environ['GYP_MSVS_OVERRIDE_PATH'] = _DetectVisualStudioPath()
@ -167,6 +169,18 @@ def _FormatAsEnvironmentBlock(envvar_dict):
return block
def _LowercaseDict(d):
"""Returns a copy of `d` with both key and values lowercased.
Args:
d: dict to lowercase (e.g. {'A': 'BcD'}).
Returns:
A dict with both keys and values lowercased (e.g.: {'a': 'bcd'}).
"""
return {k.lower(): d[k].lower() for k in d}
def main():
if len(sys.argv) != 8:
print('Usage setup_toolchain.py '