Better asserts on missing files during gn gen
This improves the assert message when user32.lib cannot be found during gn gen on Windows. This is an ongoing source of problems for external contributors and this change may help with diagnostics. Change-Id: I1649fb4d9cac4a735377df14149f554b434d63cd Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2136889 Reviewed-by: Scott Graham <scottmg@chromium.org> Commit-Queue: Bruce Dawson <brucedawson@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#756952} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: d76ad2d6deac409096b539b378c2eb0545ac9da4
This commit is contained in:
Родитель
0ce2b478a5
Коммит
d25bc90745
|
@ -185,6 +185,16 @@ def _LowercaseDict(d):
|
|||
return {k.lower(): d[k].lower() for k in d}
|
||||
|
||||
|
||||
def FindFileInEnvList(env, env_name, separator, file_name, optional=False):
|
||||
parts = env[env_name].split(separator)
|
||||
for path in parts:
|
||||
if os.path.exists(os.path.join(path, file_name)):
|
||||
return os.path.realpath(path)
|
||||
assert optional, "%s is not found in %s:\n%s\nCheck if it is installed." % (
|
||||
file_name, env_name, '\n'.join(parts))
|
||||
return ''
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 7:
|
||||
print('Usage setup_toolchain.py '
|
||||
|
@ -223,34 +233,11 @@ def main():
|
|||
env = _LoadToolchainEnv(cpu, win_sdk_path, target_store)
|
||||
env['PATH'] = runtime_dirs + os.pathsep + env['PATH']
|
||||
|
||||
for path in env['PATH'].split(os.pathsep):
|
||||
if os.path.exists(os.path.join(path, 'cl.exe')):
|
||||
vc_bin_dir = os.path.realpath(path)
|
||||
break
|
||||
assert vc_bin_dir, "cl.exe is not found, check if it is installed."
|
||||
|
||||
for path in env['LIB'].split(';'):
|
||||
if os.path.exists(os.path.join(path, 'msvcrt.lib')):
|
||||
vc_lib_path = os.path.realpath(path)
|
||||
break
|
||||
assert vc_lib_path, "msvcrt.lib is not found, check if it is installed."
|
||||
|
||||
for path in env['LIB'].split(';'):
|
||||
if os.path.exists(os.path.join(path, 'atls.lib')):
|
||||
vc_lib_atlmfc_path = os.path.realpath(path)
|
||||
break
|
||||
if (target_store != True):
|
||||
# Path is assumed to exist for desktop applications.
|
||||
assert vc_lib_atlmfc_path, (
|
||||
"Microsoft.VisualStudio.Component.VC.ATLMFC " +
|
||||
"is not found, check if it is installed.")
|
||||
|
||||
for path in env['LIB'].split(';'):
|
||||
if os.path.exists(os.path.join(path, 'User32.Lib')):
|
||||
vc_lib_um_path = os.path.realpath(path)
|
||||
break
|
||||
assert vc_lib_um_path, (
|
||||
"User32.lib is not found, check if it is installed.")
|
||||
vc_bin_dir = FindFileInEnvList(env, 'PATH', os.pathsep, 'cl.exe')
|
||||
vc_lib_path = FindFileInEnvList(env, 'LIB', ';', 'msvcrt.lib')
|
||||
vc_lib_atlmfc_path = FindFileInEnvList(
|
||||
env, 'LIB', ';', 'atls.lib', optional=True)
|
||||
vc_lib_um_path = FindFileInEnvList(env, 'LIB', ';', 'user32.lib')
|
||||
|
||||
# The separator for INCLUDE here must match the one used in
|
||||
# _LoadToolchainEnv() above.
|
||||
|
|
Загрузка…
Ссылка в новой задаче