diff options
| author | Jack Nagel | 2014-09-05 15:13:52 -0500 |
|---|---|---|
| committer | Jack Nagel | 2014-09-05 15:13:52 -0500 |
| commit | 659896fda22ceeac7ad1480f90109bc31b16749a (patch) | |
| tree | 9fe4e16a95e782bf90d7e881169d6102a654c698 /Library | |
| parent | bbf79f5d85abcdec428096a1631a3ee4ff7ed2c2 (diff) | |
| download | brew-659896fda22ceeac7ad1480f90109bc31b16749a.tar.bz2 | |
Extract body of child process to a method
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/formula.rb | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 2277d3d7e..6965a452e 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -510,29 +510,7 @@ class Formula logfn = "#{logd}/%02d.%s" % [@exec_count, File.basename(cmd).split(' ').first] mkdir_p(logd) - pid = fork do - ENV['HOMEBREW_CC_LOG_PATH'] = logfn - - # TODO system "xcodebuild" is deprecated, this should be removed soon. - if cmd.to_s.start_with? "xcodebuild" - ENV.remove_cc_etc - end - - # Turn on argument filtering in the superenv compiler wrapper. - # We should probably have a better mechanism for this than adding - # special cases to this method. - if cmd == "python" && %w[setup.py build.py].include?(args.first) - ENV.refurbish_args - end - - rd.close - $stdout.reopen wr - $stderr.reopen wr - args.collect!{|arg| arg.to_s} - exec(cmd, *args) rescue nil - puts "Failed to execute: #{cmd}" - exit! 1 # never gets here unless exec threw or failed - end + pid = fork { exec_cmd(cmd, args, rd, wr, logfn) } wr.close File.open(logfn, 'w') do |f| @@ -569,6 +547,30 @@ class Formula private + def exec_cmd(cmd, args, rd, wr, logfn) + ENV['HOMEBREW_CC_LOG_PATH'] = logfn + + # TODO system "xcodebuild" is deprecated, this should be removed soon. + if cmd.to_s.start_with? "xcodebuild" + ENV.remove_cc_etc + end + + # Turn on argument filtering in the superenv compiler wrapper. + # We should probably have a better mechanism for this than adding + # special cases to this method. + if cmd == "python" && %w[setup.py build.py].include?(args.first) + ENV.refurbish_args + end + + rd.close + $stdout.reopen wr + $stderr.reopen wr + args.collect!{|arg| arg.to_s} + exec(cmd, *args) rescue nil + puts "Failed to execute: #{cmd}" + exit! 1 # never gets here unless exec threw or failed + end + def stage active_spec.stage do @buildpath = Pathname.pwd |
