Commit 77d05598 authored by Eloy Duran's avatar Eloy Duran

Don't block while reading stdout and stderr of appledoc.

This fixes the generation of ASIHTTPRequest docs, which always made
building of the MacRubySample block.
parent 69498bc3
...@@ -54,7 +54,7 @@ module Pod ...@@ -54,7 +54,7 @@ module Pod
end end
def self.run(*argv) def self.run(*argv)
Setup.new(ARGV.new()).run_if_needed Setup.new(ARGV.new).run_if_needed
parse(*argv).run parse(*argv).run
rescue Interrupt rescue Interrupt
......
...@@ -94,14 +94,43 @@ module Pod ...@@ -94,14 +94,43 @@ module Pod
arguments += ['--print-settings'] if config.verbose? arguments += ['--print-settings'] if config.verbose?
arguments += files.map(&:to_s) arguments += files.map(&:to_s)
output = error = nil output, error = '', ''
process = Open4.popen4('appledoc', *arguments) do |_, __, out, err| process = Open4.popen4('appledoc', *arguments) do |pid, stdin, stdout, stderr|
output, error = out.read, err.read output_buffer, error_buffer = '', ''
begin
loop do
# Check whether stdout, stderr or both are ready to be read from
# without blocking.
IO.select([stdout, stderr]).flatten.compact.each do |io|
case io.fileno
when stdout.fileno
output_buffer << io.readpartial(1024)
when stderr.fileno
error_buffer << io.readpartial(1024)
end
end
# Remove any lines and print them if in verbose mode.
output_buffer.sub!(/(.*)\n/m) do
$stdout.puts $1 if config.verbose?
output << $&
''
end
error_buffer.sub!(/(.*)\n/m) do
$stderr.puts $1 if config.verbose?
error << $&
''
end
break if stdout.closed? && stderr.closed?
end
rescue EOFError
end
end end
# appledoc exits with 1 if a warning was logged # appledoc exits with 1 if a warning was logged
if process.exitstatus >= 2 if process.exitstatus >= 2
puts output, error puts output, error unless config.verbose?
raise "Appledoc encountered an error." raise "Appledoc encountered an error."
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment