Mike McQuaid a02be9eea2 ENV: move to new paths. (#507)
Move some stuff formerly in `Library/ENV` around:
- Move `Library/ENV/$XCODE_VERSION` to `Library/Homebrew/env/super` as they are
  all superenv wrappers and all symlinks to the same version. We never needed
  the "separate shims for separate versions" functionality and it just adds
  confusion.
- Move `Library/ENV/pkgconfig` to `Library/Homebrew/env/pkgconfig` to get more
  things under `Library/Homebrew`
- Move `Library/ENV/scm` to `Library/scm` as these wrappers are not actually
  used by or related to superenv (or stdenv) in any way.
2016-07-15 19:03:45 +01:00

58 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# 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
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 $@
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
"
exit 1