summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaisuke Aritomo <[email protected]>2023-12-09 13:13:53 +0900
committergit <[email protected]>2023-12-11 11:07:36 +0000
commit1ab91b12fa5f7e98bba2e59e2f40b57004d9acf1 (patch)
tree45b77469c33dab4e5b4f27d873e05252051261cc /lib
parent655aacc43a2ae263c9b71429232853d16df028d5 (diff)
[rubygems/rubygems] Stream output from ext builds when --verbose
Uses Open3.popen2e in place of Open3.capture2e in Gem::Ext::Builder. This change aims to stream stdout/stderr of ext builds when in verbose mode, instead of printing everything at once when the build completes. Nice for debugging gem builds that consumes longer times. https://github.com/rubygems/rubygems/commit/dcdcb5adda
Diffstat (limited to 'lib')
-rw-r--r--lib/rubygems/ext/builder.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/rubygems/ext/builder.rb b/lib/rubygems/ext/builder.rb
index ccd0853fff..be1ba3031c 100644
--- a/lib/rubygems/ext/builder.rb
+++ b/lib/rubygems/ext/builder.rb
@@ -88,13 +88,20 @@ class Gem::Ext::Builder
# Set $SOURCE_DATE_EPOCH for the subprocess.
build_env = { "SOURCE_DATE_EPOCH" => Gem.source_date_epoch_string }.merge(env)
output, status = begin
- Open3.capture2e(build_env, *command, chdir: dir)
+ Open3.popen2e(build_env, *command, chdir: dir) do |_stdin, stdouterr, wait_thread|
+ output = String.new
+ while line = stdouterr.gets
+ output << line
+ if verbose
+ print line
+ end
+ end
+ [output, wait_thread.value]
+ end
rescue StandardError => error
raise Gem::InstallError, "#{command_name || class_name} failed#{error.message}"
end
- if verbose
- puts output
- else
+ unless verbose
results << output
end
ensure