Skip to content

Commit efdc9e1

Browse files
Merge pull request #318 from ruby/katei/paralell-by-default
build: Parallelize `make` build by default
2 parents 9b6d49c + 4437c66 commit efdc9e1

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

lib/ruby_wasm/build.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,17 @@
55
module RubyWasm
66
# Build executor to run the actual build commands.
77
class BuildExecutor
8-
def initialize(verbose: false)
8+
attr_reader :process_count
9+
10+
def initialize(verbose: false, process_count: nil)
911
@verbose = verbose
1012
@github_actions_markup = ENV["ENABLE_GITHUB_ACTIONS_MARKUP"] != nil
13+
__skip__ = begin
14+
require "etc"
15+
@process_count = process_count || Etc.nprocessors
16+
rescue LoadError
17+
@process_count = process_count || 1
18+
end
1119
end
1220

1321
def system(*args, chdir: nil, env: nil)

lib/ruby_wasm/build/product/baseruby.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ def build(executor)
2828
"--prefix=#{install_dir}",
2929
"--disable-install-doc",
3030
chdir: product_build_dir
31-
executor.system "make", "install", chdir: product_build_dir
31+
executor.system "make",
32+
"-j#{executor.process_count}",
33+
"install",
34+
chdir: product_build_dir
3235
end
3336
end
3437
end

lib/ruby_wasm/build/product/crossruby.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def build(executor, crossruby)
3333
executor.mkdir_p objdir
3434
do_extconf executor, crossruby
3535
executor.system "make",
36+
"-j#{executor.process_count}",
3637
"-C",
3738
"#{objdir}",
3839
*make_args(crossruby),

sig/ruby_wasm/build.rbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,11 @@ module RubyWasm
224224
class BuildExecutor
225225
@verbose: bool
226226
@github_actions_markup: bool
227+
@process_count: Integer
227228
@start_times: Hash[[Class, String], Time]
228229

230+
attr_reader process_count: Integer
231+
229232
def initialize: (?verbose: bool) -> void
230233
def system: (*_ToS args, ?chdir: String?, ?env: Hash[String, String]?) -> void
231234
def rm_rf: (FileUtils::pathlist list) -> void

0 commit comments

Comments
 (0)