Concise --config output for build errors

Rationale, lets only pay attention to the output when it matters. Speeding up diagnosis.
This commit is contained in:
Max Howell 2012-03-06 18:08:16 +00:00
parent 6c0950999f
commit 2c84be96d8
2 changed files with 36 additions and 9 deletions

View File

@ -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"}

View File

@ -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:"