aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMax Howell2012-02-18 01:53:42 +0000
committerMax Howell2012-02-18 01:53:55 +0000
commite1461b9d2055f893a0693c695ac89d787ab5178c (patch)
treebd3378dae46edeae8a4356001c056b22d405f244 /Library
parent1e9a4dbfe49b666d6441507d90948e8030594b8a (diff)
downloadbrew-e1461b9d2055f893a0693c695ac89d787ab5178c.tar.bz2
OTT handling for various Xcode-4.3/CLI-Tools edge cases
Also xcrun can only exist at /usr/bin/xcrun. Most of these edges are non-buildable environments, but I didn't know that when writing it, so it may as well stay, since it still does make brew --env more correct.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/extend/ENV.rb23
-rw-r--r--Library/Homebrew/utils.rb19
2 files changed, 26 insertions, 16 deletions
diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb
index 8689d977a..f3ba9c0c5 100644
--- a/Library/Homebrew/extend/ENV.rb
+++ b/Library/Homebrew/extend/ENV.rb
@@ -89,7 +89,7 @@ module HomebrewEnvExtension
def xcrun tool
if File.executable? "/usr/bin/#{tool}"
"/usr/bin/#{tool}"
- elsif system "#{MacOS.xcrun} -find #{tool} 2>1 1>/dev/null"
+ elsif 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}"
@@ -99,17 +99,26 @@ module HomebrewEnvExtension
if File.executable? fn
fn
else
- nil
+ # This is for the use-case where xcode-select is not set up with
+ # Xcode 4.3. The tools in Xcode 4.3 are split over two locations,
+ # usually xcrun would figure that out for us, but it won't work if
+ # xcode-select is not configured properly.
+ fn = "#{MacOS.xcode_prefix}/Toolchains/XcodeDefault.xctoolchain/usr/bin/#{tool}"
+ if File.executable? fn
+ fn
+ else
+ nil
+ end
end
end
end
# if your formula doesn't like CC having spaces use this
def expand_xcrun
- ENV['CC'] =~ %r{#{MacOS.xcrun} (.*)}
- ENV['CC'] = `#{MacOS.xcrun} -find #{$1}`.chomp if $1
- ENV['CXX'] =~ %r{#{MacOS.xcrun} (.*)}
- ENV['CXX'] = `#{MacOS.xcrun} -find #{$1}`.chomp if $1
+ ENV['CC'] =~ %r{/usr/bin/xcrun (.*)}
+ ENV['CC'] = `/usr/bin/xcrun -find #{$1}`.chomp if $1
+ ENV['CXX'] =~ %r{/usr/bin/xcrun (.*)}
+ ENV['CXX'] = `/usr/bin/xcrun -find #{$1}`.chomp if $1
end
def gcc args = {}
@@ -126,7 +135,7 @@ module HomebrewEnvExtension
raise "GCC could not be found" if not File.exist? ENV['CC']
end
- if not ENV['CC'] =~ /^[^\s]*xcrun /
+ if not ENV['CC'] =~ %{^/usr/bin/xcrun }
raise "GCC could not be found" if Pathname.new(ENV['CC']).realpath.to_s =~ /llvm/
end
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 1fcb23591..a0491a255 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -266,17 +266,18 @@ module MacOS extend self
end
end
- def xcrun
- @xcrun ||= begin
- path = "#{xcode_prefix}/usr/bin/xcrun"
- path = "xcrun" unless File.file? path # just in case
- path
+ def default_cc
+ cc = `/usr/bin/xcrun -find cc 2> /dev/null`.chomp
+ cc = "#{dev_tools_path}/cc" if cc.empty? or not $?.success?
+
+ unless File.executable? cc
+ # If xcode-select isn't setup then xcrun fails and on Xcode 4.3
+ # the cc binary is not at #{dev_tools_path}. This return is almost
+ # worthless however since in this particular setup nothing much builds
+ # but I wrote the code now and maybe we'll fix the other issues later.
+ cc = "#{xcode_prefix}/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc"
end
- end
- def default_cc
- cc = `#{xcrun} -find cc 2> /dev/null`.chomp
- cc = "#{dev_tools_path}/cc" if cc.empty?
Pathname.new(cc).realpath.basename.to_s rescue nil
end