From 7d49831886cb86aef7946a6e0a8d902af42eae98 Mon Sep 17 00:00:00 2001 From: deepend Date: Thu, 19 Feb 2026 11:54:54 -0700 Subject: [PATCH] Updated macOS architecture sanity-check flow in meson.build to first read the Meson option into a variable and then allow an environment-variable override (ZOITECHAT_DARWIN_ARCH_SANITY_CHECK) before running the mismatch guard. Accepted disable values are 0, false, no, and off. Kept the existing mismatch detection logic intact, but updated the error text to document both bypass methods (-Ddarwin-arch-sanity-check=false or ZOITECHAT_DARWIN_ARCH_SANITY_CHECK=0). --- meson.build | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 2fabd0a3..2a813b74 100644 --- a/meson.build +++ b/meson.build @@ -35,7 +35,15 @@ else required: get_option('tls')) endif -if host_machine.system() == 'darwin' and get_option('darwin-arch-sanity-check') +darwin_arch_sanity_check = get_option('darwin-arch-sanity-check') +if host_machine.system() == 'darwin' and darwin_arch_sanity_check + darwin_arch_sanity_check_env = run_command('sh', '-c', 'printf %s "$ZOITECHAT_DARWIN_ARCH_SANITY_CHECK"', check: false).stdout().strip().to_lower() + if ['0', 'false', 'no', 'off'].contains(darwin_arch_sanity_check_env) + darwin_arch_sanity_check = false + endif +endif + +if host_machine.system() == 'darwin' and darwin_arch_sanity_check cflags_env = run_command('sh', '-c', 'printf %s "$CFLAGS"', check: false).stdout().strip() ldflags_env = run_command('sh', '-c', 'printf %s "$LDFLAGS"', check: false).stdout().strip() pkgconfig_glib = run_command('pkg-config', '--libs-only-L', 'glib-2.0', check: false) @@ -46,7 +54,7 @@ if host_machine.system() == 'darwin' and get_option('darwin-arch-sanity-check') if targeting_x86_64 and using_arm_homebrew error('Detected x86_64 build flags (-arch x86_64) while pkg-config resolves glib from /opt/homebrew (arm64). ' + 'Use arm64 build flags with /opt/homebrew, or run an x86_64/Rosetta environment with an x86_64 dependency stack (typically /usr/local). ' + - 'To bypass this safety check, configure with -Ddarwin-arch-sanity-check=false.') + 'To bypass this safety check, configure with -Ddarwin-arch-sanity-check=false or set ZOITECHAT_DARWIN_ARCH_SANITY_CHECK=0.') endif endif