Replace error-prone superenv debug ouput with a separate log file
This commit is contained in:
parent
f141e4de96
commit
aec457bb7c
@ -7,6 +7,27 @@
|
|||||||
|
|
||||||
require "#{File.dirname __FILE__}/../libsuperenv"
|
require "#{File.dirname __FILE__}/../libsuperenv"
|
||||||
require 'set'
|
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
|
def cccfg? flags
|
||||||
flags.split('').all?{|c| ENV['HOMEBREW_CCCFG'].include? c } if ENV['HOMEBREW_CCCFG']
|
flags.split('').all?{|c| ENV['HOMEBREW_CCCFG'].include? c } if ENV['HOMEBREW_CCCFG']
|
||||||
@ -22,20 +43,6 @@ def syspath
|
|||||||
end
|
end
|
||||||
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
|
class Cmd
|
||||||
def initialize path, args
|
def initialize path, args
|
||||||
@arg0 = path.basename.freeze
|
@arg0 = path.basename.freeze
|
||||||
@ -251,9 +258,9 @@ class Cmd
|
|||||||
adds = args - @args
|
adds = args - @args
|
||||||
dups = dels & args
|
dups = dels & args
|
||||||
|
|
||||||
STDERR.puts "brew: superenv removed: #{dels*' '}" unless dels.empty?
|
LOGGER.puts "superenv removed: #{dels*' '}" unless dels.empty?
|
||||||
STDERR.puts "brew: superenv deduped: #{dups}" unless dups.empty?
|
LOGGER.puts "superenv deduped: #{dups}" unless dups.empty?
|
||||||
STDERR.puts "brew: superenv added: #{adds*' '}" unless adds.empty?
|
LOGGER.puts "superenv added: #{adds*' '}" unless adds.empty?
|
||||||
end
|
end
|
||||||
def make_fuss?
|
def make_fuss?
|
||||||
verbose? and cccfg? 'O' and not configure?
|
verbose? and cccfg? 'O' and not configure?
|
||||||
@ -268,8 +275,6 @@ class Cmd
|
|||||||
end
|
end
|
||||||
|
|
||||||
if __FILE__ == $PROGRAM_NAME
|
if __FILE__ == $PROGRAM_NAME
|
||||||
STDOUT.sync = STDERR.sync = true
|
|
||||||
|
|
||||||
##################################################################### sanity
|
##################################################################### sanity
|
||||||
abort "The build-tool has reset ENV. --env=std required." unless ENV['HOMEBREW_BREW_FILE']
|
abort "The build-tool has reset ENV. --env=std required." unless ENV['HOMEBREW_BREW_FILE']
|
||||||
|
|
||||||
@ -279,7 +284,14 @@ if __FILE__ == $PROGRAM_NAME
|
|||||||
end
|
end
|
||||||
|
|
||||||
####################################################################### main
|
####################################################################### main
|
||||||
extend(ExecLogExtension) if ENV['HOMEBREW_LOG']
|
|
||||||
|
LOGGER.puts "#{File.basename($0)} called with: #{ARGV.join(" ")}"
|
||||||
|
|
||||||
cmd = Cmd.new($0, ARGV)
|
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
|
end
|
||||||
|
@ -585,6 +585,7 @@ class Formula
|
|||||||
|
|
||||||
rd, wr = IO.pipe
|
rd, wr = IO.pipe
|
||||||
fork do
|
fork do
|
||||||
|
ENV['HOMEBREW_CC_LOG_PATH'] = logfn
|
||||||
rd.close
|
rd.close
|
||||||
$stdout.reopen wr
|
$stdout.reopen wr
|
||||||
$stderr.reopen wr
|
$stderr.reopen wr
|
||||||
|
Loading…
x
Reference in New Issue
Block a user