aboutsummaryrefslogtreecommitdiffstats
path: root/Library/ENV
diff options
context:
space:
mode:
authorMax Howell2012-09-24 08:54:06 -0400
committerMax Howell2012-09-24 09:49:53 -0400
commit1ae0e93d7e70b7d784cbc0940f996c49c67c1ceb (patch)
tree5f276dec5f1296bdc6e3ff13ab585765989f6d12 /Library/ENV
parent82c58bb615420390bd49e6bf476d3000890b889c (diff)
downloadbrew-1ae0e93d7e70b7d784cbc0940f996c49c67c1ceb.tar.bz2
Abort if `xcrun -find foo` returns superbin/foo
Fixes Homebrew/homebrew#14691. Rewrite in Ruby to facilitate checking PATHs properly.
Diffstat (limited to 'Library/ENV')
-rwxr-xr-xLibrary/ENV/4.3/xcrun52
-rw-r--r--Library/ENV/libsuperenv.rb1
2 files changed, 23 insertions, 30 deletions
diff --git a/Library/ENV/4.3/xcrun b/Library/ENV/4.3/xcrun
index 453042f6b..2c6625f83 100755
--- a/Library/ENV/4.3/xcrun
+++ b/Library/ENV/4.3/xcrun
@@ -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
# 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
- arg0="$1"
- shift
+require "#{File.dirname __FILE__}/../libsuperenv"
- case $arg0 in
- -*)
- exec /usr/bin/xcrun "$arg0" "$@";;
- esac
+exec "/usr/bin/xcrun", *ARGV if ARGV.empty? or ARGV[0][0..0] == '-'
+exec "/usr/bin/#{ARGV.shift}", *ARGV unless ENV['HOMEBREW_SDKROOT'].directory?
- path="$(/usr/bin/xcrun -find $arg0)"
- [ -x "$path" ] && exec "$path" "$@"
+def try path
+ exec path, *ARGV if File.executable?(path) and path.cleanpath.dirname != SUPERBIN
+end
- # Nuts, Xcode is not setup properly or something.
- # Try to find the tools anyway!
- path="/Applications/Xcode.app/Contents/Developer/usr/bin/$arg0"
- [ -x "$path" ] && exec "$path" "$@"
- path="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/$arg0"
- [ -x "$path" ] && exec "$path" "$@"
- path="/usr/bin/$arg0"
- [ -x "$path" ] && exec "$path" "$@"
+arg0 = ARGV.shift
+try `/usr/bin/xcrun --find #{arg0}`
+# Nuts, Xcode is not setup properly or something. Try to find the tools anyway!
+try "/Applications/Xcode.app/Contents/Developer/usr/bin/#{arg0}"
+try "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/#{arg0}"
+try "/usr/bin/#{arg0}"
- echo "Your Xcode setup is not ready. You need to either:"
- echo " sudo xcode-select -switch /path/to/Xcode.app"
- echo "or:"
- echo " xcodebuild -license"
- exit 1
-else
- cmd="$1"
- shift
- exec "/usr/bin/$cmd" "$@"
-fi
+abort <<-EOS
+Your Xcode and or CLT are mis-configured. Try some or all of the following:
+ xcrun --kill-cache
+ xcodebuild -license
+ sudo xcode-select -switch /path/to/Xcode.app
+EOS
diff --git a/Library/ENV/libsuperenv.rb b/Library/ENV/libsuperenv.rb
index dcd97efce..48093cc9b 100644
--- a/Library/ENV/libsuperenv.rb
+++ b/Library/ENV/libsuperenv.rb
@@ -39,3 +39,4 @@ end if ENV['HOMEBREW_LOG']
$brewfix = "#{__FILE__}/../../../".cleanpath.freeze
$sdkroot = ENV['HOMEBREW_SDKROOT'].freeze
+SUPERBIN = __FILE__.dirname.cleanpath.freeze