Skip to content

Commit e29081b

Browse files
Remove rake dependency from baseruby product
1 parent e6db8e4 commit e29081b

File tree

3 files changed

+19
-24
lines changed

3 files changed

+19
-24
lines changed

lib/ruby_wasm/build_system/product/baseruby.rb

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,14 @@ def name
2323
"baseruby-#{@channel}"
2424
end
2525

26-
def define_task
27-
directory product_build_dir
28-
29-
@install_task =
30-
task name => [
31-
source.src_dir,
32-
source.configure_file,
33-
product_build_dir
34-
] do
35-
next if Dir.exist?(install_dir)
36-
sh "#{source.configure_file} --prefix=#{install_dir} --disable-install-doc",
37-
chdir: product_build_dir
38-
sh "make install", chdir: product_build_dir
39-
end
26+
def build
27+
FileUtils.mkdir_p product_build_dir
28+
Rake::Task[source.configure_file].invoke
29+
return if Dir.exist?(install_dir)
30+
Dir.chdir(product_build_dir) do
31+
system "#{source.configure_file} --prefix=#{install_dir} --disable-install-doc"
32+
system "make install"
33+
end
4034
end
4135
end
4236
end

lib/ruby_wasm/build_system/product/crossruby.rb

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def build(crossruby)
3232
objdir = product_build_dir crossruby
3333
FileUtils.mkdir_p objdir
3434
do_extconf crossruby
35-
FileUtils.sh %Q(make -C "#{objdir}" #{make_args(crossruby).join(" ")} #{lib}.a)
35+
system %Q(make -C "#{objdir}" #{make_args(crossruby).join(" ")} #{lib}.a)
3636
# A ext can provide link args by link.filelist. It contains only built archive file by default.
3737
unless File.exist?(linklist(crossruby))
3838
File.write(linklist(crossruby), Dir.glob("#{objdir}/*.a").join("\n"))
@@ -63,14 +63,14 @@ def do_extconf(crossruby)
6363
"-I#{crossruby.build_dir}"
6464
]
6565
# Clear RUBYOPT to avoid loading unrelated bundle setup
66-
FileUtils.sh ({ "RUBYOPT" => "" }),
66+
system ({ "RUBYOPT" => "" }),
6767
"#{crossruby.baseruby_path} #{extconf_args.join(" ")}",
6868
chdir: objdir
6969
end
7070

7171
def do_install_rb(crossruby)
7272
objdir = product_build_dir crossruby
73-
FileUtils.sh %Q(make -C "#{objdir}" #{make_args(crossruby).join(" ")} install-rb)
73+
system %Q(make -C "#{objdir}" #{make_args(crossruby).join(" ")} install-rb)
7474
end
7575
end
7676

@@ -115,36 +115,37 @@ def initialize(
115115
def configure(reconfigure: false)
116116
if !File.exist?("#{build_dir}/Makefile") || reconfigure
117117
args = configure_args(RbConfig::CONFIG["host"], toolchain)
118-
FileUtils.sh "#{source.configure_file} #{args.join(" ")}",
118+
system "#{source.configure_file} #{args.join(" ")}",
119119
chdir: build_dir
120120
end
121121
# NOTE: we need rbconfig.rb at configuration time to build user given extensions with mkmf
122-
FileUtils.sh "make rbconfig.rb", chdir: build_dir
122+
system "make rbconfig.rb", chdir: build_dir
123123
end
124124

125125
def build_exts
126126
@user_exts.each { |prod| prod.build(self) }
127127
mkdir_p File.dirname(extinit_obj)
128-
FileUtils.sh %Q(ruby #{extinit_c_erb} #{@user_exts.map(&:name).join(" ")} | #{toolchain.cc} -c -x c - -o #{extinit_obj})
128+
system %Q(ruby #{extinit_c_erb} #{@user_exts.map(&:name).join(" ")} | #{toolchain.cc} -c -x c - -o #{extinit_obj})
129129
end
130130

131131
def build(remake: false, reconfigure: false)
132132
FileUtils.mkdir_p dest_dir
133133
FileUtils.mkdir_p build_dir
134134
Rake::Task[source.configure_file].invoke
135+
@baseruby.build
135136
dep_tasks.each(&:invoke)
136137
configure(reconfigure: reconfigure)
137138
build_exts
138139

139140
install_dir = File.join(build_dir, "install")
140141
if !File.exist?(install_dir) || remake || reconfigure
141-
FileUtils.sh "make install DESTDIR=#{install_dir}", chdir: build_dir
142+
system "make install DESTDIR=#{install_dir}", chdir: build_dir
142143
end
143144

144145
FileUtils.rm_rf dest_dir
145146
FileUtils.cp_r install_dir, dest_dir
146147
@user_exts.each { |ext| ext.do_install_rb(self) }
147-
FileUtils.sh "tar cfz #{artifact} -C rubies #{name}"
148+
system "tar cfz #{artifact} -C rubies #{name}"
148149
end
149150

150151
def name
@@ -200,7 +201,7 @@ def baseruby_path
200201
end
201202

202203
def dep_tasks
203-
[@baseruby.install_task, @toolchain.install_task] + @dep_tasks
204+
[@toolchain.install_task] + @dep_tasks
204205
end
205206

206207
def configure_args(build_triple, toolchain)

lib/ruby_wasm/rake_task.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def initialize(
4949
add_product RubyWasm::ZlibProduct.new(@build_dir, @target, @toolchain)
5050
@wasi_vfs = add_product RubyWasm::WasiVfsProduct.new(@build_dir)
5151
@source = add_product RubyWasm::BuildSource.new(src, @build_dir)
52-
@baseruby = add_product RubyWasm::BaseRubyProduct.new(@build_dir, @source)
52+
@baseruby = RubyWasm::BaseRubyProduct.new(@build_dir, @source)
5353

5454
build_params =
5555
RubyWasm::BuildParams.new(options.merge(name: name, target: @target))

0 commit comments

Comments
 (0)