From 2c84be96d8325abf6e3062197c99f5dc12f79109 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Tue, 6 Mar 2012 18:08:16 +0000 Subject: [PATCH] Concise --config output for build errors Rationale, lets only pay attention to the output when it matters. Speeding up diagnosis. --- Library/Homebrew/cmd/--config.rb | 31 +++++++++++++++++++++++++++++-- Library/Homebrew/exceptions.rb | 14 +++++++------- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/cmd/--config.rb b/Library/Homebrew/cmd/--config.rb index 1d74bebf59..da146ac892 100644 --- a/Library/Homebrew/cmd/--config.rb +++ b/Library/Homebrew/cmd/--config.rb @@ -76,14 +76,41 @@ module Homebrew extend self Pathname.new(a_path).realpath.to_s end + def hardware + "CPU: #{Hardware.cores_as_words}-core #{Hardware.bits}-bit #{Hardware.intel_family}" + end + + def kernel + `uname -m`.chomp + end + + # we try to keep output minimal + def dump_build_config + puts "HOMEBREW_PREFIX: #{HOMEBREW_PREFIX}" if HOMEBREW_PREFIX.to_s != "/usr/local" + puts "HOMEBREW_CELLAR: #{HOMEBREW_CELLAR}" if HOMEBREW_CELLAR.to_s != "#{HOMEBREW_PREFIX}/Cellar" + puts hardware + puts "MacOS: #{MACOS_FULL_VERSION}-#{kernel}" + puts "Xcode: #{xcode_version}" + puts "/usr/bin/ruby: #{RUBY_VERSION}-#{RUBY_PATCHLEVEL}" if RUBY_VERSION.to_f != 1.8 + + ruby = Pathname.new("/usr/bin/ruby") + puts "/usr/bin/ruby => #{ruby.realpath}" unless ruby.realpath.to_s =~ %r{^/System} + + ponk = macports_or_fink_installed? + puts "MacPorts/Fink: #{ponk?}" if ponk + + x11 = describe_x11 + puts "X11: #{x11}" unless x11 == "/usr/X11" + end + def config_s; <<-EOS.undent HOMEBREW_VERSION: #{HOMEBREW_VERSION} HEAD: #{sha} HOMEBREW_PREFIX: #{HOMEBREW_PREFIX} HOMEBREW_CELLAR: #{HOMEBREW_CELLAR} - Hardware: #{Hardware.cores_as_words}-core #{Hardware.bits}-bit #{Hardware.intel_family} + #{hardware} OS X: #{MACOS_FULL_VERSION} - Kernel Architecture: #{`uname -m`.chomp} + Kernel Architecture: #{kernel} Xcode: #{xcode_version} GCC-4.0: #{gcc_40 ? "build #{gcc_40}" : "N/A"} GCC-4.2: #{gcc_42 ? "build #{gcc_42}" : "N/A"} diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index 9929d37bce..0d55336d1e 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -98,17 +98,17 @@ class BuildError < Homebrew::InstallationError issues_url = ISSUES_URL end - ohai "Exit Status: #{e.exit_status}" - puts "https://github.com/#{repo}/blob/master/#{repo_path}/#{formula_name}.rb#L#{error_line}" - ohai "Environment" - puts Homebrew.config_s - ohai "Build Flags" + if ARGV.verbose? + ohai "Exit Status: #{e.exit_status}" + puts "https://github.com/#{repo}/blob/master/#{repo_path}/#{formula_name}.rb#L#{error_line}" + end + ohai "Build Environment" + Homebrew.dump_build_config puts %["--use-clang" was specified] if ARGV.include? '--use-clang' puts %["--use-llvm" was specified] if ARGV.include? '--use-llvm' puts %["--use-gcc" was specified] if ARGV.include? '--use-gcc' Homebrew.dump_build_env e.env - puts - onoe e + onoe "#{e.to_s.strip} (#{formula_name}.rb:#{error_line})" issues = GitHub.issues_for_formula formula_name if issues.empty? puts "If `brew doctor' does not help diagnose the issue, please report the bug:"