Skip to content

Commit 4c3ce92

Browse files
Add --dest-dir option to link .so files built by Bundler
1 parent 1f3e767 commit 4c3ce92

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

lib/ruby_wasm/cli.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def build(args)
5353
target_triplet: "wasm32-unknown-wasip1",
5454
profile: "full",
5555
stdlib: true,
56+
dest_dir: nil,
5657
disable_gems: false,
5758
gemfile: nil,
5859
patches: [],
@@ -108,6 +109,10 @@ def build(args)
108109
options[:disable_gems] = true
109110
end
110111

112+
opts.on("--dest-dir PATH", "(Experimental) Destination directory") do |path|
113+
options[:dest_dir] = path
114+
end
115+
111116
opts.on("-p", "--patch PATCH", "Apply a patch") do |patch|
112117
options[:patches] << patch
113118
end
@@ -149,7 +154,9 @@ def do_build_with_force_ruby_platform(options)
149154

150155
require "tmpdir"
151156

152-
if options[:save_temps]
157+
if dest_dir = options[:dest_dir]
158+
self.do_build(executor, dest_dir, packager, options)
159+
elsif options[:save_temps]
153160
tmpdir = Dir.mktmpdir
154161
self.do_build(executor, tmpdir, packager, options)
155162
@stderr.puts "Temporary files are saved to #{tmpdir}"

lib/ruby_wasm/packager/core.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def _link_gem_exts(executor, build, gem_home)
139139
adapters = [wasi_adapter]
140140
dl_openable_libs = []
141141
dl_openable_libs << [File.join(ruby_root, "usr"), Dir.glob(File.join(ruby_root, "usr", "local", "lib", "ruby", "**", "*.so"))]
142-
dl_openable_libs << [gem_home, Dir.glob(File.join(gem_home, "gems", "**", "*.so"))]
142+
dl_openable_libs << [gem_home, Dir.glob(File.join(gem_home, "**", "*.so"))]
143143

144144
linker = RubyWasmExt::ComponentLink.new
145145
linker.use_built_in_libdl(true)

sig/ruby_wasm/packager.rbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class RubyWasm::Packager
2323
src: RubyWasm::Packager::build_source,
2424
default_exts: String,
2525
suffix: String,
26+
gem_home: String?,
2627
}
2728

2829
type bytes = String

0 commit comments

Comments
 (0)