From 6242a6d7fa0b9a928b8bd53560c058f7b876eae4 Mon Sep 17 00:00:00 2001 From: Misty De Meo Date: Fri, 26 Jul 2013 23:21:44 -0700 Subject: [PATCH] MacOS.locate: search HOMEBREW_PREFIX before xcrun Since xcrun doesn't work on CLT-only systems. Querying HOMEBREW_PREFIX first before xcrun is much faster for that case. --- Library/Homebrew/macos.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/macos.rb b/Library/Homebrew/macos.rb index b86bc8f42e..2e5c02f394 100644 --- a/Library/Homebrew/macos.rb +++ b/Library/Homebrew/macos.rb @@ -18,11 +18,16 @@ module MacOS extend self # Give the name of the binary you look for as a string to this method # in order to get the full path back as a Pathname. (@locate ||= {}).fetch(tool.to_s) do - @locate[tool.to_s] = if File.executable? "/usr/bin/#{tool}" - Pathname.new "/usr/bin/#{tool}" + @locate[tool.to_s] = if File.executable?(path = "/usr/bin/#{tool}") + Pathname.new path + # Homebrew GCCs most frequently; much faster to check this before xcrun + # This also needs to be queried if xcrun won't work, e.g. CLT-only + elsif File.executable?(path = "#{HOMEBREW_PREFIX}/bin/#{tool}") + Pathname.new path else - # If the tool isn't in /usr/bin, then we first try to use xcrun to find - # it. If it's not there, or xcode-select is misconfigured, we have to + # If the tool isn't in /usr/bin or from Homebrew, + # then we first try to use xcrun to find it. + # If it's not there, or xcode-select is misconfigured, we have to # look in dev_tools_path, and finally in xctoolchain_path, because the # tools were split over two locations beginning with Xcode 4.3+. xcrun_path = unless Xcode.bad_xcode_select_path?