Skip to content

Commit

Permalink
compat: Wire up MachineSpec.config for Windows
Browse files Browse the repository at this point in the history
Where MSVC vs MinGW is important, and the CRT flavor in the former case.
  • Loading branch information
oleavr committed Apr 16, 2024
1 parent ef3325f commit 9282b08
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
18 changes: 16 additions & 2 deletions compat/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -40,6 +42,7 @@ def main(argv):
args.builddir,
args.host_os,
args.host_arch,
args.host_toolchain,
args.compat,
args.assets,
args.components))
Expand Down Expand Up @@ -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]):
Expand Down Expand Up @@ -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))
Expand All @@ -232,6 +236,7 @@ class State:
role: Role
host_os: str
host_arch: str
host_toolchain: str
outputs: Mapping[str, Sequence[Output]]


Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions compat/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 9282b08

Please sign in to comment.