2014-06-03 10:03:34 -05:00
|
|
|
#!/bin/sh
|
2014-04-29 21:51:18 -05:00
|
|
|
# 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.
|
superenv: build-environments that just work
1. A minimal build environment, we don't set CFLAGS, CPPFLAGS, LDFLAGS, etc. the rationale being, the less that is set, the less variables we are introducing that can break builds.
2. A set of scripts that replace cc, ld, etc. and inject the -I, -L, etc. flags we need into the args passed to the build-tools.
Because we now have complete control over compiler instantiations we do a variety of clean-up tasks, like removing bad flags, enforcing universal builds and ensuring makefiles don't try to change the order of library and include paths from ones that work to ones that don't.
The previous ENV-system is still available when --env=std is specified.
superenv applies to Xcode >= 4.3 only currently.
2012-08-11 12:30:51 -04:00
|
|
|
|
2014-04-29 21:51:18 -05:00
|
|
|
# Some build tools set DEVELOPER_DIR, so discard it
|
2014-06-03 10:03:34 -05:00
|
|
|
unset DEVELOPER_DIR
|
|
|
|
|
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
exec /usr/bin/xcrun "$@"
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
-*) exec /usr/bin/xcrun "$@" ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
arg0=$1
|
|
|
|
shift
|
|
|
|
|
|
|
|
exe="/usr/bin/${arg0}"
|
|
|
|
if [ -x "$exe" ]; then
|
|
|
|
if [ -n "$HOMEBREW_PREFER_CLT_PROXIES" ]; then
|
|
|
|
exec "$exe" "$@"
|
|
|
|
elif [ -z "$HOMEBREW_SDKROOT" -o ! -d "$HOMEBREW_SDKROOT" ]; then
|
|
|
|
exec "$exe" "$@"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
SUPERBIN=$(cd "${0%/*}" && pwd -P)
|
|
|
|
|
|
|
|
exe=$(/usr/bin/xcrun --find "$arg0" 2>/dev/null)
|
|
|
|
if [ -x "$exe" -a "${exe%/*}" != "$SUPERBIN" ]; then
|
|
|
|
exec "$exe" "$@"
|
|
|
|
fi
|
|
|
|
|
|
|
|
old_IFS=$IFS
|
|
|
|
IFS=:
|
|
|
|
for path in $PATH; do
|
|
|
|
if [ "$path" = "$SUPERBIN" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
exe="${path}/${arg0}"
|
|
|
|
if [ -x "$exe" ]; then
|
|
|
|
exec "$exe" "$@"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
IFS=$old_IFS
|
|
|
|
|
|
|
|
echo >&2 "
|
|
|
|
Failed to execute $arg0 $@
|
2014-04-21 11:03:42 -05:00
|
|
|
|
|
|
|
Xcode and/or the CLT appear to be misconfigured. Try one or both of the following:
|
|
|
|
xcodebuild -license
|
|
|
|
sudo xcode-select -switch /path/to/Xcode.app
|
2014-06-03 10:03:34 -05:00
|
|
|
"
|
|
|
|
exit 1
|