Skip to content

Commit 1f671ee

Browse files
Add --enable-component-model to js ext library
To support graceful migration, we need to support both legacy wit-bindgen ABI and the latest Component Model ABI at the same time. This patch does the following: * Add `--enable-component-model` option to js extconf.rb * Generate bindings for the latest Component Model ABI
1 parent d3d3dec commit 1f671ee

File tree

13 files changed

+877
-12
lines changed

13 files changed

+877
-12
lines changed

lib/ruby_wasm/build/product/crossruby.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ module RubyWasm
55
class CrossRubyExtProduct < BuildProduct
66
attr_reader :name
77

8-
def initialize(srcdir, toolchain, ext_relative_path: nil)
8+
def initialize(srcdir, toolchain, features:, ext_relative_path: nil)
99
@srcdir, @toolchain = srcdir, toolchain
1010
# ext_relative_path is relative path from build dir
1111
# e.g. cgi-0.3.6/ext/cgi/escape
1212
@ext_relative_path = ext_relative_path || File.basename(srcdir)
13+
@features = features
1314
@name = @ext_relative_path
1415
end
1516

@@ -76,6 +77,7 @@ def do_extconf(executor, crossruby)
7677
"#{@srcdir}/extconf.rb",
7778
"--target-rbconfig=#{rbconfig_rb}",
7879
]
80+
extconf_args << "--enable-component-model" if @features.support_component_model?
7981
executor.system Gem.ruby, *extconf_args
8082
end
8183

@@ -105,8 +107,10 @@ def do_legacy_extconf(executor, crossruby)
105107
# like "cgi/escape" instead of "escape"
106108
"-e",
107109
%Q(require "json"; File.write("#{metadata_json(crossruby)}", JSON.dump({target: $target}))),
108-
"-I#{crossruby.build_dir}"
110+
"-I#{crossruby.build_dir}",
111+
"--",
109112
]
113+
extconf_args << "--enable-component-model" if @features.support_component_model?
110114
# Clear RUBYOPT to avoid loading unrelated bundle setup
111115
executor.system crossruby.baseruby_path,
112116
*extconf_args,

lib/ruby_wasm/build/toolchain/wit_bindgen.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ class WitBindgen
44

55
def initialize(
66
build_dir:,
7-
revision: "251e84b89121751f79ac268629e9285082b2596d"
7+
revision: "v0.24.0"
88
)
99
@build_dir = build_dir
10-
@tool_dir = File.join(@build_dir, "toolchain", "wit-bindgen")
10+
@tool_dir = File.join(@build_dir, "toolchain", "wit-bindgen-#{revision}")
1111
@bin_path = File.join(@tool_dir, "bin", "wit-bindgen")
1212
@revision = revision
1313
end

lib/ruby_wasm/packager/core.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ def build_exts(executor, build)
162162
RubyWasm::CrossRubyExtProduct.new(
163163
ext_srcdir,
164164
build.toolchain,
165+
features: @packager.features,
165166
ext_relative_path: ext_relative_path
166167
)
167168
end
@@ -323,6 +324,7 @@ def user_exts(build)
323324
RubyWasm::CrossRubyExtProduct.new(
324325
ext_srcdir,
325326
build.toolchain,
327+
features: @packager.features,
326328
ext_relative_path: ext_relative_path
327329
)
328330
end

0 commit comments

Comments
 (0)