Skip to content

Commit

Permalink
Merge pull request #318 from ruby/katei/paralell-by-default
Browse files Browse the repository at this point in the history
build: Parallelize `make` build by default
  • Loading branch information
kateinoigakukun authored Nov 27, 2023
2 parents 9b6d49c + 4437c66 commit efdc9e1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib/ruby_wasm/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@
module RubyWasm
# Build executor to run the actual build commands.
class BuildExecutor
def initialize(verbose: false)
attr_reader :process_count

def initialize(verbose: false, process_count: nil)
@verbose = verbose
@github_actions_markup = ENV["ENABLE_GITHUB_ACTIONS_MARKUP"] != nil
__skip__ = begin
require "etc"
@process_count = process_count || Etc.nprocessors
rescue LoadError
@process_count = process_count || 1
end
end

def system(*args, chdir: nil, env: nil)
Expand Down
5 changes: 4 additions & 1 deletion lib/ruby_wasm/build/product/baseruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ def build(executor)
"--prefix=#{install_dir}",
"--disable-install-doc",
chdir: product_build_dir
executor.system "make", "install", chdir: product_build_dir
executor.system "make",
"-j#{executor.process_count}",
"install",
chdir: product_build_dir
end
end
end
1 change: 1 addition & 0 deletions lib/ruby_wasm/build/product/crossruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def build(executor, crossruby)
executor.mkdir_p objdir
do_extconf executor, crossruby
executor.system "make",
"-j#{executor.process_count}",
"-C",
"#{objdir}",
*make_args(crossruby),
Expand Down
3 changes: 3 additions & 0 deletions sig/ruby_wasm/build.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,11 @@ module RubyWasm
class BuildExecutor
@verbose: bool
@github_actions_markup: bool
@process_count: Integer
@start_times: Hash[[Class, String], Time]

attr_reader process_count: Integer

def initialize: (?verbose: bool) -> void
def system: (*_ToS args, ?chdir: String?, ?env: Hash[String, String]?) -> void
def rm_rf: (FileUtils::pathlist list) -> void
Expand Down

0 comments on commit efdc9e1

Please sign in to comment.