diff options
| author | Jack Nagel | 2013-11-17 11:53:55 -0600 |
|---|---|---|
| committer | Jack Nagel | 2013-11-17 19:04:21 -0600 |
| commit | aec457bb7c277dae1a1228a6fe20bae657557e07 (patch) | |
| tree | e5500f2350f065d54d7f8779dcf933afb27821b8 /Library | |
| parent | f141e4de96e4a1cd95ea939af0066288a489996f (diff) | |
| download | brew-aec457bb7c277dae1a1228a6fe20bae657557e07.tar.bz2 | |
Replace error-prone superenv debug ouput with a separate log file
Diffstat (limited to 'Library')
| -rwxr-xr-x | Library/ENV/4.3/cc | 54 | ||||
| -rw-r--r-- | Library/Homebrew/formula.rb | 1 |
2 files changed, 34 insertions, 21 deletions
diff --git a/Library/ENV/4.3/cc b/Library/ENV/4.3/cc index d2c7be0ce..74eed697d 100755 --- a/Library/ENV/4.3/cc +++ b/Library/ENV/4.3/cc @@ -7,6 +7,27 @@ require "#{File.dirname __FILE__}/../libsuperenv" require 'set' +require 'stringio' + +class Logger + def initialize + @io = StringIO.new + end + + def puts(*args) + @io.puts(*args) + end + + def log! + return unless ENV.key? 'HOMEBREW_CC_LOG_PATH' + path = "#{ENV['HOMEBREW_CC_LOG_PATH']}.cc" + + puts + File.open(path, File::WRONLY | File::APPEND | File::CREAT) { |f| f.write(@io.string) } + end +end + +LOGGER = Logger.new def cccfg? flags flags.split('').all?{|c| ENV['HOMEBREW_CCCFG'].include? c } if ENV['HOMEBREW_CCCFG'] @@ -22,20 +43,6 @@ def syspath end end -module ExecLogExtension - def exec *args - path = File.expand_path('~/Library/Logs/Homebrew/cc.log') - open(path, 'a') do |f| - f.print '[', $0 - f.print " -%s" % ENV['HOMEBREW_CCCFG'] if ENV['HOMEBREW_CCCFG'] - f.print '] ' - f.puts args.join(' ') - f.puts - end - Kernel.exec *args - end -end - class Cmd def initialize path, args @arg0 = path.basename.freeze @@ -251,9 +258,9 @@ class Cmd adds = args - @args dups = dels & args - STDERR.puts "brew: superenv removed: #{dels*' '}" unless dels.empty? - STDERR.puts "brew: superenv deduped: #{dups}" unless dups.empty? - STDERR.puts "brew: superenv added: #{adds*' '}" unless adds.empty? + LOGGER.puts "superenv removed: #{dels*' '}" unless dels.empty? + LOGGER.puts "superenv deduped: #{dups}" unless dups.empty? + LOGGER.puts "superenv added: #{adds*' '}" unless adds.empty? end def make_fuss? verbose? and cccfg? 'O' and not configure? @@ -268,8 +275,6 @@ class Cmd end if __FILE__ == $PROGRAM_NAME - STDOUT.sync = STDERR.sync = true - ##################################################################### sanity abort "The build-tool has reset ENV. --env=std required." unless ENV['HOMEBREW_BREW_FILE'] @@ -279,7 +284,14 @@ if __FILE__ == $PROGRAM_NAME end ####################################################################### main - extend(ExecLogExtension) if ENV['HOMEBREW_LOG'] + + LOGGER.puts "#{File.basename($0)} called with: #{ARGV.join(" ")}" + cmd = Cmd.new($0, ARGV) - exec "xcrun", cmd.tool, *cmd.args + tool, args = cmd.tool, cmd.args + + LOGGER.puts "superenv executed: #{tool} #{args.join(" ")}" + LOGGER.log! + + exec "xcrun", tool, *args end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index b8cf10e00..dd3d17f08 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -585,6 +585,7 @@ class Formula rd, wr = IO.pipe fork do + ENV['HOMEBREW_CC_LOG_PATH'] = logfn rd.close $stdout.reopen wr $stderr.reopen wr |
