Abort if xcrun -find foo
returns superbin/foo
Fixes Homebrew/homebrew#14691. Rewrite in Ruby to facilitate checking PATHs properly.
This commit is contained in:
parent
82c58bb615
commit
1ae0e93d7e
@ -1,38 +1,30 @@
|
|||||||
#!/bin/bash
|
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0
|
||||||
|
|
||||||
# This wrapper because 4.3 xcrun doesn't work with CLT-only configurations
|
# This wrapper because 4.3 xcrun doesn't work with CLT-only configurations
|
||||||
# But many build-systems expect it to work. This fixes that.
|
# But many build-systems expect it to work. This fixes that.
|
||||||
# NOTE only works if they call xcrun without a full-path. Cross your fingers!
|
# NOTE only works if the build-tool calls xcrun without a path prefixed!
|
||||||
|
|
||||||
[ "$#" -eq 0 ] && exec /usr/bin/xcrun
|
ENV['HOMEBREW_LOG'] = nil
|
||||||
|
|
||||||
if [ $HOMEBREW_SDKROOT ]; then
|
require "#{File.dirname __FILE__}/../libsuperenv"
|
||||||
arg0="$1"
|
|
||||||
shift
|
|
||||||
|
|
||||||
case $arg0 in
|
exec "/usr/bin/xcrun", *ARGV if ARGV.empty? or ARGV[0][0..0] == '-'
|
||||||
-*)
|
exec "/usr/bin/#{ARGV.shift}", *ARGV unless ENV['HOMEBREW_SDKROOT'].directory?
|
||||||
exec /usr/bin/xcrun "$arg0" "$@";;
|
|
||||||
esac
|
|
||||||
|
|
||||||
path="$(/usr/bin/xcrun -find $arg0)"
|
def try path
|
||||||
[ -x "$path" ] && exec "$path" "$@"
|
exec path, *ARGV if File.executable?(path) and path.cleanpath.dirname != SUPERBIN
|
||||||
|
end
|
||||||
|
|
||||||
# Nuts, Xcode is not setup properly or something.
|
arg0 = ARGV.shift
|
||||||
# Try to find the tools anyway!
|
try `/usr/bin/xcrun --find #{arg0}`
|
||||||
path="/Applications/Xcode.app/Contents/Developer/usr/bin/$arg0"
|
# Nuts, Xcode is not setup properly or something. Try to find the tools anyway!
|
||||||
[ -x "$path" ] && exec "$path" "$@"
|
try "/Applications/Xcode.app/Contents/Developer/usr/bin/#{arg0}"
|
||||||
path="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/$arg0"
|
try "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/#{arg0}"
|
||||||
[ -x "$path" ] && exec "$path" "$@"
|
try "/usr/bin/#{arg0}"
|
||||||
path="/usr/bin/$arg0"
|
|
||||||
[ -x "$path" ] && exec "$path" "$@"
|
|
||||||
|
|
||||||
echo "Your Xcode setup is not ready. You need to either:"
|
abort <<-EOS
|
||||||
echo " sudo xcode-select -switch /path/to/Xcode.app"
|
Your Xcode and or CLT are mis-configured. Try some or all of the following:
|
||||||
echo "or:"
|
xcrun --kill-cache
|
||||||
echo " xcodebuild -license"
|
xcodebuild -license
|
||||||
exit 1
|
sudo xcode-select -switch /path/to/Xcode.app
|
||||||
else
|
EOS
|
||||||
cmd="$1"
|
|
||||||
shift
|
|
||||||
exec "/usr/bin/$cmd" "$@"
|
|
||||||
fi
|
|
||||||
|
@ -39,3 +39,4 @@ end if ENV['HOMEBREW_LOG']
|
|||||||
|
|
||||||
$brewfix = "#{__FILE__}/../../../".cleanpath.freeze
|
$brewfix = "#{__FILE__}/../../../".cleanpath.freeze
|
||||||
$sdkroot = ENV['HOMEBREW_SDKROOT'].freeze
|
$sdkroot = ENV['HOMEBREW_SDKROOT'].freeze
|
||||||
|
SUPERBIN = __FILE__.dirname.cleanpath.freeze
|
||||||
|
Loading…
x
Reference in New Issue
Block a user