From 86bef2094af5ab73e6e869a4174b366522943016 Mon Sep 17 00:00:00 2001 From: Dustin Spicuzza Date: Tue, 13 May 2025 01:05:03 -0400 Subject: [PATCH] macos: when ARCHFLAGS is specified, add pkgconf/strip to cross file --- src/hatch_meson/plugin.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/hatch_meson/plugin.py b/src/hatch_meson/plugin.py index 8d7fa5b..43f061b 100644 --- a/src/hatch_meson/plugin.py +++ b/src/hatch_meson/plugin.py @@ -677,18 +677,28 @@ def _create_macos_crossfile(crossfile_path: pathlib.Path) -> bool: family = "aarch64" if arch == "arm64" else arch cross_file_data = textwrap.dedent( f""" - [binaries] - c = ['cc', '-arch', {arch!r}] - cpp = ['c++', '-arch', {arch!r}] - objc = ['cc', '-arch', {arch!r}] - objcpp = ['c++', '-arch', {arch!r}] [host_machine] system = 'darwin' cpu = {arch!r} cpu_family = {family!r} endian = 'little' + [binaries] + c = ['cc', '-arch', {arch!r}] + cpp = ['c++', '-arch', {arch!r}] + objc = ['cc', '-arch', {arch!r}] + objcpp = ['c++', '-arch', {arch!r}] """ ) + + # Support common binaries + pkgconf_path = shutil.which("pkgconf") + if pkgconf_path: + cross_file_data += f"pkg-config = {pkgconf_path!r}\n" + + strip_path = shutil.which("strip") + if strip_path: + cross_file_data += f"strip = {strip_path!r}\n" + crossfile_path.write_text(cross_file_data, encoding="utf-8") return True