Skip to content

Commit 716980d

Browse files
configure with downloaded wasm-opt
1 parent d40491a commit 716980d

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

lib/ruby_wasm/build_system/product/crossruby.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ def configure_args(build_triple, toolchain)
217217
case target
218218
when "wasm32-unknown-wasi"
219219
xldflags << @wasi_vfs.lib_wasi_vfs_a if @wasi_vfs
220+
args << %Q(WASMOPT=#{@toolchain.wasm_opt})
220221
when "wasm32-unknown-emscripten"
221222
ldflags.concat(%w[-s MODULARIZE=1])
222223
else

lib/ruby_wasm/build_system/toolchain.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ def initialize(
7474
if build_dir.nil?
7575
raise "build_dir is required when wasm-opt not installed in PATH"
7676
end
77-
@wasm_opt_path =
78-
File.join(build_dir, "toolchain", "binaryen", "bin", "wasm-opt")
77+
@binaryen_path = File.join(build_dir, "toolchain", "binaryen")
7978
@binaryen_version = binaryen_version
8079
end
8180

@@ -97,6 +96,10 @@ def find_tool(name)
9796
@tools[name]
9897
end
9998

99+
def wasm_opt
100+
File.join(@binaryen_path, "bin", "wasm-opt")
101+
end
102+
100103
def define_task
101104
@task ||= fetch_task
102105
end
@@ -152,17 +155,15 @@ def fetch_task
152155
sh "tar -C #{@wasi_sdk_path} --strip-component 1 -xzf #{wasi_sdk_tarball}"
153156
end
154157

155-
binaryen_path = File.expand_path("../..", @wasm_opt_path)
156-
binaryen_tarball =
157-
File.expand_path("../../../binaryen.tar.gz", @wasm_opt_path)
158+
binaryen_tarball = File.expand_path("../binaryen.tar.gz", @binaryen_path)
158159
file binaryen_tarball do
159160
mkdir_p File.dirname(binaryen_tarball)
160161
sh "curl -L -o #{binaryen_tarball} #{self.binaryen_download_url(@binaryen_version)}"
161162
end
162163
binaryen =
163-
file_create binaryen_path => binaryen_tarball do
164-
mkdir_p binaryen_path
165-
sh "tar -C #{binaryen_path} --strip-component 1 -xzf #{binaryen_tarball}"
164+
file_create @binaryen_path => binaryen_tarball do
165+
mkdir_p @binaryen_path
166+
sh "tar -C #{@binaryen_path} --strip-component 1 -xzf #{binaryen_tarball}"
166167
end
167168

168169
required = []

0 commit comments

Comments
 (0)