forked from mirrors/gecko-dev
Bug 1817372 - Refactor checks for the MSVC abi that take the form of a compiler check. r=firefox-build-system-reviewers,andi
We're soon going to introduce a new way to distinguish between the two windows ABIs, so we factor out compiler checks that will need to be adjusted to limit the amount of changes down the line. Differential Revision: https://phabricator.services.mozilla.com/D170167
This commit is contained in:
parent
d4f69748d1
commit
f608c3ae17
3 changed files with 47 additions and 24 deletions
|
|
@ -1509,6 +1509,23 @@ host_cxx_compiler = compiler(
|
||||||
other_c_compiler=c_compiler,
|
other_c_compiler=c_compiler,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@template
|
||||||
|
def windows_abi(host_or_target, c_compiler):
|
||||||
|
@depends(host_or_target, c_compiler)
|
||||||
|
def windows_abi(host_or_target, c_compiler):
|
||||||
|
if host_or_target.os == "WINNT":
|
||||||
|
if c_compiler.type == "clang-cl":
|
||||||
|
return "msvc"
|
||||||
|
return "mingw"
|
||||||
|
|
||||||
|
return windows_abi
|
||||||
|
|
||||||
|
|
||||||
|
target_windows_abi = windows_abi(target, c_compiler)
|
||||||
|
host_windows_abi = windows_abi(host, host_c_compiler)
|
||||||
|
|
||||||
|
|
||||||
# Generic compiler-based conditions.
|
# Generic compiler-based conditions.
|
||||||
building_with_gcc = depends(c_compiler)(lambda info: info.type == "gcc")
|
building_with_gcc = depends(c_compiler)(lambda info: info.type == "gcc")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,15 +31,13 @@ def valid_windows_version(value):
|
||||||
option(env="WINDOWSSDKDIR", nargs=1, help="Directory containing the Windows SDK")
|
option(env="WINDOWSSDKDIR", nargs=1, help="Directory containing the Windows SDK")
|
||||||
|
|
||||||
|
|
||||||
@depends("WINDOWSSDKDIR", "WINSYSROOT", c_compiler, host_c_compiler)
|
@depends("WINDOWSSDKDIR", "WINSYSROOT", target_windows_abi, host_windows_abi)
|
||||||
def windows_sdk_dir(value, winsysroot, compiler, host_compiler):
|
def windows_sdk_dir(value, winsysroot, target_windows_abi, host_windows_abi):
|
||||||
if value:
|
if value:
|
||||||
if winsysroot:
|
if winsysroot:
|
||||||
die("WINDOWSSDKDIR and WINSYSROOT cannot be set together.")
|
die("WINDOWSSDKDIR and WINSYSROOT cannot be set together.")
|
||||||
return value
|
return value
|
||||||
# Ideally, we'd actually check for host/target ABI being MSVC, but
|
if target_windows_abi != "msvc" and host_windows_abi != "msvc":
|
||||||
# that's waiting for bug 1617793.
|
|
||||||
if compiler.type != "clang-cl" and host_compiler.type != "clang-cl":
|
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
if winsysroot:
|
if winsysroot:
|
||||||
|
|
@ -86,17 +84,25 @@ def valid_windows_sdk_dir_result(value):
|
||||||
|
|
||||||
|
|
||||||
@depends(
|
@depends(
|
||||||
c_compiler, host_c_compiler, windows_sdk_dir, valid_windows_version, "WINDOWSSDKDIR"
|
c_compiler,
|
||||||
|
target_windows_abi,
|
||||||
|
host_windows_abi,
|
||||||
|
windows_sdk_dir,
|
||||||
|
valid_windows_version,
|
||||||
|
"WINDOWSSDKDIR",
|
||||||
)
|
)
|
||||||
@checking("for Windows SDK", valid_windows_sdk_dir_result)
|
@checking("for Windows SDK", valid_windows_sdk_dir_result)
|
||||||
@imports(_from="__builtin__", _import="Exception")
|
@imports(_from="__builtin__", _import="Exception")
|
||||||
@imports(_from="textwrap", _import="dedent")
|
@imports(_from="textwrap", _import="dedent")
|
||||||
def valid_windows_sdk_dir(
|
def valid_windows_sdk_dir(
|
||||||
compiler, host_compiler, windows_sdk_dir, target_version, windows_sdk_dir_env
|
compiler,
|
||||||
|
target_windows_abi,
|
||||||
|
host_windows_abi,
|
||||||
|
windows_sdk_dir,
|
||||||
|
target_version,
|
||||||
|
windows_sdk_dir_env,
|
||||||
):
|
):
|
||||||
# Ideally, we'd actually check for host/target ABI being MSVC, but
|
if target_windows_abi != "msvc" and host_windows_abi != "msvc":
|
||||||
# that's waiting for bug 1617793.
|
|
||||||
if compiler.type != "clang-cl" and host_compiler.type != "clang-cl":
|
|
||||||
return None
|
return None
|
||||||
if windows_sdk_dir_env:
|
if windows_sdk_dir_env:
|
||||||
windows_sdk_dir_env = windows_sdk_dir_env[0]
|
windows_sdk_dir_env = windows_sdk_dir_env[0]
|
||||||
|
|
@ -171,14 +177,14 @@ def valid_ucrt_sdk_dir_result(value):
|
||||||
return "%s in %s" % (value.version, quote(value.path))
|
return "%s in %s" % (value.version, quote(value.path))
|
||||||
|
|
||||||
|
|
||||||
@depends(windows_sdk_dir, "WINDOWSSDKDIR", c_compiler, host_c_compiler)
|
@depends(windows_sdk_dir, "WINDOWSSDKDIR", target_windows_abi, host_windows_abi)
|
||||||
@checking("for Universal CRT SDK", valid_ucrt_sdk_dir_result)
|
@checking("for Universal CRT SDK", valid_ucrt_sdk_dir_result)
|
||||||
@imports("os")
|
@imports("os")
|
||||||
@imports(_import="mozpack.path", _as="mozpath")
|
@imports(_import="mozpack.path", _as="mozpath")
|
||||||
def valid_ucrt_sdk_dir(windows_sdk_dir, windows_sdk_dir_env, compiler, host_compiler):
|
def valid_ucrt_sdk_dir(
|
||||||
# Ideally, we'd actually check for host/target ABI being MSVC, but
|
windows_sdk_dir, windows_sdk_dir_env, target_windows_abi, host_windows_abi
|
||||||
# that's waiting for bug 1617793.
|
):
|
||||||
if compiler.type != "clang-cl" and host_compiler.type != "clang-cl":
|
if target_windows_abi != "msvc" and host_windows_abi != "msvc":
|
||||||
return None
|
return None
|
||||||
if windows_sdk_dir_env:
|
if windows_sdk_dir_env:
|
||||||
windows_sdk_dir_env = windows_sdk_dir_env[0]
|
windows_sdk_dir_env = windows_sdk_dir_env[0]
|
||||||
|
|
@ -256,10 +262,10 @@ def valid_ucrt_sdk_dir(windows_sdk_dir, windows_sdk_dir_env, compiler, host_comp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@depends(c_compiler, host_c_compiler, vc_toolchain_search_path)
|
@depends(target_windows_abi, host_windows_abi, vc_toolchain_search_path)
|
||||||
@imports("os")
|
@imports("os")
|
||||||
def vc_path(c_compiler, host_c_compiler, vc_toolchain_search_path):
|
def vc_path(target_windows_abi, host_windows_abi, vc_toolchain_search_path):
|
||||||
if c_compiler.type != "clang-cl" and host_c_compiler.type != "clang-cl":
|
if target_windows_abi != "msvc" and host_windows_abi != "msvc":
|
||||||
return
|
return
|
||||||
|
|
||||||
# In clang-cl builds, we need the headers and libraries from an MSVC installation.
|
# In clang-cl builds, we need the headers and libraries from an MSVC installation.
|
||||||
|
|
|
||||||
|
|
@ -256,17 +256,17 @@ def so_version(value):
|
||||||
@template
|
@template
|
||||||
def library_name_info_template(host_or_target):
|
def library_name_info_template(host_or_target):
|
||||||
assert host_or_target in {host, target}
|
assert host_or_target in {host, target}
|
||||||
compiler = {
|
windows_abi = {
|
||||||
host: host_c_compiler,
|
host: host_windows_abi,
|
||||||
target: c_compiler,
|
target: target_windows_abi,
|
||||||
}[host_or_target]
|
}[host_or_target]
|
||||||
|
|
||||||
@depends(host_or_target, compiler, so_version)
|
@depends(host_or_target, windows_abi, so_version)
|
||||||
def library_name_info_impl(host_or_target, compiler, so_version):
|
def library_name_info_impl(host_or_target, windows_abi, so_version):
|
||||||
if host_or_target.kernel == "WINNT":
|
if host_or_target.kernel == "WINNT":
|
||||||
# There aren't artifacts for mingw builds, so it's OK that the
|
# There aren't artifacts for mingw builds, so it's OK that the
|
||||||
# results are inaccurate in that case.
|
# results are inaccurate in that case.
|
||||||
if compiler and compiler.type != "clang-cl":
|
if windows_abi and windows_abi != "msvc":
|
||||||
return namespace(
|
return namespace(
|
||||||
dll=namespace(prefix="", suffix=".dll"),
|
dll=namespace(prefix="", suffix=".dll"),
|
||||||
lib=namespace(prefix="lib", suffix="a"),
|
lib=namespace(prefix="lib", suffix="a"),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue