Skip to content

Commit f0dbac1

Browse files
[skip ci] rake format
1 parent 3cc8c05 commit f0dbac1

File tree

2 files changed

+57
-41
lines changed

2 files changed

+57
-41
lines changed

lib/ruby_wasm/build.rb

Lines changed: 52 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -21,39 +21,53 @@ def system(*args, chdir: nil, env: nil)
2121

2222
args = args.to_a.map(&:to_s)
2323
# TODO: Remove __skip__ once we have open3 RBS definitions.
24-
__skip__ = if @verbose || !$stdout.tty?
25-
kwargs[:exception] = true
26-
env ? Kernel.system(env, *args, **kwargs) : Kernel.system(*args, **kwargs)
27-
else
28-
printer = StatusPrinter.new
29-
block = proc do |stdin, stdout, stderr, wait_thr|
30-
mux = Mutex.new
31-
out = String.new
32-
err = String.new
33-
readers = [[stdout, :stdout, out], [stderr, :stderr, err]].map do |io, name, str|
34-
reader = Thread.new {
35-
while (line = io.gets)
36-
mux.synchronize {
37-
printer.send(name, line)
38-
str << line
39-
}
40-
end
41-
}
42-
reader.report_on_exception = false
43-
reader
24+
__skip__ =
25+
if @verbose || !$stdout.tty?
26+
kwargs[:exception] = true
27+
if env
28+
Kernel.system(env, *args, **kwargs)
29+
else
30+
Kernel.system(*args, **kwargs)
31+
end
32+
else
33+
printer = StatusPrinter.new
34+
block =
35+
proc do |stdin, stdout, stderr, wait_thr|
36+
mux = Mutex.new
37+
out = String.new
38+
err = String.new
39+
readers =
40+
[
41+
[stdout, :stdout, out],
42+
[stderr, :stderr, err]
43+
].map do |io, name, str|
44+
reader =
45+
Thread.new do
46+
while (line = io.gets)
47+
mux.synchronize do
48+
printer.send(name, line)
49+
str << line
50+
end
51+
end
52+
end
53+
reader.report_on_exception = false
54+
reader
55+
end
56+
57+
readers.each(&:join)
58+
59+
[out, err, wait_thr.value]
60+
end
61+
begin
62+
if env
63+
Open3.popen3(env, *args, **kwargs, &block)
64+
else
65+
Open3.popen3(*args, **kwargs, &block)
66+
end
67+
ensure
68+
printer.done
4469
end
45-
46-
readers.each(&:join)
47-
48-
[out, err, wait_thr.value]
49-
end
50-
begin
51-
env ? Open3.popen3(env, *args, **kwargs, &block) : Open3.popen3(*args, **kwargs, &block)
52-
ensure
53-
printer.done
5470
end
55-
end
56-
5771
rescue => e
5872
$stdout.flush
5973
$stderr.puts "Try running with `rake --verbose` for more complete output."
@@ -126,12 +140,14 @@ def initialize
126140

127141
def stdout(message)
128142
require "io/console"
129-
@mutex.synchronize {
143+
@mutex.synchronize do
130144
$stdout.print "\e[K"
131145
first_line = message.lines(chomp: true).first || ""
132146

133147
# Make sure we don't line-wrap the output
134-
size = __skip__ = IO.respond_to?(:console_size) ? IO.console_size : IO.console.winsize
148+
size =
149+
__skip__ =
150+
IO.respond_to?(:console_size) ? IO.console_size : IO.console.winsize
135151
terminal_width = size[1].to_i.nonzero? || 80
136152
width_limit = terminal_width / 2 - 3
137153

@@ -144,19 +160,15 @@ def stdout(message)
144160
$stdout.print "\e[1A\n"
145161
@counter += 1
146162
@counter = 0 if @counter >= @indicators.length
147-
}
163+
end
148164
end
149165

150166
def stderr(message)
151-
@mutex.synchronize {
152-
$stdout.print message
153-
}
167+
@mutex.synchronize { $stdout.print message }
154168
end
155169

156170
def done
157-
@mutex.synchronize {
158-
$stdout.print "\e[K"
159-
}
171+
@mutex.synchronize { $stdout.print "\e[K" }
160172
end
161173
end
162174
end

lib/ruby_wasm/build/product/wasi_vfs.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ def build(executor)
4848
lib_wasi_vfs_url =
4949
"https://github.com/kateinoigakukun/wasi-vfs/releases/download/v#{WASI_VFS_VERSION}/libwasi_vfs-wasm32-unknown-unknown.zip"
5050
Dir.mktmpdir do |tmpdir|
51-
executor.system "curl", "-L", lib_wasi_vfs_url, "-o", "#{tmpdir}/libwasi_vfs.zip"
51+
executor.system "curl",
52+
"-L",
53+
lib_wasi_vfs_url,
54+
"-o",
55+
"#{tmpdir}/libwasi_vfs.zip"
5256
executor.system "unzip", "#{tmpdir}/libwasi_vfs.zip", "-d", tmpdir
5357
executor.mkdir_p File.dirname(lib_wasi_vfs_a)
5458
executor.mv File.join(tmpdir, "libwasi_vfs.a"), lib_wasi_vfs_a

0 commit comments

Comments
 (0)