shims/mac/super/xcrun: use Homebrew's chosen SDK and DEVELOPER_DIR

Fixes #7250.
This commit is contained in:
Bo Anderson 2020-04-01 16:25:00 +01:00
parent c1708ff6b9
commit 99550ff564
2 changed files with 18 additions and 3 deletions

View File

@ -109,6 +109,11 @@ module Superenv
def setup_build_environment(formula = nil)
generic_setup_build_environment(formula)
self["HOMEBREW_SDKROOT"] = effective_sysroot
self["HOMEBREW_DEVELOPER_DIR"] = if MacOS::CLT.installed? && MacOS::CLT.provides_sdk?
MacOS::CLT::PKG_PATH
else
MacOS::Xcode.prefix
end
# Filter out symbols known not to be defined since GNU Autotools can't
# reliably figure this out with Xcode 8 and above.

View File

@ -1,10 +1,20 @@
#!/bin/sh
#!/bin/bash
# Historically, xcrun has had various bugs, and in some cases it didn't
# work at all (e.g. CLT-only in the Xcode 4.3 era). This script emulates
# it and attempts to avoid these issues.
# Some build tools set DEVELOPER_DIR, so discard it
unset DEVELOPER_DIR
# SDKROOT is not used if `--sdk` is supplied.
# We however don't want to interrupt other uses like `xcrun --find clang`.
if [[ "$*" =~ (^| )-?-sdk ]]; then
export DEVELOPER_DIR=$HOMEBREW_DEVELOPER_DIR
else
# Some build tools set DEVELOPER_DIR, so discard it
unset DEVELOPER_DIR
fi
if [ -z "$SDKROOT" ]; then
export SDKROOT=$HOMEBREW_SDKROOT
fi
if [ $# -eq 0 ]; then
exec /usr/bin/xcrun "$@"