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).
This commit is contained in:
2026-02-19 11:54:54 -07:00
parent d2e6dabdca
commit 7d49831886

View File

@@ -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