diff options
| author | Jack Nagel | 2013-07-21 16:41:50 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-07-21 16:41:50 -0500 |
| commit | a8f7f4caff42f7984e9d616b88e19d5330fff3fb (patch) | |
| tree | 46a65fd314f9943f8cec2570f1d5b3971b3eb8f1 /Library | |
| parent | 4d5a011bcfadd5fc2ee920e3ed35b8d4bbb2f2e7 (diff) | |
| download | homebrew-a8f7f4caff42f7984e9d616b88e19d5330fff3fb.tar.bz2 | |
Pull another unwieldy condition into a method
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/macos.rb | 16 |
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 |
