| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  | require 'hardware' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-18 22:41:47 -05:00
										 |  |  | module Homebrew | 
					
						
							| 
									
										
										
										
											2014-04-26 23:31:39 -07:00
										 |  |  |   def config | 
					
						
							| 
									
										
										
										
											2014-07-19 22:33:59 -05:00
										 |  |  |     dump_verbose_config(STDOUT) | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def llvm | 
					
						
							|  |  |  |     @llvm ||= MacOS.llvm_build_version | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def gcc_42 | 
					
						
							|  |  |  |     @gcc_42 ||= MacOS.gcc_42_build_version | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def gcc_40 | 
					
						
							|  |  |  |     @gcc_40 ||= MacOS.gcc_40_build_version | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-03 21:10:09 -05:00
										 |  |  |   def clang | 
					
						
							|  |  |  |     @clang ||= MacOS.clang_version | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def clang_build | 
					
						
							|  |  |  |     @clang_build ||= MacOS.clang_build_version | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-14 13:24:28 -05:00
										 |  |  |   def xcode | 
					
						
							|  |  |  |     if instance_variable_defined?(:@xcode) | 
					
						
							|  |  |  |       @xcode | 
					
						
							|  |  |  |     elsif MacOS::Xcode.installed? | 
					
						
							|  |  |  |       @xcode = MacOS::Xcode.version | 
					
						
							|  |  |  |       @xcode += " => #{MacOS::Xcode.prefix}" unless MacOS::Xcode.default_prefix? | 
					
						
							|  |  |  |       @xcode | 
					
						
							| 
									
										
											  
											
												Core change: XCode only install, with CLT or both
Allow XCode without the Command Line Tools to
work with homebrew, so it's not necessary
to register an Apple Dev ID and/or go to the
XCode prefs and download the CLT. Yay!
Further, this commit allows to use the CLT
solely (without the need for XCode).
Saves quite some megs.
(Some furmulae require xcodebuild)
Of course XCode together with the CLT is still
fine and has been tested on 10.7 and 10.6
with Xcode 4 and Xcode 3.
Only on Lion or above, tell the user about the options,
which are
- Xcode without CLT
- CLT without Xcode
- both (ok, it's not directly stated, but implicit)
So if no Xcode is found and we are on Lion or above,
we don't fail but check for the CLTs now.
For older Macs, the old message that Xcode is needed
and the installer should be run is still displayed.
If the CLT are not found but Xcode is, then we
print out about the experimental status of this setup.
Closes Homebrew/homebrew#10510.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
											
										 
											2012-02-26 21:04:15 +01:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-14 13:24:28 -05:00
										 |  |  |   def clt | 
					
						
							|  |  |  |     if instance_variable_defined?(:@clt) | 
					
						
							|  |  |  |       @clt | 
					
						
							| 
									
										
										
										
											2013-10-22 20:48:22 -05:00
										 |  |  |     elsif MacOS::CLT.installed? && MacOS::Xcode.version >= "4.3" | 
					
						
							| 
									
										
										
										
											2012-09-14 13:24:28 -05:00
										 |  |  |       @clt = MacOS::CLT.version | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-08 12:22:25 -05:00
										 |  |  |   def head | 
					
						
							| 
									
										
										
										
											2014-06-30 19:15:03 -05:00
										 |  |  |     Homebrew.git_head || "(none)" | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-04 16:09:48 -07:00
										 |  |  |   def last_commit | 
					
						
							|  |  |  |     Homebrew.git_last_commit || "never" | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-16 15:56:36 +01:00
										 |  |  |   def origin | 
					
						
							|  |  |  |     origin = HOMEBREW_REPOSITORY.cd do | 
					
						
							| 
									
										
										
										
											2013-10-04 13:08:13 -05:00
										 |  |  |       `git config --get remote.origin.url 2>/dev/null`.chomp | 
					
						
							| 
									
										
										
										
											2013-01-16 15:56:36 +01:00
										 |  |  |     end | 
					
						
							|  |  |  |     if origin.empty? then "(none)" else origin end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-08 05:44:11 +02:00
										 |  |  |   def describe_path path | 
					
						
							|  |  |  |     return "N/A" if path.nil? | 
					
						
							|  |  |  |     realpath = path.realpath | 
					
						
							|  |  |  |     if realpath == path then path else "#{path} => #{realpath}" end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-27 23:43:19 -06:00
										 |  |  |   def describe_x11 | 
					
						
							| 
									
										
										
										
											2012-07-25 15:04:46 -05:00
										 |  |  |     return "N/A" unless MacOS::XQuartz.installed? | 
					
						
							| 
									
										
										
										
											2013-08-26 21:45:47 -05:00
										 |  |  |     return "#{MacOS::XQuartz.version} => #{describe_path(MacOS::XQuartz.prefix)}" | 
					
						
							| 
									
										
										
										
											2012-02-27 23:43:19 -06:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-02 19:10:15 -08:00
										 |  |  |   def describe_perl | 
					
						
							| 
									
										
										
										
											2012-06-08 05:44:11 +02:00
										 |  |  |     describe_path(which 'perl') | 
					
						
							| 
									
										
										
										
											2012-02-02 19:10:15 -08:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def describe_python | 
					
						
							| 
									
										
										
										
											2012-06-08 05:44:11 +02:00
										 |  |  |     describe_path(which 'python') | 
					
						
							| 
									
										
										
										
											2012-02-02 19:10:15 -08:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def describe_ruby | 
					
						
							| 
									
										
										
										
											2012-06-08 05:44:11 +02:00
										 |  |  |     describe_path(which 'ruby') | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-06 18:08:16 +00:00
										 |  |  |   def hardware | 
					
						
							| 
									
										
										
										
											2013-03-17 13:30:12 -05:00
										 |  |  |     "CPU: #{Hardware.cores_as_words}-core #{Hardware::CPU.bits}-bit #{Hardware::CPU.family}" | 
					
						
							| 
									
										
										
										
											2012-03-06 18:08:16 +00:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def kernel | 
					
						
							|  |  |  |     `uname -m`.chomp | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-17 17:05:53 -06:00
										 |  |  |   def macports_or_fink | 
					
						
							|  |  |  |     @ponk ||= MacOS.macports_or_fink | 
					
						
							|  |  |  |     @ponk.join(", ") unless @ponk.empty? | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-06 18:08:16 +00:00
										 |  |  |   # we try to keep output minimal | 
					
						
							| 
									
										
										
										
											2014-07-19 23:28:56 -05:00
										 |  |  |   def dump_build_config(f=STDOUT) | 
					
						
							| 
									
										
										
										
											2014-07-19 22:33:00 -05:00
										 |  |  |     f.puts "HOMEBREW_VERSION: #{HOMEBREW_VERSION}" | 
					
						
							|  |  |  |     f.puts "HEAD: #{head}" | 
					
						
							|  |  |  |     f.puts "HOMEBREW_PREFIX: #{HOMEBREW_PREFIX}" if HOMEBREW_PREFIX.to_s != "/usr/local" | 
					
						
							|  |  |  |     f.puts "HOMEBREW_CELLAR: #{HOMEBREW_CELLAR}" if HOMEBREW_CELLAR.to_s != "#{HOMEBREW_PREFIX}/Cellar" | 
					
						
							|  |  |  |     f.puts hardware | 
					
						
							|  |  |  |     f.puts "OS X: #{MACOS_FULL_VERSION}-#{kernel}" | 
					
						
							|  |  |  |     f.puts "Xcode: #{xcode}" if xcode | 
					
						
							|  |  |  |     f.puts "CLT: #{clt}" if clt | 
					
						
							| 
									
										
										
										
											2014-06-07 15:56:54 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ruby_version = MacOS.version >= "10.9" ? "2.0" : "1.8" | 
					
						
							|  |  |  |     if RUBY_VERSION[/\d\.\d/] != ruby_version | 
					
						
							| 
									
										
										
										
											2014-07-19 22:33:00 -05:00
										 |  |  |       f.puts "#{RUBY_PATH}:\n  #{RUBY_VERSION}-#{RUBY_PATCHLEVEL}" | 
					
						
							| 
									
										
										
										
											2014-06-07 15:56:54 -05:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2012-03-06 18:08:16 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-08 12:21:47 -05:00
										 |  |  |     unless MacOS.compilers_standard? | 
					
						
							| 
									
										
										
										
											2014-07-19 22:33:00 -05:00
										 |  |  |       f.puts "GCC-4.0: build #{gcc_40}" if gcc_40 | 
					
						
							|  |  |  |       f.puts "GCC-4.2: build #{gcc_42}" if gcc_42 | 
					
						
							|  |  |  |       f.puts "LLVM-GCC: build #{llvm}"  if llvm | 
					
						
							|  |  |  |       f.puts "Clang: #{clang ? "#{clang} build #{clang_build}" : "N/A"}" | 
					
						
							| 
									
										
										
										
											2012-07-08 12:21:47 -05:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-19 22:33:00 -05:00
										 |  |  |     f.puts "MacPorts/Fink: #{macports_or_fink}" if macports_or_fink | 
					
						
							|  |  |  |     f.puts "X11: #{describe_x11}" | 
					
						
							| 
									
										
										
										
											2012-03-06 18:08:16 +00:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-19 22:33:59 -05:00
										 |  |  |   def dump_verbose_config(f) | 
					
						
							|  |  |  |     f.puts "HOMEBREW_VERSION: #{HOMEBREW_VERSION}" | 
					
						
							|  |  |  |     f.puts "ORIGIN: #{origin}" | 
					
						
							|  |  |  |     f.puts "HEAD: #{head}" | 
					
						
							| 
									
										
										
										
											2014-10-04 16:09:48 -07:00
										 |  |  |     f.puts "Last commit: #{last_commit}" | 
					
						
							| 
									
										
										
										
											2014-07-19 22:33:59 -05:00
										 |  |  |     f.puts "HOMEBREW_PREFIX: #{HOMEBREW_PREFIX}" | 
					
						
							|  |  |  |     f.puts "HOMEBREW_CELLAR: #{HOMEBREW_CELLAR}" | 
					
						
							|  |  |  |     f.puts hardware | 
					
						
							|  |  |  |     f.puts "OS X: #{MACOS_FULL_VERSION}-#{kernel}" | 
					
						
							|  |  |  |     f.puts "Xcode: #{xcode}" if xcode | 
					
						
							|  |  |  |     f.puts "CLT: #{clt}" if clt | 
					
						
							|  |  |  |     f.puts "GCC-4.0: build #{gcc_40}" if gcc_40 | 
					
						
							|  |  |  |     f.puts "GCC-4.2: build #{gcc_42}" if gcc_42 | 
					
						
							|  |  |  |     f.puts "LLVM-GCC: build #{llvm}"  if llvm | 
					
						
							|  |  |  |     f.puts "Clang: #{clang ? "#{clang} build #{clang_build}" : "N/A"}" | 
					
						
							|  |  |  |     f.puts "MacPorts/Fink: #{macports_or_fink}" if macports_or_fink | 
					
						
							|  |  |  |     f.puts "X11: #{describe_x11}" | 
					
						
							|  |  |  |     f.puts "System Ruby: #{RUBY_VERSION}-#{RUBY_PATCHLEVEL}" | 
					
						
							|  |  |  |     f.puts "Perl: #{describe_perl}" | 
					
						
							|  |  |  |     f.puts "Python: #{describe_python}" | 
					
						
							|  |  |  |     f.puts "Ruby: #{describe_ruby}" | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | end |