From 61a8bd9ca0d30c571212f534e4262715fba72e49 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Tue, 21 Feb 2012 10:32:48 +0000 Subject: [PATCH] Don't hang if xcode-select -print-path is "/" Introducing MacOS.xctools_fucked?. Refs Homebrew/homebrew#10293. --- Library/Homebrew/cmd/--env.rb | 2 +- Library/Homebrew/extend/ENV.rb | 2 +- Library/Homebrew/utils.rb | 12 ++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/cmd/--env.rb b/Library/Homebrew/cmd/--env.rb index d020ac0ac9..9f5f4bb7ad 100644 --- a/Library/Homebrew/cmd/--env.rb +++ b/Library/Homebrew/cmd/--env.rb @@ -18,7 +18,7 @@ module Homebrew extend self value = env[k] if value results = value - if value =~ /^[^\s]*xcrun (.*)/ + if value =~ %r{/usr/bin/xcrun (.*)} path = `/usr/bin/xcrun -find #{$1}` results += " => #{path}" elsif File.exists? value and File.symlink? value diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb index 0373bced11..2f2a0d90a9 100644 --- a/Library/Homebrew/extend/ENV.rb +++ b/Library/Homebrew/extend/ENV.rb @@ -94,7 +94,7 @@ module HomebrewEnvExtension def xcrun tool if File.executable? "/usr/bin/#{tool}" "/usr/bin/#{tool}" - elsif system "/usr/bin/xcrun -find #{tool} 2>1 1>/dev/null" + elsif not MacOS.xctools_fucked? and system "/usr/bin/xcrun -find #{tool} 2>1 1>/dev/null" # xcrun was provided first with Xcode 4.3 and allows us to proxy # tool usage thus avoiding various bugs "/usr/bin/xcrun #{tool}" diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 2854c82b15..2ad5cbc784 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -266,9 +266,17 @@ module MacOS extend self end end + def xctools_fucked? + # Xcode 4.3 tools hang if "/" is set + `/usr/bin/xcode-select -print-path 2>/dev/null`.chomp == "/" + end + def default_cc - cc = `/usr/bin/xcrun -find cc 2> /dev/null`.chomp - cc = "#{dev_tools_path}/cc" if cc.empty? or not $?.success? + cc = unless xctools_fucked? + out = `/usr/bin/xcrun -find cc 2> /dev/null`.chomp + out if $?.success? + end + cc = "#{dev_tools_path}/cc" if cc.nil? or cc.empty? unless File.executable? cc # If xcode-select isn't setup then xcrun fails and on Xcode 4.3