From 9282b08972d06a32598d4e46905edf56d92fc9eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Tue, 16 Apr 2024 23:34:39 +0200 Subject: [PATCH] compat: Wire up MachineSpec.config for Windows Where MSVC vs MinGW is important, and the CRT flavor in the former case. --- compat/build.py | 18 ++++++++++++++++-- compat/meson.build | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/compat/build.py b/compat/build.py index 72e34813d..d9297bbec 100755 --- a/compat/build.py +++ b/compat/build.py @@ -31,6 +31,8 @@ def main(argv): command.add_argument("builddir", help="build directory", type=Path) command.add_argument("host_os", help="operating system binaries are being built for") command.add_argument("host_arch", help="architecture binaries are being built for") + command.add_argument("host_toolchain", help="the kind of toolchain being used", + choices=["microsoft", "apple", "gnu"]) command.add_argument("compat", help="support for targets with a different architecture", type=parse_compat_option_value) command.add_argument("assets", help="whether assets are embedded vs installed and loaded at runtime") @@ -40,6 +42,7 @@ def main(argv): args.builddir, args.host_os, args.host_arch, + args.host_toolchain, args.compat, args.assets, args.components)) @@ -81,6 +84,7 @@ def setup(role: Role, builddir: Path, host_os: str, host_arch: str, + host_toolchain: str, compat: set[str], assets: str, components: set[str]): @@ -217,7 +221,7 @@ def setup(role: Role, if not outputs: return - state = State(role, host_os, host_arch, outputs) + state = State(role, host_os, host_arch, host_toolchain, outputs) privdir = compute_private_dir(builddir) privdir.mkdir(exist_ok=True) (privdir / STATE_FILENAME).write_bytes(pickle.dumps(state)) @@ -232,6 +236,7 @@ class State: role: Role host_os: str host_arch: str + host_toolchain: str outputs: Mapping[str, Sequence[Output]] @@ -272,11 +277,20 @@ def call_internal_meson(argv, *args, **kwargs): build_env = scrub_environment(os.environ) for extra_arch, outputs in state.outputs.items(): workdir = compute_workdir_for_arch(extra_arch, builddir) - host_machine = MachineSpec(state.host_os, extra_arch) if not (workdir / "build.ninja").exists(): if options is None: options = load_meson_options(top_builddir, state.role) + + if state.host_os == "windows": + if state.host_toolchain == "microsoft": + config = next((opt.split("=")[1] for opt in options if opt.startswith("-Db_vscrt="))) + else: + config = "mingw" + else: + config = None + host_machine = MachineSpec(state.host_os, extra_arch, config) + configure(sourcedir=REPO_ROOT, builddir=workdir, host_machine=host_machine, diff --git a/compat/meson.build b/compat/meson.build index 7d0e37f36..8feb00920 100644 --- a/compat/meson.build +++ b/compat/meson.build @@ -38,6 +38,7 @@ if no_overridden_compat_bits meson.current_build_dir(), host_os, host_abi, + host_toolchain, ','.join(get_option('compat')), get_option('assets'), ','.join(components),