diff --git a/Library/Homebrew/extend/os/mac/extend/ENV/super.rb b/Library/Homebrew/extend/os/mac/extend/ENV/super.rb index d43b6c9c2a..2ca2a00e4b 100644 --- a/Library/Homebrew/extend/os/mac/extend/ENV/super.rb +++ b/Library/Homebrew/extend/os/mac/extend/ENV/super.rb @@ -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. diff --git a/Library/Homebrew/shims/mac/super/xcrun b/Library/Homebrew/shims/mac/super/xcrun index 128f40ba2a..167109f306 100755 --- a/Library/Homebrew/shims/mac/super/xcrun +++ b/Library/Homebrew/shims/mac/super/xcrun @@ -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 "$@"