Bug 1807779 - Allow to set a single variable for MSVC. r=firefox-build-system-reviewers,ahochheiden

For builds using our toolchain artifact (or a similarly shaped copy of
MSVC + SDKs)

Differential Revision: https://phabricator.services.mozilla.com/D165592
This commit is contained in:
Mike Hommey 2022-12-28 22:48:51 +00:00
parent ce754eb1e4
commit b2be53b830
6 changed files with 33 additions and 13 deletions

View File

@ -548,6 +548,16 @@ def is_windows(target, host):
return host.kernel == "WINNT" or target.kernel == "WINNT"
# Calling this a sysroot is a little weird, but it's the terminology clang went
# with with its -winsysroot flag.
option(
env="WINSYSROOT",
nargs=1,
when=is_windows,
help='Path to a Windows "sysroot" (directory containing MSVC, SDKs)',
)
option(
env="VC_PATH",
nargs=1,
@ -561,12 +571,21 @@ option(
vs_version,
build_environment,
"VC_PATH",
"WINSYSROOT",
when=is_windows,
)
@imports("os")
@imports(_from="operator", _import="itemgetter")
def vc_compiler_paths_for_version(host, vs_version, env, vc_path):
if vc_path and vs_version:
die("VC_PATH and --with-visual-studio-version cannot be used together.")
def vc_compiler_paths_for_version(host, vs_version, env, vc_path, winsysroot):
if (vc_path or winsysroot) and vs_version:
var = "VC_PATH" if vc_path else "WINSYSROOT"
die(f"{var} and --with-visual-studio-version cannot be used together.")
if winsysroot:
if vc_path:
die("WINSYSROOT and VC_PATH cannot be set together.")
base_vc_path = os.path.join(winsysroot[0], "VC", "Tools", "MSVC")
versions = os.listdir(base_vc_path)
vc_path = [os.path.join(base_vc_path, str(max(Version(v) for v in versions)))]
if vc_path:
# Use an arbitrary version, it doesn't matter.
all_versions = [(Version("15"), vc_path[0])]

View File

@ -31,15 +31,20 @@ def valid_windows_version(value):
option(env="WINDOWSSDKDIR", nargs=1, help="Directory containing the Windows SDK")
@depends("WINDOWSSDKDIR", c_compiler, host_c_compiler)
def windows_sdk_dir(value, compiler, host_compiler):
@depends("WINDOWSSDKDIR", "WINSYSROOT", c_compiler, host_c_compiler)
def windows_sdk_dir(value, winsysroot, compiler, host_compiler):
if value:
if winsysroot:
die("WINDOWSSDKDIR and WINSYSROOT cannot be set together.")
return value
# Ideally, we'd actually check for host/target ABI being MSVC, but
# that's waiting for bug 1617793.
if compiler.type != "clang-cl" and host_compiler.type != "clang-cl":
return ()
if winsysroot:
return [os.path.join(winsysroot[0], "Windows Kits", "10")]
return set(
normalize_path(x[1])
for x in get_registry_values(

View File

@ -18,8 +18,7 @@ unset BINDGEN_CFLAGS
unset ENABLE_CLANG_PLUGIN
unset MACOS_SDK_DIR
unset MACOS_PRIVATE_FRAMEWORKS_DIR
unset VC_PATH
unset WINDOWSSDKDIR
unset WINSYSROOT
unset MOZ_LTO
unset MOZ_STDCXX_COMPAT

View File

@ -3,10 +3,9 @@ if [ -z "${VSPATH}" ]; then
fi
if [ -d "${VSPATH}" ]; then
export WINDOWSSDKDIR="${VSPATH}/windows kits/10"
export WIN32_REDIST_DIR="${VSPATH}/vc/redist/msvc/14.16.27012/x86/microsoft.vc141.crt"
export WIN_UCRT_REDIST_DIR="${VSPATH}/windows kits/10/redist/ucrt/dlls/x86"
export VC_PATH="${VSPATH}/vc/tools/msvc/14.16.27023"
export WINSYSROOT="${VSPATH}"
fi
ac_add_options --target=i686-pc-mingw32

View File

@ -3,7 +3,6 @@ if [ -z "${VSPATH}" ]; then
fi
if [ -d "${VSPATH}" ]; then
export WINDOWSSDKDIR="${VSPATH}/windows kits/10"
export WIN32_REDIST_DIR="${VSPATH}/vc/redist/msvc/14.16.27012/arm64/microsoft.vc141.crt"
export VC_PATH="${VSPATH}/vc/tools/msvc/14.16.27023"
export WINSYSROOT="${VSPATH}"
fi

View File

@ -3,8 +3,7 @@ if [ -z "${VSPATH}" ]; then
fi
if [ -d "${VSPATH}" ]; then
export WINDOWSSDKDIR="${VSPATH}/windows kits/10"
export WIN32_REDIST_DIR=${VSPATH}/vc/redist/msvc/14.16.27012/x64/microsoft.vc141.crt
export WIN_UCRT_REDIST_DIR="${VSPATH}/windows kits/10/redist/ucrt/dlls/x64"
export VC_PATH="${VSPATH}/vc/tools/msvc/14.16.27023"
export WINSYSROOT="${VSPATH}"
fi