| 
									
										
										
										
											2016-07-06 11:07:24 +01:00
										 |  |  | require "os/mac/xcode" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-25 18:01:03 +01:00
										 |  |  | # @private | 
					
						
							|  |  |  | class DevelopmentTools | 
					
						
							|  |  |  |   class << self | 
					
						
							|  |  |  |     alias_method :original_locate, :locate | 
					
						
							|  |  |  |     def locate(tool) | 
					
						
							|  |  |  |       (@locate ||= {}).fetch(tool) do |key| | 
					
						
							|  |  |  |         @locate[key] = if (located_tool = original_locate(tool)) | 
					
						
							|  |  |  |           located_tool | 
					
						
							|  |  |  |         elsif MacOS.version > :tiger | 
					
						
							|  |  |  |           path = Utils.popen_read("/usr/bin/xcrun", "-no-cache", "-find", tool).chomp | 
					
						
							|  |  |  |           Pathname.new(path) if File.executable?(path) | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-06 11:07:24 +01: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. | 
					
						
							|  |  |  |     def installed? | 
					
						
							|  |  |  |       MacOS::Xcode.installed? || MacOS::CLT.installed? | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-25 18:01:03 +01:00
										 |  |  |     def default_compiler | 
					
						
							|  |  |  |       case default_cc | 
					
						
							|  |  |  |       # if GCC 4.2 is installed, e.g. via Tigerbrew, prefer it | 
					
						
							|  |  |  |       # over the system's GCC 4.0 | 
					
						
							|  |  |  |       when /^gcc-4.0/ then gcc_42_build_version ? :gcc : :gcc_4_0 | 
					
						
							|  |  |  |       when /^gcc/ then :gcc | 
					
						
							|  |  |  |       when "clang" then :clang | 
					
						
							|  |  |  |       else | 
					
						
							|  |  |  |         # guess :( | 
					
						
							| 
									
										
										
										
											2016-05-26 19:02:25 +02:00
										 |  |  |         if MacOS::Xcode.version >= "4.3" | 
					
						
							| 
									
										
										
										
											2016-04-25 18:01:03 +01:00
										 |  |  |           :clang | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |           :gcc | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |