| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  | require "hardware" | 
					
						
							|  |  |  | require "os/mac/version" | 
					
						
							|  |  |  | require "os/mac/xcode" | 
					
						
							|  |  |  | require "os/mac/xquartz" | 
					
						
							| 
									
										
										
										
											2015-10-16 17:08:11 +08:00
										 |  |  | require "os/mac/pathname" | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | module OS | 
					
						
							|  |  |  |   module Mac | 
					
						
							|  |  |  |     extend self | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ::MacOS = self # compatibility | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # This can be compared to numerics, strings, or symbols | 
					
						
							|  |  |  |     # using the standard Ruby Comparable methods. | 
					
						
							|  |  |  |     def version | 
					
						
							| 
									
										
										
										
											2015-10-16 16:41:14 +08:00
										 |  |  |       @version ||= Version.new(full_version.to_s[/10\.\d+/]) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # This can be compared to numerics, strings, or symbols | 
					
						
							|  |  |  |     # using the standard Ruby Comparable methods. | 
					
						
							|  |  |  |     def full_version | 
					
						
							|  |  |  |       @full_version ||= Version.new(`/usr/bin/sw_vers -productVersion`.chomp) | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-23 00:07:12 +02:00
										 |  |  |     def prerelease? | 
					
						
							|  |  |  |       # TODO: bump version when new OS is released | 
					
						
							|  |  |  |       version >= "10.12" | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |     def cat | 
					
						
							|  |  |  |       version.to_sym | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     def locate(tool) | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |       # Don't call tools (cc, make, strip, etc.) directly! | 
					
						
							|  |  |  |       # 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. | 
					
						
							| 
									
										
										
										
											2014-04-21 22:39:44 -05:00
										 |  |  |       (@locate ||= {}).fetch(tool) do |key| | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |         @locate[key] = if File.executable?(path = "/usr/bin/#{tool}") | 
					
						
							|  |  |  |           Pathname.new path | 
					
						
							|  |  |  |         # Homebrew GCCs most frequently; much faster to check this before xcrun | 
					
						
							| 
									
										
										
										
											2015-08-22 13:21:13 +08:00
										 |  |  |         elsif (path = HOMEBREW_PREFIX/"bin/#{tool}").executable? | 
					
						
							|  |  |  |           path | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |         else | 
					
						
							| 
									
										
										
										
											2014-12-16 15:27:36 -05:00
										 |  |  |           path = Utils.popen_read("/usr/bin/xcrun", "-no-cache", "-find", tool).chomp | 
					
						
							| 
									
										
										
											
												Trust xcrun now that we error out early for bad xcode-select paths
Since ae177adb2bd55ee5ad6367e7639c4cf0c774b63a, we can safely assume
that xcrun works, and a functioning xcrun will search dev_tools_path and
xctoolchain_path, so we can stop doing extra work here.
On CLT-only 10.7 and 10.8, xcrun will not work, but all the tools will
be in /usr/bin, which we check before invoking xcrun. Further, in this
case, dev_tools_path will be /usr/bin, and xctoolchain_path will not
exist, so the fallbacks here are unnecessary.
											
										 
											2014-05-01 18:36:46 -05:00
										 |  |  |           Pathname.new(path) if File.executable?(path) | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |         end | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2015-06-13 20:32:04 -04:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-12 14:57:54 -04:00
										 |  |  |     # Locates a (working) copy of install_name_tool, guaranteed to function | 
					
						
							|  |  |  |     # whether the user has developer tools installed or not. | 
					
						
							| 
									
										
										
										
											2015-06-13 20:32:04 -04:00
										 |  |  |     def install_name_tool | 
					
						
							| 
									
										
										
										
											2015-08-22 13:21:13 +08:00
										 |  |  |       if (path = HOMEBREW_PREFIX/"opt/cctools/bin/install_name_tool").executable? | 
					
						
							|  |  |  |         path | 
					
						
							| 
									
										
										
										
											2015-06-13 20:32:04 -04:00
										 |  |  |       else | 
					
						
							|  |  |  |         locate("install_name_tool") | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-12 14:57:54 -04:00
										 |  |  |     # Locates a (working) copy of otool, guaranteed to function whether the user | 
					
						
							|  |  |  |     # has developer tools installed or not. | 
					
						
							| 
									
										
										
										
											2015-06-13 20:32:04 -04:00
										 |  |  |     def otool | 
					
						
							| 
									
										
										
										
											2015-08-22 13:21:13 +08:00
										 |  |  |       if (path = HOMEBREW_PREFIX/"opt/cctools/bin/otool").executable? | 
					
						
							|  |  |  |         path | 
					
						
							| 
									
										
										
										
											2015-06-13 20:32:04 -04:00
										 |  |  |       else | 
					
						
							|  |  |  |         locate("otool") | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-12 14:57:54 -04:00
										 |  |  |     # Checks if the user has any developer tools installed, either via Xcode | 
					
						
							|  |  |  |     # or the CLT. Convenient for guarding against formula builds when building | 
					
						
							|  |  |  |     # is impossible. | 
					
						
							| 
									
										
										
										
											2015-07-26 16:49:16 -04:00
										 |  |  |     def has_apple_developer_tools? | 
					
						
							| 
									
										
										
										
											2015-06-29 14:09:57 -04:00
										 |  |  |       Xcode.installed? || CLT.installed? | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-01 18:36:46 -05:00
										 |  |  |     def active_developer_dir | 
					
						
							| 
									
										
										
										
											2014-12-16 15:27:36 -05:00
										 |  |  |       @active_developer_dir ||= Utils.popen_read("/usr/bin/xcode-select", "-print-path").strip | 
					
						
							| 
									
										
										
										
											2014-05-01 18:36:46 -05:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |     def sdk_path(v = version) | 
					
						
							|  |  |  |       (@sdk_path ||= {}).fetch(v.to_s) do |key| | 
					
						
							|  |  |  |         opts = [] | 
					
						
							|  |  |  |         # First query Xcode itself | 
					
						
							| 
									
										
										
										
											2014-12-16 15:27:36 -05:00
										 |  |  |         opts << Utils.popen_read(locate("xcodebuild"), "-version", "-sdk", "macosx#{v}", "Path").chomp | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |         # Xcode.prefix is pretty smart, so lets look inside to find the sdk | 
					
						
							|  |  |  |         opts << "#{Xcode.prefix}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX#{v}.sdk" | 
					
						
							|  |  |  |         # Xcode < 4.3 style | 
					
						
							|  |  |  |         opts << "/Developer/SDKs/MacOSX#{v}.sdk" | 
					
						
							|  |  |  |         @sdk_path[key] = opts.map { |a| Pathname.new(a) }.detect(&:directory?) | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def default_cc | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |       cc = locate "cc" | 
					
						
							| 
									
										
										
										
											2014-01-04 01:20:56 -08:00
										 |  |  |       cc.realpath.basename.to_s rescue nil | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def default_compiler | 
					
						
							|  |  |  |       case default_cc | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |       when /^gcc-4.0/ then :gcc_4_0 | 
					
						
							|  |  |  |       when /^gcc/ then :gcc | 
					
						
							|  |  |  |       when /^llvm/ then :llvm | 
					
						
							|  |  |  |       when "clang" then :clang | 
					
						
							|  |  |  |       else | 
					
						
							|  |  |  |         # guess :( | 
					
						
							|  |  |  |         if Xcode.version >= "4.3" | 
					
						
							|  |  |  |           :clang | 
					
						
							|  |  |  |         elsif Xcode.version >= "4.2" | 
					
						
							|  |  |  |           :llvm | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |         else | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |           :gcc | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def gcc_40_build_version | 
					
						
							|  |  |  |       @gcc_40_build_version ||= | 
					
						
							|  |  |  |         if (path = locate("gcc-4.0")) | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |         `#{path} --version`[/build (\d{4,})/, 1].to_i | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |         end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |     alias_method :gcc_4_0_build_version, :gcc_40_build_version | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def gcc_42_build_version | 
					
						
							|  |  |  |       @gcc_42_build_version ||= | 
					
						
							| 
									
										
										
										
											2013-10-19 23:09:09 -07:00
										 |  |  |         begin | 
					
						
							| 
									
										
										
										
											2014-05-01 16:57:14 -05:00
										 |  |  |           gcc = MacOS.locate("gcc-4.2") || HOMEBREW_PREFIX.join("opt/apple-gcc42/bin/gcc-4.2") | 
					
						
							| 
									
										
										
										
											2014-05-01 18:22:39 -05:00
										 |  |  |           if gcc.exist? && gcc.realpath.basename.to_s !~ /^llvm/ | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |             `#{gcc} --version`[/build (\d{4,})/, 1].to_i | 
					
						
							| 
									
										
										
										
											2014-05-01 16:57:14 -05:00
										 |  |  |           end | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |         end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |     alias_method :gcc_build_version, :gcc_42_build_version | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def llvm_build_version | 
					
						
							|  |  |  |       @llvm_build_version ||= | 
					
						
							|  |  |  |         if (path = locate("llvm-gcc")) && path.realpath.basename.to_s !~ /^clang/ | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |         `#{path} --version`[/LLVM build (\d{4,})/, 1].to_i | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |         end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def clang_version | 
					
						
							|  |  |  |       @clang_version ||= | 
					
						
							|  |  |  |         if (path = locate("clang")) | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |         `#{path} --version`[/(?:clang|LLVM) version (\d\.\d)/, 1] | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |         end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def clang_build_version | 
					
						
							|  |  |  |       @clang_build_version ||= | 
					
						
							|  |  |  |         if (path = locate("clang")) | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |         `#{path} --version`[/clang-(\d{2,})/, 1].to_i | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |         end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def non_apple_gcc_version(cc) | 
					
						
							| 
									
										
										
										
											2014-07-13 10:50:56 -05:00
										 |  |  |       (@non_apple_gcc_version ||= {}).fetch(cc) do | 
					
						
							|  |  |  |         path = HOMEBREW_PREFIX.join("opt", "gcc", "bin", cc) | 
					
						
							|  |  |  |         path = locate(cc) unless path.exist? | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |         version = `#{path} --version`[/gcc(?:-\d(?:\.\d)? \(.+\))? (\d\.\d\.\d)/, 1] if path | 
					
						
							| 
									
										
										
										
											2014-07-13 10:50:56 -05:00
										 |  |  |         @non_apple_gcc_version[cc] = version | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-24 08:46:24 +01:00
										 |  |  |     def clear_version_cache | 
					
						
							|  |  |  |       @gcc_40_build_version = @gcc_42_build_version = @llvm_build_version = nil | 
					
						
							|  |  |  |       @clang_version = @clang_build_version = nil | 
					
						
							|  |  |  |       @non_apple_gcc_version = {} | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |     # See these issues for some history: | 
					
						
							| 
									
										
										
										
											2015-01-04 05:02:27 +01:00
										 |  |  |     # https://github.com/Homebrew/homebrew/issues/13 | 
					
						
							|  |  |  |     # https://github.com/Homebrew/homebrew/issues/41 | 
					
						
							|  |  |  |     # https://github.com/Homebrew/homebrew/issues/48 | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |     def macports_or_fink | 
					
						
							|  |  |  |       paths = [] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       # First look in the path because MacPorts is relocatable and Fink | 
					
						
							|  |  |  |       # may become relocatable in the future. | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |       %w[port fink].each do |ponk| | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |         path = which(ponk) | 
					
						
							|  |  |  |         paths << path unless path.nil? | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       # Look in the standard locations, because even if port or fink are | 
					
						
							|  |  |  |       # not in the path they can still break builds if the build scripts | 
					
						
							|  |  |  |       # have these paths baked in. | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |       %w[/sw/bin/fink /opt/local/bin/port].each do |ponk| | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |         path = Pathname.new(ponk) | 
					
						
							|  |  |  |         paths << path if path.exist? | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       # Finally, some users make their MacPorts or Fink directorie | 
					
						
							|  |  |  |       # read-only in order to try out Homebrew, but this doens't work as | 
					
						
							|  |  |  |       # some build scripts error out when trying to read from these now | 
					
						
							|  |  |  |       # unreadable paths. | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |       %w[/sw /opt/local].map { |p| Pathname.new(p) }.each do |path| | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |         paths << path if path.exist? && !path.readable? | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       paths.uniq | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def prefer_64_bit? | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |       Hardware::CPU.is_64_bit? && version > :leopard | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def preferred_arch | 
					
						
							| 
									
										
										
										
											2013-11-26 20:23:19 -06:00
										 |  |  |       if prefer_64_bit? | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |         Hardware::CPU.arch_64_bit | 
					
						
							|  |  |  |       else | 
					
						
							|  |  |  |         Hardware::CPU.arch_32_bit | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     STANDARD_COMPILERS = { | 
					
						
							| 
									
										
										
										
											2013-10-20 00:41:08 -07:00
										 |  |  |       "2.5"   => { :gcc_40_build => 5370 }, | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |       "3.1.4" => { :gcc_40_build => 5493, :gcc_42_build => 5577 }, | 
					
						
							|  |  |  |       "3.2.6" => { :gcc_40_build => 5494, :gcc_42_build => 5666, :llvm_build => 2335, :clang => "1.7", :clang_build => 77 }, | 
					
						
							|  |  |  |       "4.0"   => { :gcc_40_build => 5494, :gcc_42_build => 5666, :llvm_build => 2335, :clang => "2.0", :clang_build => 137 }, | 
					
						
							|  |  |  |       "4.0.1" => { :gcc_40_build => 5494, :gcc_42_build => 5666, :llvm_build => 2335, :clang => "2.0", :clang_build => 137 }, | 
					
						
							|  |  |  |       "4.0.2" => { :gcc_40_build => 5494, :gcc_42_build => 5666, :llvm_build => 2335, :clang => "2.0", :clang_build => 137 }, | 
					
						
							|  |  |  |       "4.2"   => { :llvm_build => 2336, :clang => "3.0", :clang_build => 211 }, | 
					
						
							|  |  |  |       "4.3"   => { :llvm_build => 2336, :clang => "3.1", :clang_build => 318 }, | 
					
						
							|  |  |  |       "4.3.1" => { :llvm_build => 2336, :clang => "3.1", :clang_build => 318 }, | 
					
						
							|  |  |  |       "4.3.2" => { :llvm_build => 2336, :clang => "3.1", :clang_build => 318 }, | 
					
						
							|  |  |  |       "4.3.3" => { :llvm_build => 2336, :clang => "3.1", :clang_build => 318 }, | 
					
						
							|  |  |  |       "4.4"   => { :llvm_build => 2336, :clang => "4.0", :clang_build => 421 }, | 
					
						
							|  |  |  |       "4.4.1" => { :llvm_build => 2336, :clang => "4.0", :clang_build => 421 }, | 
					
						
							|  |  |  |       "4.5"   => { :llvm_build => 2336, :clang => "4.1", :clang_build => 421 }, | 
					
						
							|  |  |  |       "4.5.1" => { :llvm_build => 2336, :clang => "4.1", :clang_build => 421 }, | 
					
						
							|  |  |  |       "4.5.2" => { :llvm_build => 2336, :clang => "4.1", :clang_build => 421 }, | 
					
						
							|  |  |  |       "4.6"   => { :llvm_build => 2336, :clang => "4.2", :clang_build => 425 }, | 
					
						
							|  |  |  |       "4.6.1" => { :llvm_build => 2336, :clang => "4.2", :clang_build => 425 }, | 
					
						
							|  |  |  |       "4.6.2" => { :llvm_build => 2336, :clang => "4.2", :clang_build => 425 }, | 
					
						
							|  |  |  |       "4.6.3" => { :llvm_build => 2336, :clang => "4.2", :clang_build => 425 }, | 
					
						
							|  |  |  |       "5.0"   => { :clang => "5.0", :clang_build => 500 }, | 
					
						
							|  |  |  |       "5.0.1" => { :clang => "5.0", :clang_build => 500 }, | 
					
						
							| 
									
										
										
										
											2013-11-05 22:19:33 -06:00
										 |  |  |       "5.0.2" => { :clang => "5.0", :clang_build => 500 }, | 
					
						
							| 
									
										
										
										
											2014-03-10 15:26:19 -05:00
										 |  |  |       "5.1"   => { :clang => "5.1", :clang_build => 503 }, | 
					
						
							| 
									
										
										
										
											2014-04-05 15:23:58 +02:00
										 |  |  |       "5.1.1" => { :clang => "5.1", :clang_build => 503 }, | 
					
						
							| 
									
										
										
										
											2014-08-07 23:43:05 +01:00
										 |  |  |       "6.0"   => { :clang => "6.0", :clang_build => 600 }, | 
					
						
							| 
									
										
										
										
											2014-09-18 10:09:14 -05:00
										 |  |  |       "6.0.1" => { :clang => "6.0", :clang_build => 600 }, | 
					
						
							| 
									
										
										
										
											2014-09-10 02:44:36 +01:00
										 |  |  |       "6.1"   => { :clang => "6.0", :clang_build => 600 }, | 
					
						
							| 
									
										
										
										
											2014-12-03 02:40:22 +00:00
										 |  |  |       "6.1.1" => { :clang => "6.0", :clang_build => 600 }, | 
					
						
							| 
									
										
										
										
											2015-03-10 00:08:43 +00:00
										 |  |  |       "6.2"   => { :clang => "6.0", :clang_build => 600 }, | 
					
						
							| 
									
										
										
										
											2015-04-09 00:55:37 +01:00
										 |  |  |       "6.3"   => { :clang => "6.1", :clang_build => 602 }, | 
					
						
							| 
									
										
										
										
											2015-04-22 05:09:40 +01:00
										 |  |  |       "6.3.1" => { :clang => "6.1", :clang_build => 602 }, | 
					
						
							| 
									
										
										
										
											2015-05-19 18:52:36 +01:00
										 |  |  |       "6.3.2" => { :clang => "6.1", :clang_build => 602 }, | 
					
						
							| 
									
										
										
										
											2015-07-08 15:21:32 +01:00
										 |  |  |       "6.4"   => { :clang => "6.1", :clang_build => 602 }, | 
					
						
							| 
									
										
										
										
											2015-10-01 05:51:35 +01:00
										 |  |  |       "7.0"   => { :clang => "7.0", :clang_build => 700 }, | 
					
						
							|  |  |  |       "7.0.1" => { :clang => "7.0", :clang_build => 700 }, | 
					
						
							| 
									
										
										
										
											2015-10-23 14:16:03 +02:00
										 |  |  |       "7.1"   => { :clang => "7.0", :clang_build => 700 }, | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def compilers_standard? | 
					
						
							|  |  |  |       STANDARD_COMPILERS.fetch(Xcode.version.to_s).all? do |method, build| | 
					
						
							|  |  |  |         send(:"#{method}_version") == build | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     rescue IndexError | 
					
						
							|  |  |  |       onoe <<-EOS.undent
 | 
					
						
							|  |  |  |         Homebrew doesn't know what compiler versions ship with your version | 
					
						
							|  |  |  |         of Xcode (#{Xcode.version}). Please `brew update` and if that doesn't help, file | 
					
						
							|  |  |  |         an issue with the output of `brew --config`: | 
					
						
							| 
									
										
										
										
											2013-12-14 18:14:50 +00:00
										 |  |  |           https://github.com/Homebrew/homebrew/issues | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-22 17:48:47 -08:00
										 |  |  |         Note that we only track stable, released versions of Xcode. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |         Thanks! | 
					
						
							|  |  |  |       EOS | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-01 20:47:26 -05:00
										 |  |  |     def app_with_bundle_id(*ids) | 
					
						
							|  |  |  |       path = mdfind(*ids).first | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |       Pathname.new(path) unless path.nil? || path.empty? | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-01 20:47:26 -05:00
										 |  |  |     def mdfind(*ids) | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |       return [] unless OS.mac? | 
					
						
							| 
									
										
										
										
											2014-04-01 20:47:26 -05:00
										 |  |  |       (@mdfind ||= {}).fetch(ids) do | 
					
						
							| 
									
										
										
										
											2014-07-11 15:51:19 -05:00
										 |  |  |         @mdfind[ids] = Utils.popen_read("/usr/bin/mdfind", mdfind_query(*ids)).split("\n") | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-01 20:47:26 -05:00
										 |  |  |     def pkgutil_info(id) | 
					
						
							| 
									
										
										
										
											2014-04-01 20:49:11 -05:00
										 |  |  |       (@pkginfo ||= {}).fetch(id) do |key| | 
					
						
							| 
									
										
										
										
											2014-07-11 15:51:19 -05:00
										 |  |  |         @pkginfo[key] = Utils.popen_read("/usr/sbin/pkgutil", "--pkg-info", key).strip | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2014-04-01 20:47:26 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def mdfind_query(*ids) | 
					
						
							|  |  |  |       ids.map! { |id| "kMDItemCFBundleIdentifier == #{id}" }.join(" || ") | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2013-10-18 12:56:51 -05:00
										 |  |  |   end | 
					
						
							|  |  |  | end |