use Pathname#executable? directly

This commit is contained in:
Xu Cheng 2015-08-22 13:21:13 +08:00
parent a88c40b8c8
commit 62be981016

View File

@ -27,8 +27,8 @@ module OS
@locate[key] = if File.executable?(path = "/usr/bin/#{tool}")
Pathname.new path
# Homebrew GCCs most frequently; much faster to check this before xcrun
elsif File.executable?(path = "#{HOMEBREW_PREFIX}/bin/#{tool}")
Pathname.new path
elsif (path = HOMEBREW_PREFIX/"bin/#{tool}").executable?
path
else
path = Utils.popen_read("/usr/bin/xcrun", "-no-cache", "-find", tool).chomp
Pathname.new(path) if File.executable?(path)
@ -39,8 +39,8 @@ module OS
# Locates a (working) copy of install_name_tool, guaranteed to function
# whether the user has developer tools installed or not.
def install_name_tool
if File.executable?(path = "#{HOMEBREW_PREFIX}/opt/cctools/bin/install_name_tool")
Pathname.new(path)
if (path = HOMEBREW_PREFIX/"opt/cctools/bin/install_name_tool").executable?
path
else
locate("install_name_tool")
end
@ -49,8 +49,8 @@ module OS
# Locates a (working) copy of otool, guaranteed to function whether the user
# has developer tools installed or not.
def otool
if File.executable?(path = "#{HOMEBREW_PREFIX}/opt/cctools/bin/otool")
Pathname.new(path)
if (path = HOMEBREW_PREFIX/"opt/cctools/bin/otool").executable?
path
else
locate("otool")
end