Skip to content

Commit dfa96af

Browse files
build: Print stdout only when --verbose is specified
1 parent 07f1fdc commit dfa96af

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ jobs:
121121
run: rake ${{ matrix.entry.prerelease }}[${{ inputs.prerel_name }}]
122122
if: ${{ inputs.prerel_name != '' && matrix.entry.prerelease != '' }}
123123
- name: rake ${{ matrix.entry.task }}
124-
run: docker run -v "$GITHUB_WORKSPACE:/home/me/build" -w /home/me/build -e "RUBYWASM_UID=$(id -u)" -e "RUBYWASM_GID=$(id -g)" -e "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" ${{ steps.builder-image.outputs.imageid }} rake ${{ matrix.entry.task }}
124+
run: docker run -v "$GITHUB_WORKSPACE:/home/me/build" -w /home/me/build -e "RUBYWASM_UID=$(id -u)" -e "RUBYWASM_GID=$(id -g)" -e "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" ${{ steps.builder-image.outputs.imageid }} rake --verbose ${{ matrix.entry.task }}
125125
- name: rake ${{ matrix.entry.test }}
126126
run: rake ${{ matrix.entry.test }}
127127
if: ${{ matrix.entry.test != '' }}

lib/ruby_wasm/build.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,18 @@
55
module RubyWasm
66
# Build executor to run the actual build commands.
77
class BuildExecutor
8+
def initialize(verbose: false)
9+
@verbose = verbose
10+
end
11+
812
def system(*args, **kwargs)
9-
Kernel.system(*args, **kwargs)
13+
puts args.join(" ")
14+
if @verbose
15+
out = kwargs[:out] || $stdout
16+
else
17+
out = IO.pipe[1]
18+
end
19+
Kernel.system(*args, **kwargs, out: out)
1020
end
1121

1222
def rm_rf(list)

lib/ruby_wasm/rake_task.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ def initialize(
7171
@crossruby.with_wasi_vfs @wasi_vfs
7272
@crossruby.with_openssl @openssl
7373

74-
executor = RubyWasm::BuildExecutor.new
74+
# Rake.verbose can be Object.new by default, so compare with true explicitly.
75+
executor = RubyWasm::BuildExecutor.new(verbose: Rake.verbose == true)
7576

7677
desc "Cross-build Ruby for #{@target}"
7778
task name do

sig/ruby_wasm/build.rbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ module RubyWasm
222222
end
223223

224224
class BuildExecutor
225+
@verbose: bool
226+
227+
def initialize: (?verbose: bool) -> void
225228
def system: (*untyped, **untyped) -> bool?
226229
def rm_rf: (FileUtils::pathlist list) -> void
227230
def rm_f: (FileUtils::pathlist list) -> void

0 commit comments

Comments
 (0)