Rewrite xcrun wrapper in shell
This commit is contained in:
parent
6e616b29c5
commit
3ccca7720f
@ -1,50 +1,57 @@
|
|||||||
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0
|
#!/bin/sh
|
||||||
|
|
||||||
# Historically, xcrun has had various bugs, and in some cases it didn't
|
# 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
|
# work at all (e.g. CLT-only in the Xcode 4.3 era). This script emulates
|
||||||
# it and attempts to avoid these issues.
|
# it and attempts to avoid these issues.
|
||||||
|
|
||||||
# Some build tools set DEVELOPER_DIR, so discard it
|
# Some build tools set DEVELOPER_DIR, so discard it
|
||||||
ENV.delete "DEVELOPER_DIR"
|
unset DEVELOPER_DIR
|
||||||
|
|
||||||
if ARGV.empty? || ARGV[0][0..0] == "-"
|
if [ $# -eq 0 ]; then
|
||||||
exec "/usr/bin/xcrun", *ARGV
|
exec /usr/bin/xcrun "$@"
|
||||||
end
|
fi
|
||||||
|
|
||||||
arg0 = ARGV.shift
|
case "$1" in
|
||||||
|
-*) exec /usr/bin/xcrun "$@" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
exe = "/usr/bin/#{arg0}"
|
arg0=$1
|
||||||
if File.executable?(exe)
|
shift
|
||||||
exec(exe, *ARGV) if ENV["HOMEBREW_PREFER_CLT_PROXIES"]
|
|
||||||
sdkroot = ENV["HOMEBREW_SDKROOT"]
|
|
||||||
exec(exe, *ARGV) unless sdkroot && File.directory?(sdkroot)
|
|
||||||
end
|
|
||||||
|
|
||||||
$:.unshift "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8"
|
exe="/usr/bin/${arg0}"
|
||||||
require "pathname"
|
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
|
||||||
|
|
||||||
def canonical_dirname path
|
SUPERBIN=$(cd "${0%/*}" && pwd -P)
|
||||||
Pathname.new(path).dirname.realpath.to_s
|
|
||||||
end
|
|
||||||
|
|
||||||
SUPERBIN = canonical_dirname(__FILE__)
|
exe=$(/usr/bin/xcrun --find "$arg0" 2>/dev/null)
|
||||||
|
if [ -x "$exe" -a "${exe%/*}" != "$SUPERBIN" ]; then
|
||||||
|
exec "$exe" "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
exe = `/usr/bin/xcrun --find #{arg0} 2>/dev/null`.chomp
|
old_IFS=$IFS
|
||||||
if File.executable?(exe) && canonical_dirname(exe) != SUPERBIN
|
IFS=:
|
||||||
exec(exe, *ARGV)
|
for path in $PATH; do
|
||||||
end
|
if [ "$path" = "$SUPERBIN" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
paths = ENV["PATH"].split(File::PATH_SEPARATOR)
|
exe="${path}/${arg0}"
|
||||||
paths.delete(SUPERBIN)
|
if [ -x "$exe" ]; then
|
||||||
paths.each do |path|
|
exec "$exe" "$@"
|
||||||
exe = File.join(path, arg0)
|
fi
|
||||||
exec(exe, *ARGV) if File.executable?(exe)
|
done
|
||||||
end
|
IFS=$old_IFS
|
||||||
|
|
||||||
abort <<-EOS
|
echo >&2 "
|
||||||
Failed to execute: #{arg0} #{ARGV.join(" ")}
|
Failed to execute $arg0 $@
|
||||||
|
|
||||||
Xcode and/or the CLT appear to be misconfigured. Try one or both of the following:
|
Xcode and/or the CLT appear to be misconfigured. Try one or both of the following:
|
||||||
xcodebuild -license
|
xcodebuild -license
|
||||||
sudo xcode-select -switch /path/to/Xcode.app
|
sudo xcode-select -switch /path/to/Xcode.app
|
||||||
EOS
|
"
|
||||||
|
exit 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user