ruby_wasm 2.5.0-x64-mingw-ucrt → 2.5.2-x64-mingw-ucrt

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +9 -7
  3. data/Gemfile +1 -1
  4. data/README.md +12 -11
  5. data/Rakefile +9 -7
  6. data/docs/cheat_sheet.md +8 -8
  7. data/lib/ruby_wasm/3.1/ruby_wasm.so +0 -0
  8. data/lib/ruby_wasm/3.2/ruby_wasm.so +0 -0
  9. data/lib/ruby_wasm/3.3/ruby_wasm.so +0 -0
  10. data/lib/ruby_wasm/build/executor.rb +4 -0
  11. data/lib/ruby_wasm/build/product/crossruby.rb +59 -25
  12. data/lib/ruby_wasm/build/product/libyaml.rb +5 -3
  13. data/lib/ruby_wasm/build/product/openssl.rb +7 -2
  14. data/lib/ruby_wasm/build/product/product.rb +3 -3
  15. data/lib/ruby_wasm/build/product/ruby_source.rb +3 -3
  16. data/lib/ruby_wasm/build/product/wasi_vfs.rb +1 -1
  17. data/lib/ruby_wasm/build/product/zlib.rb +3 -1
  18. data/lib/ruby_wasm/build/target.rb +24 -0
  19. data/lib/ruby_wasm/build/toolchain/wit_bindgen.rb +2 -2
  20. data/lib/ruby_wasm/build/toolchain.rb +1 -1
  21. data/lib/ruby_wasm/build.rb +7 -3
  22. data/lib/ruby_wasm/cli.rb +147 -11
  23. data/lib/ruby_wasm/feature_set.rb +30 -0
  24. data/lib/ruby_wasm/packager/component_adapter/wasi_snapshot_preview1.command.wasm +0 -0
  25. data/lib/ruby_wasm/packager/component_adapter/wasi_snapshot_preview1.reactor.wasm +0 -0
  26. data/lib/ruby_wasm/packager/component_adapter.rb +14 -0
  27. data/lib/ruby_wasm/packager/core.rb +199 -5
  28. data/lib/ruby_wasm/packager/file_system.rb +5 -3
  29. data/lib/ruby_wasm/packager.rb +22 -82
  30. data/lib/ruby_wasm/rake_task.rb +1 -0
  31. data/lib/ruby_wasm/version.rb +1 -1
  32. data/lib/ruby_wasm.rb +2 -0
  33. data/package-lock.json +5571 -7015
  34. data/package.json +3 -3
  35. data/rakelib/check.rake +23 -10
  36. data/rakelib/ci.rake +3 -3
  37. data/rakelib/packaging.rake +44 -15
  38. data/sig/ruby_wasm/build.rbs +38 -28
  39. data/sig/ruby_wasm/cli.rbs +27 -3
  40. data/sig/ruby_wasm/ext.rbs +25 -2
  41. data/sig/ruby_wasm/feature_set.rbs +12 -0
  42. data/sig/ruby_wasm/packager.rbs +44 -7
  43. metadata +10 -7
  44. data/builders/wasm32-unknown-emscripten/Dockerfile +0 -43
  45. data/builders/wasm32-unknown-emscripten/entrypoint.sh +0 -7
  46. data/builders/wasm32-unknown-wasi/Dockerfile +0 -47
  47. data/builders/wasm32-unknown-wasi/entrypoint.sh +0 -7
data/package.json CHANGED
@@ -5,8 +5,8 @@
5
5
  "packages/npm-packages/*"
6
6
  ],
7
7
  "devDependencies": {
8
- "@playwright/test": "^1.40.1",
9
- "@rollup/plugin-json": "^6.0.1",
10
- "rollup": "^4.6.1"
8
+ "@playwright/test": "^1.43.1",
9
+ "@rollup/plugin-json": "^6.1.0",
10
+ "rollup": "^4.17.2"
11
11
  }
12
12
  }
data/rakelib/check.rake CHANGED
@@ -1,35 +1,48 @@
1
1
  namespace :check do
2
+ legacy_wit_bindgen = RubyWasm::WitBindgen.new(build_dir: "build", revision: "251e84b89121751f79ac268629e9285082b2596d")
2
3
  wit_bindgen = RubyWasm::WitBindgen.new(build_dir: "build")
3
4
  task :install_wit_bindgen do
5
+ legacy_wit_bindgen.install
4
6
  wit_bindgen.install
5
7
  end
6
- task bindgen_c: :install_wit_bindgen do
8
+ task legacy_bindgen_c: :install_wit_bindgen do
7
9
  wits = [
8
- %w[packages/gems/js/ext/witapi/bindgen/rb-abi-guest.wit --export],
9
- %w[packages/gems/js/ext/js/bindgen/rb-js-abi-host.wit --import]
10
+ %w[packages/gems/js/ext/js/bindgen/legacy/rb-abi-guest.wit --export],
11
+ %w[packages/gems/js/ext/js/bindgen/legacy/rb-js-abi-host.wit --import]
10
12
  ]
11
13
  wits.each do |wit|
12
14
  path, mode = wit
13
- sh "#{wit_bindgen.bin_path} guest c #{mode} #{path} --out-dir #{File.dirname(path)}"
15
+ sh "#{legacy_wit_bindgen.bin_path} guest c #{mode} #{path} --out-dir #{File.dirname(path)}"
14
16
  end
15
17
  end
16
18
 
17
- task bindgen_js: :install_wit_bindgen do
19
+ task legacy_bindgen_js: :install_wit_bindgen do
18
20
  sh *[
19
- wit_bindgen.bin_path,
21
+ legacy_wit_bindgen.bin_path,
20
22
  "host",
21
23
  "js",
22
24
  "--import",
23
- "packages/gems/js/ext/witapi/bindgen/rb-abi-guest.wit",
25
+ "packages/gems/js/ext/js/bindgen/legacy/rb-abi-guest.wit",
24
26
  "--export",
25
- "packages/gems/js/ext/js/bindgen/rb-js-abi-host.wit",
27
+ "packages/gems/js/ext/js/bindgen/legacy/rb-js-abi-host.wit",
26
28
  "--out-dir",
27
- "packages/npm-packages/ruby-wasm-wasi/src/bindgen"
29
+ "packages/npm-packages/ruby-wasm-wasi/src/bindgen/legacy"
28
30
  ]
29
31
  end
30
32
 
33
+ task bindgen_c: :install_wit_bindgen do
34
+ js_pkg_dir = "packages/gems/js"
35
+ sh(
36
+ wit_bindgen.bin_path,
37
+ "c",
38
+ File.join(js_pkg_dir, "wit"),
39
+ "--out-dir",
40
+ File.join(js_pkg_dir, "ext", "js", "bindgen")
41
+ )
42
+ end
43
+
31
44
  desc "Check wit-bindgen'ed sources are up-to-date"
32
- task bindgen: %i[bindgen_c bindgen_js]
45
+ task bindgen: %i[bindgen_c legacy_bindgen_c legacy_bindgen_js]
33
46
 
34
47
  task :type do
35
48
  sh "bundle exec steep check"
data/rakelib/ci.rake CHANGED
@@ -1,7 +1,7 @@
1
1
  def latest_build_sources
2
2
  BUILD_SOURCES
3
3
  .filter_map do |name|
4
- src = RubyWasm::Packager.build_source_aliases(LIB_ROOT)[name]
4
+ src = RubyWasm::CLI.build_source_aliases(LIB_ROOT)[name]
5
5
  case src[:type]
6
6
  when "github"
7
7
  url = "repos/#{src[:repo]}/commits/#{src[:rev]}"
@@ -23,7 +23,7 @@ def release_note
23
23
  EOS
24
24
 
25
25
  BUILD_SOURCES.each do |name|
26
- source = RubyWasm::Packager.build_source_aliases(LIB_ROOT)[name]
26
+ source = RubyWasm::CLI.build_source_aliases(LIB_ROOT)[name]
27
27
  case source[:type]
28
28
  when "github"
29
29
  output +=
@@ -86,7 +86,7 @@ def rake_task_matrix
86
86
  task: "standalone:#{pkg[:name]}",
87
87
  artifact: "packages/standalone/#{pkg[:name]}/dist",
88
88
  artifact_name: "standalone-#{pkg[:name]}",
89
- builder: "wasm32-unknown-wasi",
89
+ builder: "wasm32-unknown-wasip1",
90
90
  rubies_cache_key: ruby_cache_keys[pkg[:build]]
91
91
  }
92
92
  end
@@ -1,7 +1,9 @@
1
1
  wasi_vfs = RubyWasm::WasiVfsProduct.new(File.join(Dir.pwd, "build"))
2
2
  wasi_sdk = TOOLCHAINS["wasi-sdk"]
3
+ def exe_rbwasm = File.expand_path(File.join(__dir__, "..", "exe", "rbwasm"))
4
+
3
5
  tools = {
4
- "WASI_VFS_CLI" => File.expand_path(File.join(__dir__, "..", "exe", "rbwasm")),
6
+ "WASI_VFS_CLI" => exe_rbwasm,
5
7
  "WASMOPT" => wasi_sdk.wasm_opt
6
8
  }
7
9
 
@@ -11,7 +13,7 @@ def npm_pkg_build_command(pkg)
11
13
  [
12
14
  "bundle",
13
15
  "exec",
14
- "rbwasm",
16
+ exe_rbwasm,
15
17
  "build",
16
18
  "--ruby-version",
17
19
  pkg[:ruby_version],
@@ -27,7 +29,8 @@ def npm_pkg_rubies_cache_key(pkg)
27
29
  return nil unless build_command
28
30
  require "open3"
29
31
  cmd = build_command + ["--print-ruby-cache-key"]
30
- stdout, status = Open3.capture2(*cmd)
32
+ chdir = pkg[:gemfile] ? File.dirname(pkg[:gemfile]) : Dir.pwd
33
+ stdout, status = Open3.capture2(*cmd, chdir: chdir)
31
34
  unless status.success?
32
35
  raise "Command failed with status (#{status.exitstatus}): #{cmd.join ""}"
33
36
  end
@@ -51,8 +54,9 @@ namespace :npm do
51
54
  # Share ./build and ./rubies in the same workspace
52
55
  "RUBY_WASM_ROOT" => base_dir
53
56
  }
57
+ cwd = nil
54
58
  if gemfile_path = pkg[:gemfile]
55
- env["BUNDLE_GEMFILE"] = File.join(base_dir, gemfile_path)
59
+ cwd = File.dirname(gemfile_path)
56
60
  else
57
61
  # Explicitly disable rubygems integration since Bundler finds
58
62
  # Gemfile in the repo root directory.
@@ -60,16 +64,30 @@ namespace :npm do
60
64
  end
61
65
  dist_dir = File.join(pkg_dir, "dist")
62
66
  mkdir_p dist_dir
63
- if pkg[:target] == "wasm32-unknown-wasi"
64
- sh env,
65
- *build_command,
66
- "--no-stdlib",
67
- "-o",
68
- File.join(dist_dir, "ruby.wasm")
69
- sh env,
70
- *build_command,
71
- "-o",
72
- File.join(dist_dir, "ruby.debug+stdlib.wasm")
67
+ if pkg[:target].start_with?("wasm32-unknown-wasi")
68
+ Dir.chdir(cwd || base_dir) do
69
+ sh env,
70
+ *build_command,
71
+ "--no-stdlib",
72
+ "-o",
73
+ File.join(dist_dir, "ruby.wasm")
74
+ sh env,
75
+ *build_command,
76
+ "-o",
77
+ File.join(dist_dir, "ruby.debug+stdlib.wasm")
78
+ if pkg[:enable_component_model]
79
+ component_path = File.join(pkg_dir, "tmp", "ruby.component.wasm")
80
+ FileUtils.mkdir_p(File.dirname(component_path))
81
+
82
+ sh env.merge("RUBY_WASM_EXPERIMENTAL_COMPONENT_MODEL" => "1"),
83
+ *build_command, "-o", component_path
84
+ sh "npx", "jco", "transpile",
85
+ "--no-wasi-shim", "--instantiation", "--valid-lifting-optimization",
86
+ component_path, "-o", File.join(dist_dir, "component")
87
+ # ./component/package.json is required to be an ES module
88
+ File.write(File.join(dist_dir, "component", "package.json"), '{ "type": "module" }')
89
+ end
90
+ end
73
91
  sh wasi_sdk.wasm_opt,
74
92
  "--strip-debug",
75
93
  File.join(dist_dir, "ruby.wasm"),
@@ -81,7 +99,9 @@ namespace :npm do
81
99
  "-o",
82
100
  File.join(dist_dir, "ruby+stdlib.wasm")
83
101
  elsif pkg[:target] == "wasm32-unknown-emscripten"
84
- sh env, *build_command, "-o", "/dev/null"
102
+ Dir.chdir(cwd || base_dir) do
103
+ sh env, *build_command, "-o", "/dev/null"
104
+ end
85
105
  end
86
106
  end
87
107
 
@@ -149,3 +169,12 @@ namespace :standalone do
149
169
  end
150
170
  end
151
171
  end
172
+
173
+ namespace :gem do
174
+ task :update_component_adapters do
175
+ ["command", "reactor"].each do |exec_model|
176
+ sh "curl", "-L", "-o", "lib/ruby_wasm/packager/component_adapter/wasi_snapshot_preview1.#{exec_model}.wasm",
177
+ "https://github.com/bytecodealliance/wasmtime/releases/download/v19.0.1/wasi_snapshot_preview1.#{exec_model}.wasm"
178
+ end
179
+ end
180
+ end
@@ -5,17 +5,29 @@ module RubyWasm
5
5
  def cache_key: (Digest::SHA256 digest) -> void
6
6
  end
7
7
 
8
+ class Target
9
+ include _Cacheable
10
+
11
+ @triple: String
12
+ @pic: bool
13
+
14
+ attr_reader triple: String
15
+
16
+ def initialize: (String triple, ?pic: bool) -> void
17
+ def pic?: -> bool
18
+ end
19
+
8
20
  class Build
9
21
  include _Cacheable
10
22
 
11
- @target: String
23
+ @target: Target
12
24
  @build_dir: String
13
25
  @rubies_dir: String
14
26
  @toolchain: Toolchain
15
27
  @libyaml: LibYAMLProduct
16
28
  @zlib: ZlibProduct
17
29
  @openssl: OpenSSLProduct
18
- @wasi_vfs: WasiVfsProduct
30
+ @wasi_vfs: WasiVfsProduct?
19
31
  @baseruby: BaseRubyProduct
20
32
  @crossruby: CrossRubyProduct
21
33
  @source: BuildSource
@@ -24,11 +36,12 @@ module RubyWasm
24
36
 
25
37
  def initialize: (
26
38
  string name,
27
- target: String,
39
+ target: Target,
28
40
  src: Packager::build_source,
29
41
  toolchain: Toolchain?,
30
42
  build_dir: string,
31
43
  rubies_dir: string,
44
+ ?wasi_vfs: :default | WasiVfsProduct?,
32
45
  **untyped
33
46
  ) -> void
34
47
  def crossruby: () -> CrossRubyProduct
@@ -36,10 +49,10 @@ module RubyWasm
36
49
 
37
50
  class BuildParams
38
51
  attr_accessor name: String
39
- attr_accessor target: String
52
+ attr_accessor target: Target
40
53
  attr_accessor default_exts: String
41
54
 
42
- def initialize: (name: string, target: string, default_exts: string) -> void
55
+ def initialize: (name: string, target: Target, default_exts: string) -> void
43
56
  end
44
57
 
45
58
  class BuildProduct
@@ -47,10 +60,10 @@ module RubyWasm
47
60
  end
48
61
 
49
62
  class AutoconfProduct < BuildProduct
50
- @target: String
63
+ @target: Target
51
64
  @toolchain: Toolchain
52
65
 
53
- def initialize: (String target, Toolchain toolchain) -> void
66
+ def initialize: (Target target, Toolchain toolchain) -> void
54
67
  def system_triplet_args: -> Array[String]
55
68
  | -> Array[String]
56
69
  def tools_args: -> Array[String]
@@ -88,8 +101,8 @@ module RubyWasm
88
101
  ZLIB_VERSION: String
89
102
  @build_dir: String
90
103
 
91
- attr_reader target: String
92
- def initialize: (String build_dir, String target, Toolchain toolchain) -> void
104
+ attr_reader target: Target
105
+ def initialize: (String build_dir, Target target, Toolchain toolchain) -> void
93
106
  def product_build_dir: -> String
94
107
  def destdir: -> String
95
108
  def install_root: -> String
@@ -102,8 +115,8 @@ module RubyWasm
102
115
  LIBYAML_VERSION: String
103
116
  @build_dir: String
104
117
 
105
- attr_reader target: String
106
- def initialize: (String build_dir, String target, Toolchain toolchain) -> void
118
+ attr_reader target: Target
119
+ def initialize: (String build_dir, Target target, Toolchain toolchain) -> void
107
120
  def product_build_dir: -> String
108
121
  def destdir: -> String
109
122
  def install_root: -> String
@@ -115,8 +128,8 @@ module RubyWasm
115
128
  OPENSSL_VERSION: String
116
129
  @build_dir: String
117
130
 
118
- attr_reader target: String
119
- def initialize: (String build_dir, String target, Toolchain toolchain) -> void
131
+ attr_reader target: Target
132
+ def initialize: (String build_dir, Target target, Toolchain toolchain) -> void
120
133
  def product_build_dir: -> String
121
134
  def destdir: -> String
122
135
  def install_root: -> String
@@ -145,9 +158,10 @@ module RubyWasm
145
158
  @toolchain: Toolchain
146
159
  @srcdir: String
147
160
  @ext_relative_path: String
161
+ @features: RubyWasm::FeatureSet
148
162
 
149
163
  attr_reader name: String
150
- def initialize: (String srcdir, Toolchain toolchain, ?ext_relative_path: String?) -> void
164
+ def initialize: (String srcdir, Toolchain toolchain, features: RubyWasm::FeatureSet, ?ext_relative_path: String?) -> void
151
165
  def product_build_dir: (CrossRubyProduct crossruby) -> String
152
166
  def linklist: (CrossRubyProduct crossruby) -> String
153
167
  def metadata_json: (CrossRubyProduct crossruby) -> String
@@ -157,6 +171,8 @@ module RubyWasm
157
171
  def build: (BuildExecutor executor, CrossRubyProduct crossruby) -> void
158
172
  def do_extconf: (BuildExecutor executor, CrossRubyProduct crossruby) -> void
159
173
  def do_install_rb: (BuildExecutor executor, CrossRubyProduct crossruby) -> void
174
+
175
+ private def do_legacy_extconf: (BuildExecutor executor, CrossRubyProduct crossruby) -> void
160
176
  end
161
177
 
162
178
  class CrossRubyProduct < AutoconfProduct
@@ -171,6 +187,7 @@ module RubyWasm
171
187
  @openssl: OpenSSLProduct
172
188
  @wasi_vfs: WasiVfsProduct
173
189
 
190
+ attr_reader target: Target
174
191
  attr_reader source: BuildSource
175
192
  attr_reader toolchain: Toolchain
176
193
  attr_accessor user_exts: Array[CrossRubyExtProduct]
@@ -183,6 +200,8 @@ module RubyWasm
183
200
  attr_accessor xldflags: Array[String]
184
201
  def initialize: (BuildParams params, String build_dir, String rubies_dir, BaseRubyProduct baseruby, BuildSource source, Toolchain toolchain) -> void
185
202
  def configure: (BuildExecutor executor, ?reconfigure: bool) -> void
203
+ def need_exts_build?: -> bool
204
+ def need_extinit_obj?: -> bool
186
205
  def build_exts: (BuildExecutor executor) -> void
187
206
  def build: (BuildExecutor executor, ?remake: bool, ?reconfigure: bool) -> void
188
207
  def clean: (BuildExecutor executor) -> void
@@ -191,7 +210,7 @@ module RubyWasm
191
210
  def ext_build_dir: -> String
192
211
  def with_libyaml: (LibYAMLProduct libyaml) -> LibYAMLProduct
193
212
  def with_zlib: (ZlibProduct zlib) -> ZlibProduct
194
- def with_wasi_vfs: (WasiVfsProduct wasi_vfs) -> WasiVfsProduct
213
+ def with_wasi_vfs: (WasiVfsProduct? wasi_vfs) -> WasiVfsProduct?
195
214
  def with_openssl: (OpenSSLProduct openssl) -> OpenSSLProduct
196
215
  def dest_dir: -> String
197
216
  def artifact: -> String
@@ -219,7 +238,7 @@ module RubyWasm
219
238
  def initialize: -> void
220
239
  def find_tool: (Symbol name) -> String
221
240
  def check_envvar: (untyped name) -> void
222
- def self.get: (String target, ?String? build_dir) -> (Toolchain)
241
+ def self.get: (Target target, ?String? build_dir) -> (Toolchain)
223
242
  def self.find_path: (String command) -> String?
224
243
  def self.check_executable: (String command) -> String
225
244
  def cc: -> String
@@ -273,6 +292,7 @@ module RubyWasm
273
292
  def cp_r: (FileUtils::pathlist src, path dest) -> void
274
293
  def mv: (FileUtils::pathlist src, path dest) -> void
275
294
  def mkdir_p: (FileUtils::pathlist list) -> void
295
+ def ln_s: (String src, String dest) -> void
276
296
  def write: (String path, _ToS data) -> void
277
297
 
278
298
  def begin_section: (Class klass, String name, String note) -> void
@@ -299,19 +319,9 @@ module RubyWasm
299
319
  end
300
320
 
301
321
  class BuildTask
302
- @build_dir: String
303
- @rubies_dir: String
304
- @openssl: OpenSSLProduct
305
-
322
+ @build: Build
306
323
  attr_accessor name: String
307
- attr_reader source: BuildSource
308
- attr_reader target: String
309
- attr_reader toolchain: Toolchain
310
- attr_reader libyaml: LibYAMLProduct
311
- attr_reader zlib: ZlibProduct
312
- attr_reader wasi_vfs: WasiVfsProduct
313
- attr_reader baseruby: BaseRubyProduct
314
- attr_reader crossruby: CrossRubyProduct
324
+
315
325
  def initialize: (String name, target: String, src: untyped, ?toolchain: Toolchain?, ?build_dir: String?, ?rubies_dir: String?, **untyped) -> void
316
326
  def hexdigest: -> String
317
327
  end
@@ -1,5 +1,25 @@
1
1
  module RubyWasm
2
2
  class CLI
3
+ type cli_options = {
4
+ print_ruby_cache_key: bool,
5
+ save_temps: bool,
6
+ output: String,
7
+
8
+ optimize: bool,
9
+ remake: bool,
10
+ reconfigure: bool,
11
+ clean: bool,
12
+
13
+ ruby_version: String,
14
+ target_triplet: String,
15
+ profile: String,
16
+ stdlib: bool,
17
+ disable_gems: bool,
18
+ gemfile: String?,
19
+ patches: Array[String],
20
+ format: String,
21
+ }
22
+
3
23
  DEFAULT_RUBIES_DIR: string
4
24
 
5
25
  @stdout: IO
@@ -12,11 +32,15 @@ module RubyWasm
12
32
 
13
33
  private
14
34
 
15
- def build_config: (Hash[untyped, untyped] options) -> Hash[untyped, untyped]
35
+ def build_config: (cli_options options) -> Packager::build_config
36
+ def compute_build_source: (cli_options options) -> [Packager::build_source, String?]
37
+ def self.build_source_aliases: (string root) -> Hash[string, Packager::build_source]
38
+ def self.bundled_patches_path: () -> string
39
+ def root: () -> string
16
40
 
17
- def derive_packager: (Hash[untyped, untyped] options) -> Packager
41
+ def derive_packager: (cli_options options) -> Packager
18
42
  def do_print_ruby_cache_key: (Packager) -> void
19
- def do_build: (BuildExecutor, string tmpdir, Packager, Hash[untyped, untyped] options) -> void
43
+ def do_build: (BuildExecutor, string tmpdir, Packager, cli_options options) -> void
20
44
 
21
45
  def require_extension: () -> void
22
46
  end
@@ -1,5 +1,7 @@
1
1
  module RubyWasmExt
2
- def self.preinitialize: (Array[Integer] module_bytes) -> Array[Integer]
2
+ type bytes = String
3
+
4
+ def self.preinitialize: (bytes module_bytes) -> bytes
3
5
 
4
6
  class WasiVfs
5
7
  def initialize: () -> void
@@ -8,6 +10,27 @@ module RubyWasmExt
8
10
 
9
11
  def map_dir: (String guest_path, String host_path) -> void
10
12
 
11
- def pack: (Array[Integer] module_bytes) -> Array[Integer]
13
+ def pack: (bytes module_bytes) -> bytes
14
+ end
15
+
16
+ class ComponentLink
17
+ def initialize: () -> void
18
+ def library: (String name, bytes module, bool dl_openable) -> void
19
+ def adapter: (String name, bytes module) -> void
20
+ def validate: (bool) -> void
21
+ def stack_size: (Integer) -> void
22
+ def stub_missing_functions: (bool) -> void
23
+ def use_built_in_libdl: (bool) -> void
24
+ def encode: () -> bytes
25
+ end
26
+
27
+ class ComponentEncode
28
+ def initialize: () -> void
29
+ def validate: (bool) -> void
30
+ def adapter: (String name, bytes module) -> void
31
+ def module: (bytes module) -> void
32
+ def realloc_via_memory_grow: (bool) -> void
33
+ def import_name_map: (Hash[String, String] map) -> void
34
+ def encode: () -> bytes
12
35
  end
13
36
  end
@@ -0,0 +1,12 @@
1
+ class RubyWasm::FeatureSet
2
+ @features: Hash[Symbol, bool]
3
+
4
+ def initialize: (Hash[Symbol, bool]) -> void
5
+
6
+ FEATURES: Hash[Symbol, String]
7
+
8
+ def self.derive_from_env: () -> RubyWasm::FeatureSet
9
+
10
+ def support_dynamic_linking?: () -> bool
11
+ def support_component_model?: () -> bool
12
+ end
@@ -1,11 +1,39 @@
1
1
 
2
2
  class RubyWasm::Packager
3
+ type build_source_github = {
4
+ type: "github",
5
+ repo: String,
6
+ rev: String,
7
+ }
8
+ type build_source_tarball = {
9
+ type: "tarball",
10
+ url: String,
11
+ }
12
+ type build_source_local = {
13
+ type: "local",
14
+ path: String,
15
+ }
16
+ type build_source = (build_source_github | build_source_tarball | build_source_local) & {
17
+ name: string,
18
+ patches: Array[String],
19
+ }
20
+
21
+ type build_config = {
22
+ target: String,
23
+ src: RubyWasm::Packager::build_source,
24
+ default_exts: String,
25
+ suffix: String,
26
+ }
27
+
28
+ type bytes = String
29
+
3
30
  @definition: untyped
4
- @config: Hash[untyped, untyped]
31
+ @config: build_config
32
+ @features: RubyWasm::FeatureSet
5
33
 
6
- def initialize: (untyped?, Hash[untyped, untyped]?) -> void
34
+ def initialize: (string root, build_config?, untyped? definition, features: RubyWasm::FeatureSet) -> void
7
35
 
8
- def package: (RubyWasm::BuildExecutor, string dest_dir, untyped options) -> Array[Integer]
36
+ def package: (RubyWasm::BuildExecutor, string dest_dir, untyped options) -> bytes
9
37
 
10
38
  @ruby_core_build: RubyWasm::Packager::Core?
11
39
  def ruby_core_build: () -> RubyWasm::Packager::Core
@@ -13,13 +41,10 @@ class RubyWasm::Packager
13
41
  EXCLUDED_GEMS: Array[string]
14
42
 
15
43
  def specs: () -> Array[untyped]
16
- def support_dynamic_linking?: () -> bool
44
+ def features: () -> RubyWasm::FeatureSet
17
45
 
18
46
  def root: () -> string
19
47
 
20
- type build_source = Hash[Symbol, (String | Array[String])]
21
- def self.build_source_aliases: (string root) -> Hash[string, build_source]
22
-
23
48
  ALL_DEFAULT_EXTS: string
24
49
 
25
50
  def build_options: () -> Hash[Symbol, untyped]
@@ -31,6 +56,7 @@ class RubyWasm::Packager
31
56
  @packager: RubyWasm::Packager
32
57
  def initialize: (RubyWasm::Packager) -> void
33
58
  def build: (RubyWasm::BuildExecutor, untyped options) -> String
59
+ def build_and_link_exts: (RubyWasm::BuildExecutor, bytes module_bytes) -> bytes
34
60
 
35
61
  extend Forwardable
36
62
 
@@ -46,9 +72,16 @@ class RubyWasm::Packager
46
72
  def initialize: (RubyWasm::Packager) -> void
47
73
  def build: (RubyWasm::BuildExecutor, untyped options) -> String
48
74
  def specs_with_extensions: () -> Array[[untyped, Array[string]]]
75
+ def build_and_link_exts: (RubyWasm::BuildExecutor, bytes module_bytes) -> bytes
49
76
  end
50
77
 
51
78
  class DynamicLinking < RubyWasm::Packager::Core::BuildStrategy
79
+ @build: RubyWasm::Build
80
+ def derive_build: () -> RubyWasm::Build
81
+ def build_exts: (RubyWasm::BuildExecutor, RubyWasm::Build) -> void
82
+ def name: () -> string
83
+
84
+ private def link_exts: (RubyWasm::BuildExecutor, RubyWasm::Build) -> bytes
52
85
  end
53
86
 
54
87
  class StaticLinking < RubyWasm::Packager::Core::BuildStrategy
@@ -88,4 +121,8 @@ class RubyWasm::Packager
88
121
  def ruby_version: () -> String
89
122
  def rubyarchdir: () -> String
90
123
  end
124
+
125
+ module ComponentAdapter
126
+ def self.wasi_snapshot_preview1: (String exec_model) -> String
127
+ end
91
128
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_wasm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.2
5
5
  platform: x64-mingw-ucrt
6
6
  authors:
7
7
  - Yuta Saito
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-28 00:00:00.000000000 Z
11
+ date: 2024-05-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby to WebAssembly toolkit. This gem takes Ruby code and Gemfile, and
14
14
  packages them with Ruby runtime into a WebAssembly binary.
@@ -28,10 +28,6 @@ files:
28
28
  - Rakefile
29
29
  - Steepfile
30
30
  - benchmarks/vm_deep_call.rb
31
- - builders/wasm32-unknown-emscripten/Dockerfile
32
- - builders/wasm32-unknown-emscripten/entrypoint.sh
33
- - builders/wasm32-unknown-wasi/Dockerfile
34
- - builders/wasm32-unknown-wasi/entrypoint.sh
35
31
  - docs/api.md
36
32
  - docs/cheat_sheet.md
37
33
  - docs/faq.md
@@ -42,6 +38,7 @@ files:
42
38
  - lib/ruby_wasm.rb
43
39
  - lib/ruby_wasm/3.1/ruby_wasm.so
44
40
  - lib/ruby_wasm/3.2/ruby_wasm.so
41
+ - lib/ruby_wasm/3.3/ruby_wasm.so
45
42
  - lib/ruby_wasm/build.rb
46
43
  - lib/ruby_wasm/build/build_params.rb
47
44
  - lib/ruby_wasm/build/downloader.rb
@@ -55,10 +52,15 @@ files:
55
52
  - lib/ruby_wasm/build/product/ruby_source.rb
56
53
  - lib/ruby_wasm/build/product/wasi_vfs.rb
57
54
  - lib/ruby_wasm/build/product/zlib.rb
55
+ - lib/ruby_wasm/build/target.rb
58
56
  - lib/ruby_wasm/build/toolchain.rb
59
57
  - lib/ruby_wasm/build/toolchain/wit_bindgen.rb
60
58
  - lib/ruby_wasm/cli.rb
59
+ - lib/ruby_wasm/feature_set.rb
61
60
  - lib/ruby_wasm/packager.rb
61
+ - lib/ruby_wasm/packager/component_adapter.rb
62
+ - lib/ruby_wasm/packager/component_adapter/wasi_snapshot_preview1.command.wasm
63
+ - lib/ruby_wasm/packager/component_adapter/wasi_snapshot_preview1.reactor.wasm
62
64
  - lib/ruby_wasm/packager/core.rb
63
65
  - lib/ruby_wasm/packager/file_system.rb
64
66
  - lib/ruby_wasm/rake_task.rb
@@ -77,6 +79,7 @@ files:
77
79
  - sig/ruby_wasm/build.rbs
78
80
  - sig/ruby_wasm/cli.rbs
79
81
  - sig/ruby_wasm/ext.rbs
82
+ - sig/ruby_wasm/feature_set.rbs
80
83
  - sig/ruby_wasm/packager.rbs
81
84
  - sig/ruby_wasm/util.rbs
82
85
  - tools/clang-format-diff.sh
@@ -99,7 +102,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
102
  version: '3.1'
100
103
  - - "<"
101
104
  - !ruby/object:Gem::Version
102
- version: 3.3.dev
105
+ version: 3.4.dev
103
106
  required_rubygems_version: !ruby/object:Gem::Requirement
104
107
  requirements:
105
108
  - - ">="