ENV/super: replace m4 shim with M4 variable

The problem is the shim can end up getting baked into formula binaries
(e.g. `flex`) or cause odd issues when mixed up with brew `m4`, e.g.
https://github.com/Homebrew/homebrew-core/issues/180040
This commit is contained in:
Michael Cho 2024-09-11 11:03:12 -04:00
parent 9c8068793b
commit 99d81b4717
No known key found for this signature in database
GPG Key ID: 55E85E28A7CD1E85
2 changed files with 10 additions and 19 deletions

View File

@ -99,6 +99,16 @@ module Superenv
MacOS::CLT::PKG_PATH
end
# This is a workaround for the missing `m4` in Xcode CLT 15.3, which was
# reported in FB13679972. Apple has fixed this in Xcode CLT 16.0.
# See https://github.com/Homebrew/homebrew-core/issues/165388
if deps.none? { |d| d.name == "m4" } &&
MacOS.active_developer_dir == MacOS::CLT::PKG_PATH &&
!File.exist?("#{MacOS::CLT::PKG_PATH}/usr/bin/m4") &&
(gm4 = DevelopmentTools.locate("gm4").to_s).present?
self["M4"] = gm4
end
generic_setup_build_environment(formula:, cc:, build_bottle:, bottle_arch:,
testing_formula:, debug_symbols:)

View File

@ -1,19 +0,0 @@
#!/bin/bash
# This shim is a workaround for the missing `m4` in Xcode CLT 15.3.
# It can be removed after Apple provides a new CLT with a fix for FB13679972.
# See https://github.com/Homebrew/homebrew-core/issues/165388
# HOMEBREW_LIBRARY is set by bin/brew
# HOMEBREW_DEVELOPER_DIR is set by extend/ENV/super.rb
# shellcheck disable=SC2154
source "${HOMEBREW_LIBRARY}/Homebrew/shims/utils.sh"
try_exec_non_system "${SHIM_FILE}" "$@"
if [[ -n "${HOMEBREW_DEVELOPER_DIR}" && ! -x "${HOMEBREW_DEVELOPER_DIR}/usr/bin/m4" ]]
then
safe_exec "/usr/bin/gm4" "$@"
fi
exec "/usr/bin/m4" "$@"