Skip to content

Commit 2a5fd9f

Browse files
Build exts under unbundled environment for dynamic linking too
1 parent 6d91d09 commit 2a5fd9f

File tree

2 files changed

+26
-29
lines changed

2 files changed

+26
-29
lines changed

lib/ruby_wasm/packager/core.rb

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ def wasi_exec_model
6767
use_js_gem ? "reactor" : "command"
6868
end
6969

70+
def with_unbundled_env(&block)
71+
__skip__ = if defined?(Bundler)
72+
Bundler.with_unbundled_env(&block)
73+
else
74+
block.call
75+
end
76+
end
77+
7078
def cache_key(digest)
7179
raise NotImplementedError
7280
end
@@ -87,27 +95,22 @@ def build(executor, options)
8795
end
8896
build.crossruby.clean(executor) if options[:clean]
8997

90-
do_build =
91-
proc do
92-
build.crossruby.build(
93-
executor,
94-
remake: options[:remake],
95-
reconfigure: options[:reconfigure]
96-
)
97-
end
98+
self.with_unbundled_env do
99+
build.crossruby.build(
100+
executor,
101+
remake: options[:remake],
102+
reconfigure: options[:reconfigure]
103+
)
104+
end
98105

99-
__skip__ =
100-
if defined?(Bundler)
101-
Bundler.with_unbundled_env(&do_build)
102-
else
103-
do_build.call
104-
end
105106
build.crossruby.artifact
106107
end
107108

108109
def build_gem_exts(executor, gem_home)
109110
build = derive_build
110-
self._build_gem_exts(executor, build, gem_home)
111+
self.with_unbundled_env do
112+
self._build_gem_exts(executor, build, gem_home)
113+
end
111114
end
112115

113116
def link_gem_exts(executor, ruby_root, gem_home, module_bytes)
@@ -269,21 +272,14 @@ def build(executor, options)
269272
end
270273
build.crossruby.clean(executor) if options[:clean]
271274

272-
do_build =
273-
proc do
274-
build.crossruby.build(
275-
executor,
276-
remake: options[:remake],
277-
reconfigure: options[:reconfigure]
278-
)
279-
end
275+
self.with_unbundled_env do
276+
build.crossruby.build(
277+
executor,
278+
remake: options[:remake],
279+
reconfigure: options[:reconfigure]
280+
)
281+
end
280282

281-
__skip__ =
282-
if defined?(Bundler)
283-
Bundler.with_unbundled_env(&do_build)
284-
else
285-
do_build.call
286-
end
287283
build.crossruby.artifact
288284
end
289285

sig/ruby_wasm/packager.rbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class RubyWasm::Packager
7777
def build_gem_exts: (RubyWasm::BuildExecutor, string gem_home) -> void
7878
def link_gem_exts: (RubyWasm::BuildExecutor, string ruby_root, string gem_home, bytes module_bytes) -> bytes
7979
def wasi_exec_model: () -> String
80+
def with_unbundled_env: () { () -> void } -> void
8081
end
8182

8283
class DynamicLinking < RubyWasm::Packager::Core::BuildStrategy

0 commit comments

Comments
 (0)