in tools/gn_args.py [0:0]
def ValidateArgs(args):
"""
Validate GN arg combinations that we know about. Also provide suggestions
where appropriate.
"""
dcheck_always_on = GetArgValue(args, 'dcheck_always_on')
is_asan = GetArgValue(args, 'is_asan')
is_debug = GetArgValue(args, 'is_debug')
is_official_build = GetArgValue(args, 'is_official_build')
target_cpu = GetArgValue(args, 'target_cpu')
if platform == 'linux':
use_sysroot = GetArgValue(args, 'use_sysroot')
if platform == 'windows':
is_win_fastlink = GetArgValue(args, 'is_win_fastlink')
visual_studio_path = GetArgValue(args, 'visual_studio_path')
visual_studio_version = GetArgValue(args, 'visual_studio_version')
visual_studio_runtime_dirs = GetArgValue(args, 'visual_studio_runtime_dirs')
windows_sdk_path = GetArgValue(args, 'windows_sdk_path')
# Target CPU architecture.
# - Windows supports "x86", "x64" and "arm64".
# - Mac supports "x64" and "arm64".
# - Linux supports only "x64" unless using a sysroot environment.
if platform == 'mac':
assert target_cpu in ('x64', 'arm64'), 'target_cpu must be "x64" or "arm64"'
elif platform == 'windows':
assert target_cpu in ('x86', 'x64',
'arm64'), 'target_cpu must be "x86", "x64" or "arm64"'
elif platform == 'linux':
assert target_cpu in (
'x86', 'x64', 'arm',
'arm64'), 'target_cpu must be "x86", "x64", "arm" or "arm64"'
if platform == 'linux':
if target_cpu == 'x86':
assert use_sysroot, 'target_cpu="x86" requires use_sysroot=true'
elif target_cpu == 'arm':
assert use_sysroot, 'target_cpu="arm" requires use_sysroot=true'
elif target_cpu == 'arm64':
assert use_sysroot, 'target_cpu="arm64" requires use_sysroot=true'
# ASAN requires Release builds.
if is_asan:
assert not is_debug, "is_asan=true requires is_debug=false"
if not dcheck_always_on:
msg('is_asan=true recommends dcheck_always_on=true')
# Official build requires Release builds.
if is_official_build:
assert not is_debug, "is_official_build=true requires is_debug=false"
if platform == 'windows':
# Official builds should not use /DEBUG:FASTLINK.
if is_official_build:
assert not is_win_fastlink, "is_official_build=true precludes is_win_fastlink=true"
# Windows custom toolchain requirements.
#
# Required GN arguments:
# visual_studio_path="<path to VS root>"
# The directory that contains Visual Studio. For example, a subset of
# "C:\Program Files (x86)\Microsoft Visual Studio 14.0".
# visual_studio_version="<VS version>"
# The VS version. For example, "2015".
# visual_studio_runtime_dirs="<path to VS CRT>"
# The directory that contains the VS CRT. For example, the contents of
# "C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\x64" plus
# "C:\Windows\System32\ucrtbased.dll"
# windows_sdk_path="<path to WinSDK>"
# The directory that contains the Win SDK. For example, a subset of
# "C:\Program Files (x86)\Windows Kits\10".
#
# Required environment variables:
# DEPOT_TOOLS_WIN_TOOLCHAIN=0
# GYP_MSVS_OVERRIDE_PATH=<path to VS root, must match visual_studio_path>
# GYP_MSVS_VERSION=<VS version, must match visual_studio_version>
# CEF_VCVARS=none
#
# Optional environment variables (required if vcvarsall.bat does not exist):
# INCLUDE=<VS include paths>
# LIB=<VS library paths>
# PATH=<VS executable paths>
#
# See comments in gclient_hook.py for environment variable usage.
#
if visual_studio_path != '':
assert visual_studio_version != '', 'visual_studio_path requires visual_studio_version'
assert visual_studio_runtime_dirs != '', 'visual_studio_path requires visual_studio_runtime_dirs'
assert windows_sdk_path != '', 'visual_studio_path requires windows_sdk_path'
assert os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '') == '0', \
"visual_studio_path requires DEPOT_TOOLS_WIN_TOOLCHAIN=0 env variable"
msvs_path = os.environ.get('GYP_MSVS_OVERRIDE_PATH', '')
assert msvs_path == visual_studio_path and os.path.exists(msvs_path), \
"visual_studio_path requires matching GYP_MSVS_OVERRIDE_PATH env variable"
msvs_version = os.environ.get('GYP_MSVS_VERSION', '')
assert msvs_version == visual_studio_version, \
"visual_studio_version requires matching GYP_MSVS_VERSION env variable"
assert os.environ.get('CEF_VCVARS', '') == 'none', \
"visual_studio_path requires CEF_VCVARS=none env variable"
# If vcvarsall.bat exists then environment variables will be derived from
# there and any specified INCLUDE/LIB values will be ignored by Chromium
# (PATH is retained because it might contain required VS runtime
# libraries). If this file does not exist then the INCLUDE/LIB/PATH values
# are also required by Chromium.
vcvars_path = os.path.join(msvs_path, 'VC', 'vcvarsall.bat')
if not os.path.exists(vcvars_path):
vcvars_path = os.path.join(msvs_path, 'VC', 'Auxiliary', 'Build',
'vcvarsall.bat')
if os.path.exists(vcvars_path):
if 'INCLUDE' in os.environ:
del os.environ['INCLUDE']
if 'LIB' in os.environ:
del os.environ['LIB']
if 'LIBPATH' in os.environ:
del os.environ['LIBPATH']
else:
assert 'INCLUDE' in os.environ \
and 'LIB' in os.environ \
and 'PATH' in os.environ, \
"visual_studio_path requires INCLUDE, LIB and PATH env variables"