| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											2016-09-23 18:13:48 +02:00
										 |  |  |     alias original_locate locate | 
					
						
							| 
									
										
										
										
											2016-04-25 18:01:03 +01:00
										 |  |  |     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-07-16 21:01:22 +01:00
										 |  |  |     def installation_instructions | 
					
						
							|  |  |  |       if MacOS.version >= "10.9" | 
					
						
							| 
									
										
										
										
											2016-09-11 17:53:00 +01:00
										 |  |  |         <<-EOS.undent
 | 
					
						
							|  |  |  |           Install the Command Line Tools: | 
					
						
							|  |  |  |             xcode-select --install | 
					
						
							|  |  |  |         EOS | 
					
						
							| 
									
										
										
										
											2016-07-16 21:01:22 +01:00
										 |  |  |       elsif MacOS.version == "10.8" || MacOS.version == "10.7" | 
					
						
							|  |  |  |         <<-EOS.undent
 | 
					
						
							|  |  |  |           Install the Command Line Tools from | 
					
						
							|  |  |  |             https://developer.apple.com/downloads/ | 
					
						
							|  |  |  |           or via Xcode's preferences. | 
					
						
							|  |  |  |         EOS | 
					
						
							|  |  |  |       else | 
					
						
							|  |  |  |         <<-EOS.undent
 | 
					
						
							|  |  |  |           Install Xcode from | 
					
						
							|  |  |  |             https://developer.apple.com/xcode/downloads/ | 
					
						
							|  |  |  |         EOS | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def custom_installation_instructions | 
					
						
							|  |  |  |       if MacOS.version > :tiger | 
					
						
							|  |  |  |         <<-EOS.undent
 | 
					
						
							|  |  |  |           Install GNU's GCC | 
					
						
							|  |  |  |             brew install gcc | 
					
						
							|  |  |  |         EOS | 
					
						
							|  |  |  |       else | 
					
						
							|  |  |  |         # Tiger doesn't ship with apple-gcc42, and this is required to build | 
					
						
							|  |  |  |         # some software that doesn't build properly with FSF GCC. | 
					
						
							|  |  |  |         <<-EOS.undent
 | 
					
						
							|  |  |  |           Install Apple's GCC | 
					
						
							|  |  |  |             brew install apple-gcc42 | 
					
						
							|  |  |  |           or GNU's GCC | 
					
						
							|  |  |  |             brew install gcc | 
					
						
							|  |  |  |         EOS | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     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 | 
					
						
							| 
									
										
										
										
											2016-07-13 16:19:51 +08:00
										 |  |  |       when /^gcc-4\.0/ then gcc_42_build_version ? :gcc : :gcc_4_0 | 
					
						
							| 
									
										
										
										
											2016-04-25 18:01:03 +01:00
										 |  |  |       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 | 
					
						
							| 
									
										
										
										
											2016-10-15 13:10:35 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def tar_supports_xz? | 
					
						
							|  |  |  |       false | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2016-04-25 18:01:03 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | end |