From 85187bf6d3779692c77b5ef8a256f16b3048294a Mon Sep 17 00:00:00 2001 From: William Woodruff Date: Sat, 13 Jun 2015 20:32:04 -0400 Subject: [PATCH] MacOS: update locate_cctool This becomes MacOS.{install_name_tool,otool}, only do check_xcode if xcode is installed, otherwise emit a warning --- Library/Homebrew/cmd/install.rb | 7 ++++++- Library/Homebrew/keg_relocate.rb | 4 ++-- Library/Homebrew/mach.rb | 4 ++-- Library/Homebrew/os/mac.rb | 16 ++++++++++++++++ 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index fa9507fb3c..1ef1ca61a5 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -157,7 +157,12 @@ module Homebrew def perform_preinstall_checks check_ppc check_writable_install_location - check_xcode + if MacOS::Xcode.installed? + check_xcode + else + opoo "You have not installed Xcode." + puts "Bottles may install correctly, but builds will fail!" + end check_cellar end diff --git a/Library/Homebrew/keg_relocate.rb b/Library/Homebrew/keg_relocate.rb index eceef192f1..59ff1c9d7c 100644 --- a/Library/Homebrew/keg_relocate.rb +++ b/Library/Homebrew/keg_relocate.rb @@ -98,8 +98,8 @@ class Keg end def install_name_tool(*args) - tool = MacOS.locate("install_name_tool") - system(tool, *args) || raise(ErrorDuringExecution.new(tool, args)) + tool = MacOS.install_name_tool + system(tool, *args) || raise ErrorDuringExecution.new(tool, args) end # If file is a dylib or bundle itself, look for the dylib named by diff --git a/Library/Homebrew/mach.rb b/Library/Homebrew/mach.rb index c15399cbfc..f7ca428e6e 100644 --- a/Library/Homebrew/mach.rb +++ b/Library/Homebrew/mach.rb @@ -154,9 +154,9 @@ module MachO def parse_otool_L_output ENV["HOMEBREW_MACH_O_FILE"] = path.expand_path.to_s - libs = `#{MacOS.locate("otool")} -L "$HOMEBREW_MACH_O_FILE"`.split("\n") + libs = `#{MacOS.otool} -L "$HOMEBREW_MACH_O_FILE"`.split("\n") unless $?.success? - raise ErrorDuringExecution.new(MacOS.locate("otool"), + raise ErrorDuringExecution.new(MacOS.otool, ["-L", ENV["HOMEBREW_MACH_O_FILE"]]) end diff --git a/Library/Homebrew/os/mac.rb b/Library/Homebrew/os/mac.rb index ffab00b009..1851265488 100644 --- a/Library/Homebrew/os/mac.rb +++ b/Library/Homebrew/os/mac.rb @@ -36,6 +36,22 @@ module OS end end + def install_name_tool + if File.executable?(path = "#{HOMEBREW_PREFIX}/opt/cctools/bin/install_name_tool") + Pathname.new(path) + else + locate("install_name_tool") + end + end + + def otool + if File.executable?(path = "#{HOMEBREW_PREFIX}/opt/cctools/bin/otool") + Pathname.new(path) + else + locate("otool") + end + end + def active_developer_dir @active_developer_dir ||= Utils.popen_read("/usr/bin/xcode-select", "-print-path").strip end