Scupper sourceable output if brew install is piped

`brew install > file` should not give "export CC=/foo" output on Build Failures.

Also moved the "Using clang" output to brew when BuildError is thrown as that is where it is interesting, and not if you just do `brew --env`.
This commit is contained in:
Max Howell 2012-03-02 00:59:22 +00:00
parent d9fdd401da
commit 7cedf67680
2 changed files with 25 additions and 25 deletions

View File

@ -6,38 +6,35 @@ module Homebrew extend self
ENV.extend(HomebrewEnvExtension)
ENV.setup_build_environment
ENV.universal_binary if ARGV.build_universal?
dump_build_env ENV
if $stdout.tty?
dump_build_env ENV
else
build_env_keys(ENV).each do |key|
puts "export #{key}=\"#{ENV[key]}\""
end
end
end
def build_env_keys env
%w[ CC CXX LD CFLAGS CXXFLAGS CPPFLAGS LDFLAGS MACOSX_DEPLOYMENT_TARGET
MAKEFLAGS PKG_CONFIG_PATH HOMEBREW_BUILD_FROM_SOURCE HOMEBREW_DEBUG
HOMEBREW_MAKE_JOBS HOMEBREW_VERBOSE HOMEBREW_USE_CLANG HOMEBREW_USE_GCC
HOMEBREW_USE_LLVM HOMEBREW_SVN ].select{ |key| env[key] }
end
def dump_build_env env
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'
%w[ CC CXX LD ].each do |k|
value = env[k]
if value and $stdout.tty?
results = value
build_env_keys(env).each do |key|
value = env[key]
print "#{key}: #{value}"
case key when 'CC', 'CXX', 'LD'
if value =~ %r{/usr/bin/xcrun (.*)}
path = `/usr/bin/xcrun -find #{$1}`
results += " => #{path}"
elsif File.exists? value and File.symlink? value
results += " => #{Pathname.new(value).realpath}"
print " => #{path}"
elsif File.symlink? value
print " => #{Pathname.new(value).realpath}"
end
env[k] = results
end
end
%w[ CC CXX LD CFLAGS CXXFLAGS CPPFLAGS LDFLAGS MACOSX_DEPLOYMENT_TARGET MAKEFLAGS PKG_CONFIG_PATH
HOMEBREW_BUILD_FROM_SOURCE HOMEBREW_DEBUG HOMEBREW_MAKE_JOBS HOMEBREW_VERBOSE
HOMEBREW_USE_CLANG HOMEBREW_USE_GCC HOMEBREW_USE_LLVM HOMEBREW_SVN ].each do |k|
value = env[k]
out = if $stdout.tty?
"#{k}: #{value}"
else
"export #{k}=\"#{value}\""
end
puts out if value
puts
end
end
end

View File

@ -118,6 +118,9 @@ rescue BuildError => e
ohai "Environment"
puts Homebrew.config_s
ohai "Build Flags"
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