Skip to content

Commit 9a0a351

Browse files
build: Group build outputs
1 parent 3c31744 commit 9a0a351

File tree

7 files changed

+52
-14
lines changed

7 files changed

+52
-14
lines changed

lib/ruby_wasm/build.rb

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,28 @@ def system(*args, chdir: nil, out: nil, env: nil)
4040
raise e
4141
end
4242

43+
def begin_section(klass, name, note)
44+
if ENV["GITHUB_ACTIONS"]
45+
puts "::group::#{klass}(#{name}) -- #{note}"
46+
else
47+
puts "\e[1;36m==>\e[0m \e[1m#{klass}(#{name}) -- #{note}\e[0m"
48+
end
49+
50+
# Record the start time
51+
@start_times ||= Hash.new
52+
@start_times[[klass, name]] = Time.now
53+
54+
$stdout.flush
55+
end
56+
57+
def end_section(klass, name)
58+
took = Time.now - @start_times[[klass, name]]
59+
puts "\e[1;36m==>\e[0m \e[1m#{klass}(#{name}) -- done in #{took.round(2)}s\e[0m"
60+
if ENV["GITHUB_ACTIONS"]
61+
puts "::endgroup::"
62+
end
63+
end
64+
4365
def rm_rf(list)
4466
FileUtils.rm_rf(list)
4567
end
@@ -69,7 +91,7 @@ def write(path, data)
6991
def _print_command(args, env)
7092
require "shellwords"
7193
# Bold cyan
72-
print "\e[1;36m ==>\e[0m "
94+
print "\e[1;36m ==>\e[0m "
7395
print "env " + env.map { |k, v| "#{k}=#{v}" }.join(" ") + " " if env
7496
print args.map { |arg| Shellwords.escape(arg.to_s) }.join(" ") + "\n"
7597
end

lib/ruby_wasm/build/product/crossruby.rb

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,27 +143,37 @@ def configure(executor, reconfigure: false)
143143
end
144144

145145
def build_exts(executor)
146-
@user_exts.each { |prod| prod.build(executor, self) }
147-
executor.mkdir_p File.dirname(extinit_obj)
148-
executor.system "ruby",
149-
extinit_c_erb,
150-
*@user_exts.map(&:name),
151-
"--cc",
152-
toolchain.cc,
153-
"--output",
154-
extinit_obj
146+
@user_exts.each do |prod|
147+
executor.begin_section prod.class, prod.name, "Building"
148+
prod.build(executor, self)
149+
executor.end_section prod.class, prod.name
150+
end
155151
end
156152

157153
def build(executor, remake: false, reconfigure: false)
158154
executor.mkdir_p dest_dir
159155
executor.mkdir_p build_dir
160156
@toolchain.install
161157
[@source, @baseruby, @libyaml, @zlib, @openssl, @wasi_vfs].each do |prod|
158+
executor.begin_section prod.class, prod.name, "Building"
162159
prod.build(executor)
160+
executor.end_section prod.class, prod.name
163161
end
162+
executor.begin_section self.class, name, "Configuring"
164163
configure(executor, reconfigure: reconfigure)
164+
executor.end_section self.class, name
165+
165166
build_exts(executor)
166167

168+
executor.begin_section self.class, name, "Building"
169+
executor.mkdir_p File.dirname(extinit_obj)
170+
executor.system "ruby",
171+
extinit_c_erb,
172+
*@user_exts.map(&:name),
173+
"--cc",
174+
toolchain.cc,
175+
"--output",
176+
extinit_obj
167177
install_dir = File.join(build_dir, "install")
168178
if !File.exist?(install_dir) || remake || reconfigure
169179
executor.system "make",
@@ -176,6 +186,8 @@ def build(executor, remake: false, reconfigure: false)
176186
executor.cp_r install_dir, dest_dir
177187
@user_exts.each { |ext| ext.do_install_rb(executor, self) }
178188
executor.system "tar", "cfz", artifact, "-C", "rubies", name
189+
190+
executor.end_section self.class, name
179191
end
180192

181193
def clean(executor)

lib/ruby_wasm/build/product/libyaml.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def install_root
2525
end
2626

2727
def name
28-
product_build_dir
28+
"libyaml-#{LIBYAML_VERSION}-#{target}"
2929
end
3030

3131
def build(executor)

lib/ruby_wasm/build/product/openssl.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def install_root
2626
end
2727

2828
def name
29-
product_build_dir
29+
"openssl-#{OPENSSL_VERSION}-#{target}"
3030
end
3131

3232
def configure_args

lib/ruby_wasm/build/product/wasi_vfs.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def cli_bin_path
3939
end
4040

4141
def name
42-
lib_product_build_dir
42+
"wasi-vfs-#{WASI_VFS_VERSION}-#{RbConfig::CONFIG["host"]}}"
4343
end
4444

4545
def build(executor)

lib/ruby_wasm/build/product/zlib.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def install_root
2525
end
2626

2727
def name
28-
product_build_dir
28+
"zlib-#{ZLIB_VERSION}-#{target}"
2929
end
3030

3131
def configure_args

sig/ruby_wasm/build.rbs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ module RubyWasm
223223

224224
class BuildExecutor
225225
@verbose: bool
226+
@start_times: Hash[[Class, String], Time]
226227

227228
def initialize: (?verbose: bool) -> void
228229
def system: (*_ToS args, ?chdir: String?, ?out: Kernel::redirect_fd?, ?env: Hash[String, String]?) -> void
@@ -233,6 +234,9 @@ module RubyWasm
233234
def mkdir_p: (FileUtils::pathlist list) -> void
234235
def write: (String path, _ToS data) -> void
235236

237+
def begin_section: (Class klass, String name, String note) -> void
238+
def end_section: (Class klass, String name) -> void
239+
236240
private def _print_command: (Array[_ToS] command, Hash[String, String]? env) -> void
237241
end
238242

0 commit comments

Comments
 (0)