aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2013-07-21 16:41:50 -0500
committerJack Nagel2013-07-21 16:41:50 -0500
commit4adf8f047ab30c55605e2276ab9c102aec0e71e5 (patch)
tree2cd31d6ec75f4601f44aa81c8f8093b8891cea9e /Library
parentd9b9b77fa674c1f8c9ee46eaa2aac8d1cb46f419 (diff)
downloadbrew-4adf8f047ab30c55605e2276ab9c102aec0e71e5.tar.bz2
Pull another unwieldy condition into a method
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/macos.rb16
1 files changed, 9 insertions, 7 deletions
diff --git a/Library/Homebrew/macos.rb b/Library/Homebrew/macos.rb
index 1483e42a6..4a941d613 100644
--- a/Library/Homebrew/macos.rb
+++ b/Library/Homebrew/macos.rb
@@ -40,17 +40,14 @@ module MacOS extend self
end
def dev_tools_path
- @dev_tools_path ||= \
- if File.exist? MacOS::CLT::STANDALONE_PKG_PATH and
- File.exist? "#{MacOS::CLT::STANDALONE_PKG_PATH}/usr/bin/cc" and
- File.exist? "#{MacOS::CLT::STANDALONE_PKG_PATH}/usr/bin/make"
+ @dev_tools_path ||= if tools_in_prefix? CLT::STANDALONE_PKG_PATH
# In 10.9 the CLT moved from /usr into /Library/Developer/CommandLineTools.
- Pathname.new "#{MacOS::CLT::STANDALONE_PKG_PATH}/usr/bin"
- elsif File.exist? "/usr/bin/cc" and File.exist? "/usr/bin/make"
+ Pathname.new "#{CLT::STANDALONE_PKG_PATH}/usr/bin"
+ elsif tools_in_prefix? "/"
# probably a safe enough assumption (the unix way)
Pathname.new "/usr/bin"
- # Note that the exit status of system "xcrun foo" isn't always accurate
elsif not Xcode.bad_xcode_select_path? and not `/usr/bin/xcrun -find make 2>/dev/null`.empty?
+ # Note that the exit status of system "xcrun foo" isn't always accurate
# Wherever "make" is there are the dev tools.
Pathname.new(`/usr/bin/xcrun -find make`.chomp).dirname
elsif File.exist? "#{Xcode.prefix}/usr/bin/make"
@@ -59,6 +56,11 @@ module MacOS extend self
end
end
+ def tools_in_prefix?(prefix)
+ File.directory?(prefix) &&
+ %w{cc make}.all? { |tool| File.executable? "#{prefix}/usr/bin/#{tool}" }
+ end
+
def xctoolchain_path
# As of Xcode 4.3, some tools are located in the "xctoolchain" directory
@xctoolchain_path ||= begin