ruby_wasm 2.6.0 → 2.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f509aedcac0dfbe264b9dff6984f1fbd71fbcac4a462783b0a3f8b182410440b
4
- data.tar.gz: 390c1306c8c7b28d8583ebdf9bcdd69ff72d1ad56435923871090dbabb301421
3
+ metadata.gz: 789a2c7d584a188d5fb83f5167988de7416a5d1a7336dc6c2726d6ace612914a
4
+ data.tar.gz: 94e9d7c42fe5971104964f488edaad386636501dc635cfa0ad4adce1cf831217
5
5
  SHA512:
6
- metadata.gz: 1cf577ede9835215d5b8a23936ed515e6e104dba588a52b1bb43127e9e907648d3739c8b452448804266ef955767c12b2a251061e36f61b6f78185e830fad41e
7
- data.tar.gz: eb7cc82ef12d8ca024ce0e24a47b57aea938ad422c76a9f26a41dfc18d35103cb5efa37986850e23b712e494ebc6adad259005ef13e730bc5c2910d5c4ba9dac
6
+ metadata.gz: 85fed1afae6f4570ab566f7ca537069325ed128f2bff17cef5cf0fb76438102204067a39760af06b68edd4b9d03ffea7810b6927c56ea66fd1be5a007f19ba92
7
+ data.tar.gz: aa407c4e3a622cf389e4a5773f655d4a19b23534409afd0451bd74e06fe3801ec7d3183ad35ce9263826ba3c7163b0a49126961c5a65fe2581923c2c88de94df
data/CONTRIBUTING.md CHANGED
@@ -6,9 +6,11 @@ This document describes development setup and pointers for diving into this proj
6
6
  ## Install dependencies
7
7
 
8
8
  ```console
9
- $ git clone https://github.com/ruby/ruby.wasm
9
+ $ git clone https://github.com/ruby/ruby.wasm --recursive
10
10
  $ cd ruby.wasm
11
11
  $ ./bin/setup
12
+ # Just for building vendor/jco (will be removed soon)
13
+ $ rustup target add wasm32-wasi
12
14
  # Compile extension library
13
15
  $ bundle exec rake compile
14
16
  $ rake --tasks
@@ -125,5 +127,5 @@ $ npm install --save @ruby/wasm-wasi@latest
125
127
  # or if you want the nightly snapshot
126
128
  $ npm install --save @ruby/wasm-wasi@next
127
129
  # or you can specify the exact snapshot version
128
- $ npm install --save @ruby/wasm-wasi@2.6.0-2024-05-05-a
130
+ $ npm install --save @ruby/wasm-wasi@2.6.1-2024-05-22-a
129
131
  ```
data/README.md CHANGED
@@ -23,7 +23,7 @@ Create and save `index.html` page with the following contents:
23
23
 
24
24
  ```html
25
25
  <html>
26
- <script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.0/dist/browser.script.iife.js"></script>
26
+ <script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.1/dist/browser.script.iife.js"></script>
27
27
  <script type="text/ruby">
28
28
  require "js"
29
29
 
data/docs/cheat_sheet.md CHANGED
@@ -38,7 +38,7 @@ The easiest way to run Ruby on browser is to use `browser.script.iife.js` script
38
38
 
39
39
  ```html
40
40
  <html>
41
- <script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.0/dist/browser.script.iife.js"></script>
41
+ <script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.1/dist/browser.script.iife.js"></script>
42
42
  <script type="text/ruby">
43
43
  require "js"
44
44
  JS.global[:document].write "Hello, world!"
@@ -51,8 +51,8 @@ If you want to control Ruby VM from JavaScript, you can use `@ruby/wasm-wasi` pa
51
51
  ```html
52
52
  <html>
53
53
  <script type="module">
54
- import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.6.0/dist/browser/+esm";
55
- const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.0/dist/ruby+stdlib.wasm");
54
+ import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.6.1/dist/browser/+esm";
55
+ const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.1/dist/ruby+stdlib.wasm");
56
56
  const module = await WebAssembly.compileStreaming(response);
57
57
  const { vm } = await DefaultRubyVM(module);
58
58
 
@@ -69,11 +69,11 @@ If you want to control Ruby VM from JavaScript, you can use `@ruby/wasm-wasi` pa
69
69
 
70
70
  ```html
71
71
  <html>
72
- <script src="https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.6.0/dist/browser.umd.js"></script>
72
+ <script src="https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.6.1/dist/browser.umd.js"></script>
73
73
  <script>
74
74
  const main = async () => {
75
75
  const { DefaultRubyVM } = window["ruby-wasm-wasi"];
76
- const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.0/dist/ruby+stdlib.wasm");
76
+ const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.1/dist/ruby+stdlib.wasm");
77
77
  const module = await WebAssembly.compileStreaming(response);
78
78
  const { vm } = await DefaultRubyVM(module);
79
79
 
@@ -128,7 +128,7 @@ end
128
128
 
129
129
  ```html
130
130
  <html>
131
- <script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.0/dist/browser.script.iife.js"></script>
131
+ <script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.1/dist/browser.script.iife.js"></script>
132
132
  <script type="text/ruby" data-eval="async">
133
133
  require "js"
134
134
 
@@ -143,8 +143,8 @@ Or using `@ruby/wasm-wasi` package API `RubyVM#evalAsync`:
143
143
  ```html
144
144
  <html>
145
145
  <script type="module">
146
- import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.6.0/dist/browser/+esm";
147
- const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.0/dist/ruby+stdlib.wasm");
146
+ import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.6.1/dist/browser/+esm";
147
+ const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.1/dist/ruby+stdlib.wasm");
148
148
  const module = await WebAssembly.compileStreaming(response);
149
149
  const { vm } = await DefaultRubyVM(module);
150
150
 
@@ -0,0 +1,3 @@
1
+ ## Extension library for `ruby_wasm` gem
2
+
3
+ This library exposes WebAssembly tools and utilities from Rust ecosystem as Ruby API.
@@ -42,7 +42,7 @@ module RubyWasm
42
42
  make_args
43
43
  end
44
44
 
45
- def build(executor, crossruby)
45
+ def build(executor, crossruby, extra_mkargs = [])
46
46
  objdir = product_build_dir crossruby
47
47
  executor.mkdir_p objdir
48
48
  do_extconf executor, crossruby
@@ -54,7 +54,8 @@ module RubyWasm
54
54
  "-C",
55
55
  "#{objdir}",
56
56
  *make_args(crossruby),
57
- build_target
57
+ build_target,
58
+ *extra_mkargs
58
59
  # A ext can provide link args by link.filelist. It contains only built archive file by default.
59
60
  unless File.exist?(linklist(crossruby))
60
61
  executor.write(
@@ -187,7 +188,7 @@ module RubyWasm
187
188
  def build_exts(executor)
188
189
  @user_exts.each do |prod|
189
190
  executor.begin_section prod.class, prod.name, "Building"
190
- prod.build(executor, self)
191
+ prod.build(executor, self, [])
191
192
  executor.end_section prod.class, prod.name
192
193
  end
193
194
  end
@@ -298,8 +299,7 @@ module RubyWasm
298
299
  end
299
300
 
300
301
  def extinit_c_erb
301
- lib_root = File.expand_path("../../../../..", __FILE__)
302
- File.join(lib_root, "ext", "extinit.c.erb")
302
+ File.expand_path("../crossruby/extinit.c.erb", __FILE__)
303
303
  end
304
304
 
305
305
  def baseruby_path
@@ -4,7 +4,7 @@ module RubyWasm
4
4
 
5
5
  def initialize(
6
6
  build_dir:,
7
- revision: "v0.24.0"
7
+ revision: "67e17745a417d07852cc283d1399d210d4d659cc"
8
8
  )
9
9
  @build_dir = build_dir
10
10
  @tool_dir = File.join(@build_dir, "toolchain", "wit-bindgen-#{revision}")
data/lib/ruby_wasm/cli.rb CHANGED
@@ -53,6 +53,8 @@ module RubyWasm
53
53
  target_triplet: "wasm32-unknown-wasip1",
54
54
  profile: "full",
55
55
  stdlib: true,
56
+ without_stdlib_components: [],
57
+ dest_dir: nil,
56
58
  disable_gems: false,
57
59
  gemfile: nil,
58
60
  patches: [],
@@ -104,10 +106,18 @@ module RubyWasm
104
106
  options[:stdlib] = stdlib
105
107
  end
106
108
 
109
+ opts.on("--without-stdlib COMPONENT", "Exclude stdlib component") do |component|
110
+ options[:without_stdlib_components] << component
111
+ end
112
+
107
113
  opts.on("--disable-gems", "Disable gems") do
108
114
  options[:disable_gems] = true
109
115
  end
110
116
 
117
+ opts.on("--dest-dir PATH", "(Experimental) Destination directory") do |path|
118
+ options[:dest_dir] = path
119
+ end
120
+
111
121
  opts.on("-p", "--patch PATCH", "Apply a patch") do |patch|
112
122
  options[:patches] << patch
113
123
  end
@@ -149,7 +159,9 @@ module RubyWasm
149
159
 
150
160
  require "tmpdir"
151
161
 
152
- if options[:save_temps]
162
+ if dest_dir = options[:dest_dir]
163
+ self.do_build(executor, dest_dir, packager, options)
164
+ elsif options[:save_temps]
153
165
  tmpdir = Dir.mktmpdir
154
166
  self.do_build(executor, tmpdir, packager, options)
155
167
  @stderr.puts "Temporary files are saved to #{tmpdir}"
@@ -12,7 +12,7 @@ class RubyWasm::Packager::Core
12
12
 
13
13
  extend Forwardable
14
14
 
15
- def_delegators :build_strategy, :cache_key, :artifact, :build_and_link_exts
15
+ def_delegators :build_strategy, :cache_key, :artifact, :build_gem_exts, :link_gem_exts
16
16
 
17
17
  private
18
18
 
@@ -37,7 +37,11 @@ class RubyWasm::Packager::Core
37
37
  raise NotImplementedError
38
38
  end
39
39
 
40
- def build_and_link_exts(executor, module_bytes)
40
+ def build_gem_exts(executor, gem_home)
41
+ raise NotImplementedError
42
+ end
43
+
44
+ def link_gem_exts(executor, ruby_root, gem_home, module_bytes)
41
45
  raise NotImplementedError
42
46
  end
43
47
 
@@ -55,6 +59,14 @@ class RubyWasm::Packager::Core
55
59
  end
56
60
  end
57
61
 
62
+ def wasi_exec_model
63
+ # TODO: Detect WASI exec-model from binary exports (_start or _initialize)
64
+ use_js_gem = @packager.specs.any? do |spec|
65
+ spec.name == "js"
66
+ end
67
+ use_js_gem ? "reactor" : "command"
68
+ end
69
+
58
70
  def cache_key(digest)
59
71
  raise NotImplementedError
60
72
  end
@@ -93,20 +105,24 @@ class RubyWasm::Packager::Core
93
105
  build.crossruby.artifact
94
106
  end
95
107
 
96
- def build_and_link_exts(executor, module_bytes)
108
+ def build_gem_exts(executor, gem_home)
97
109
  build = derive_build
98
- self.build_exts(executor, build)
99
- self.link_exts(executor, build)
110
+ self._build_gem_exts(executor, build, gem_home)
100
111
  end
101
112
 
102
- def link_exts(executor, build)
103
- ruby_root = build.crossruby.dest_dir
113
+ def link_gem_exts(executor, ruby_root, gem_home, module_bytes)
114
+ build = derive_build
115
+ self._link_gem_exts(executor, build, ruby_root, gem_home, module_bytes)
116
+ end
104
117
 
105
- libraries = [File.join(ruby_root, "usr", "local", "bin", "ruby")]
118
+ def _link_gem_exts(executor, build, ruby_root, gem_home, module_bytes)
119
+ libraries = []
106
120
 
107
121
  # TODO: Should be computed from dyinfo of ruby binary
108
122
  wasi_libc_shared_libs = [
109
123
  "libc.so",
124
+ "libc++.so",
125
+ "libc++abi.so",
110
126
  "libwasi-emulated-getpid.so",
111
127
  "libwasi-emulated-mman.so",
112
128
  "libwasi-emulated-process-clocks.so",
@@ -119,13 +135,18 @@ class RubyWasm::Packager::Core
119
135
  wasi_sdk_path = toolchain.wasi_sdk_path
120
136
  libraries << File.join(wasi_sdk_path, "share/wasi-sysroot/lib/wasm32-wasi", lib)
121
137
  end
122
- wasi_adapter = RubyWasm::Packager::ComponentAdapter.wasi_snapshot_preview1("command")
138
+ wasi_adapter = RubyWasm::Packager::ComponentAdapter.wasi_snapshot_preview1(wasi_exec_model)
123
139
  adapters = [wasi_adapter]
124
- dl_openable_libs = Dir.glob(File.join(ruby_root, "usr", "local", "lib", "ruby", "**", "*.so"))
140
+ dl_openable_libs = []
141
+ dl_openable_libs << [File.dirname(ruby_root), Dir.glob(File.join(ruby_root, "lib", "ruby", "**", "*.so"))]
142
+ dl_openable_libs << [gem_home, Dir.glob(File.join(gem_home, "**", "*.so"))]
143
+
125
144
  linker = RubyWasmExt::ComponentLink.new
126
145
  linker.use_built_in_libdl(true)
127
146
  linker.stub_missing_functions(false)
128
- linker.validate(true)
147
+ linker.validate(ENV["RUBYWASM_SKIP_LINKER_VALIDATION"] != "1")
148
+
149
+ linker.library("ruby", module_bytes, false)
129
150
 
130
151
  libraries.each do |lib|
131
152
  # Non-DL openable libraries should be referenced as base name
@@ -135,12 +156,14 @@ class RubyWasm::Packager::Core
135
156
  linker.library(lib_name, module_bytes, false)
136
157
  end
137
158
 
138
- dl_openable_libs.each do |lib|
139
- # DL openable lib_name should be a relative path from ruby_root
140
- lib_name = "/" + Pathname.new(lib).relative_path_from(Pathname.new(ruby_root)).to_s
141
- module_bytes = File.binread(lib)
142
- RubyWasm.logger.info "Linking #{lib_name} (#{module_bytes.size} bytes)"
143
- linker.library(lib_name, module_bytes, true)
159
+ dl_openable_libs.each do |root, libs|
160
+ libs.each do |lib|
161
+ # DL openable lib_name should be a relative path from ruby_root
162
+ lib_name = "/" + Pathname.new(lib).relative_path_from(Pathname.new(File.dirname(root))).to_s
163
+ module_bytes = File.binread(lib)
164
+ RubyWasm.logger.info "Linking #{lib_name} (#{module_bytes.size} bytes)"
165
+ linker.library(lib_name, module_bytes, true)
166
+ end
144
167
  end
145
168
 
146
169
  adapters.each do |adapter|
@@ -148,29 +171,36 @@ class RubyWasm::Packager::Core
148
171
  # e.g. wasi_snapshot_preview1.command.wasm -> wasi_snapshot_preview1
149
172
  adapter_name = adapter_name.split(".")[0]
150
173
  module_bytes = File.binread(adapter)
174
+ RubyWasm.logger.info "Linking adapter #{adapter_name}=#{adapter} (#{module_bytes.size} bytes)"
151
175
  linker.adapter(adapter_name, module_bytes)
152
176
  end
153
177
  return linker.encode()
154
178
  end
155
179
 
156
- def build_exts(executor, build)
180
+ def _build_gem_exts(executor, build, gem_home)
157
181
  exts = specs_with_extensions.flat_map do |spec, exts|
158
182
  exts.map do |ext|
159
183
  ext_feature = File.dirname(ext) # e.g. "ext/cgi/escape"
160
184
  ext_srcdir = File.join(spec.full_gem_path, ext_feature)
161
185
  ext_relative_path = File.join(spec.full_name, ext_feature)
162
- RubyWasm::CrossRubyExtProduct.new(
186
+ prod = RubyWasm::CrossRubyExtProduct.new(
163
187
  ext_srcdir,
164
188
  build.toolchain,
165
189
  features: @packager.features,
166
190
  ext_relative_path: ext_relative_path
167
191
  )
192
+ [prod, spec]
168
193
  end
169
194
  end
170
195
 
171
- exts.each do |prod|
196
+ exts.each do |prod, spec|
197
+ libdir = File.join(gem_home, "gems", spec.full_name, spec.raw_require_paths.first)
198
+ extra_mkargs = [
199
+ "sitearchdir=#{libdir}",
200
+ "sitelibdir=#{libdir}",
201
+ ]
172
202
  executor.begin_section prod.class, prod.name, "Building"
173
- prod.build(executor, build.crossruby)
203
+ prod.build(executor, build.crossruby, extra_mkargs)
174
204
  executor.end_section prod.class, prod.name
175
205
  end
176
206
  end
@@ -301,15 +331,19 @@ class RubyWasm::Packager::Core
301
331
  build
302
332
  end
303
333
 
304
- def build_and_link_exts(executor, module_bytes)
334
+ def build_gem_exts(executor, gem_home)
335
+ # No-op because we already built extensions as part of the Ruby build
336
+ end
337
+
338
+ def link_gem_exts(executor, ruby_root, gem_home, module_bytes)
305
339
  return module_bytes unless @packager.features.support_component_model?
306
340
 
307
341
  linker = RubyWasmExt::ComponentEncode.new
308
- linker.validate(true)
342
+ linker.validate(ENV["RUBYWASM_SKIP_LINKER_VALIDATION"] != "1")
309
343
  linker.module(module_bytes)
310
344
  linker.adapter(
311
345
  "wasi_snapshot_preview1",
312
- File.binread(RubyWasm::Packager::ComponentAdapter.wasi_snapshot_preview1("reactor"))
346
+ File.binread(RubyWasm::Packager::ComponentAdapter.wasi_snapshot_preview1(wasi_exec_model))
313
347
  )
314
348
 
315
349
  linker.encode()
@@ -38,6 +38,23 @@ class RubyWasm::Packager::FileSystem
38
38
  File.write(rbconfig, rbconfig_contents)
39
39
  end
40
40
 
41
+ def remove_stdlib_component(executor, component)
42
+ RubyWasm.logger.info "Removing stdlib component: #{component}"
43
+ case component
44
+ when "enc"
45
+ # Remove all encodings except for encdb.so and transdb.so
46
+ enc_dir = File.join(@ruby_root, "lib", "ruby", ruby_version, "wasm32-wasi", "enc")
47
+ puts File.join(enc_dir, "**/*.so")
48
+ Dir.glob(File.join(enc_dir, "**/*.so")).each do |entry|
49
+ next if entry.end_with?("encdb.so", "transdb.so")
50
+ RubyWasm.logger.debug "Removing stdlib encoding: #{entry}"
51
+ executor.rm_rf entry
52
+ end
53
+ else
54
+ raise "Unknown stdlib component: #{component}"
55
+ end
56
+ end
57
+
41
58
  def package_gems
42
59
  @packager.specs.each do |spec|
43
60
  RubyWasm.logger.info "Packaging gem: #{spec.full_name}"
@@ -32,11 +32,19 @@ class RubyWasm::Packager
32
32
 
33
33
  wasm_bytes = File.binread(File.join(fs.ruby_root, "bin", "ruby"))
34
34
 
35
+ ruby_core.build_gem_exts(executor, fs.bundle_dir)
36
+
35
37
  fs.package_gems
36
38
  fs.remove_non_runtime_files(executor)
37
- fs.remove_stdlib(executor) unless options[:stdlib]
39
+ if options[:stdlib]
40
+ options[:without_stdlib_components].each do |component|
41
+ fs.remove_stdlib_component(executor, component)
42
+ end
43
+ else
44
+ fs.remove_stdlib(executor)
45
+ end
38
46
 
39
- if full_build_options[:target] == "wasm32-unknown-wasip1"
47
+ if full_build_options[:target] == "wasm32-unknown-wasip1" && !features.support_dynamic_linking?
40
48
  # wasi-vfs supports only WASI target
41
49
  wasi_vfs = RubyWasmExt::WasiVfs.new
42
50
  wasi_vfs.map_dir("/bundle", fs.bundle_dir)
@@ -44,7 +52,7 @@ class RubyWasm::Packager
44
52
 
45
53
  wasm_bytes = wasi_vfs.pack(wasm_bytes)
46
54
  end
47
- wasm_bytes = ruby_core.build_and_link_exts(executor, wasm_bytes)
55
+ wasm_bytes = ruby_core.link_gem_exts(executor, fs.ruby_root, fs.bundle_dir, wasm_bytes)
48
56
 
49
57
  wasm_bytes = RubyWasmExt.preinitialize(wasm_bytes) if options[:optimize]
50
58
  wasm_bytes
@@ -1,3 +1,3 @@
1
1
  module RubyWasm
2
- VERSION = "2.6.0"
2
+ VERSION = "2.6.1"
3
3
  end
data/package-lock.json CHANGED
@@ -9,6 +9,7 @@
9
9
  "packages/npm-packages/*"
10
10
  ],
11
11
  "devDependencies": {
12
+ "@bytecodealliance/jco": "./vendor/jco",
12
13
  "@playwright/test": "^1.43.1",
13
14
  "@rollup/plugin-json": "^6.1.0",
14
15
  "rollup": "^4.17.2"
@@ -4783,7 +4784,7 @@
4783
4784
  },
4784
4785
  "packages/npm-packages/ruby-3.2-wasm-wasi": {
4785
4786
  "name": "@ruby/3.2-wasm-wasi",
4786
- "version": "2.6.0",
4787
+ "version": "2.6.1",
4787
4788
  "license": "MIT",
4788
4789
  "dependencies": {
4789
4790
  "@ruby/wasm-wasi": "^2.0.0"
@@ -4791,7 +4792,7 @@
4791
4792
  },
4792
4793
  "packages/npm-packages/ruby-3.3-wasm-wasi": {
4793
4794
  "name": "@ruby/3.3-wasm-wasi",
4794
- "version": "2.6.0",
4795
+ "version": "2.6.1",
4795
4796
  "license": "MIT",
4796
4797
  "dependencies": {
4797
4798
  "@ruby/wasm-wasi": "^2.0.0"
@@ -4799,12 +4800,12 @@
4799
4800
  },
4800
4801
  "packages/npm-packages/ruby-head-wasm-emscripten": {
4801
4802
  "name": "@ruby/head-wasm-emscripten",
4802
- "version": "2.6.0",
4803
+ "version": "2.6.1",
4803
4804
  "license": "MIT"
4804
4805
  },
4805
4806
  "packages/npm-packages/ruby-head-wasm-wasi": {
4806
4807
  "name": "@ruby/head-wasm-wasi",
4807
- "version": "2.6.0",
4808
+ "version": "2.6.1",
4808
4809
  "license": "MIT",
4809
4810
  "dependencies": {
4810
4811
  "@ruby/wasm-wasi": "^2.0.0"
@@ -4820,7 +4821,7 @@
4820
4821
  },
4821
4822
  "packages/npm-packages/ruby-wasm-wasi": {
4822
4823
  "name": "@ruby/wasm-wasi",
4823
- "version": "2.6.0",
4824
+ "version": "2.6.1",
4824
4825
  "license": "MIT",
4825
4826
  "dependencies": {
4826
4827
  "tslib": "^2.6.1"
@@ -4838,7 +4839,7 @@
4838
4839
  },
4839
4840
  "vendor/jco": {
4840
4841
  "name": "@bytecodealliance/jco",
4841
- "version": "1.2.1",
4842
+ "version": "1.2.4",
4842
4843
  "dev": true,
4843
4844
  "license": "(Apache-2.0 WITH LLVM-exception)",
4844
4845
  "workspaces": [
data/package.json CHANGED
@@ -7,6 +7,7 @@
7
7
  "devDependencies": {
8
8
  "@playwright/test": "^1.43.1",
9
9
  "@rollup/plugin-json": "^6.1.0",
10
- "rollup": "^4.17.2"
10
+ "rollup": "^4.17.2",
11
+ "@bytecodealliance/jco": "./vendor/jco"
11
12
  }
12
13
  }
@@ -168,7 +168,7 @@ module RubyWasm
168
168
  def feature_name: (CrossRubyProduct crossruby) -> String
169
169
 
170
170
  def make_args: (CrossRubyProduct crossruby) -> Array[String]
171
- def build: (BuildExecutor executor, CrossRubyProduct crossruby) -> void
171
+ def build: (BuildExecutor executor, CrossRubyProduct crossruby, Array[String] extra_mkargs) -> void
172
172
  def do_extconf: (BuildExecutor executor, CrossRubyProduct crossruby) -> void
173
173
  def do_install_rb: (BuildExecutor executor, CrossRubyProduct crossruby) -> void
174
174
 
@@ -14,10 +14,12 @@ module RubyWasm
14
14
  target_triplet: String,
15
15
  profile: String,
16
16
  stdlib: bool,
17
+ without_stdlib_components: Array[String],
17
18
  disable_gems: bool,
18
19
  gemfile: String?,
19
20
  patches: Array[String],
20
21
  format: String,
22
+ dest_dir: String,
21
23
  }
22
24
 
23
25
  DEFAULT_RUBIES_DIR: string
@@ -23,6 +23,7 @@ class RubyWasm::Packager
23
23
  src: RubyWasm::Packager::build_source,
24
24
  default_exts: String,
25
25
  suffix: String,
26
+ gem_home: String?,
26
27
  }
27
28
 
28
29
  type bytes = String
@@ -56,7 +57,8 @@ class RubyWasm::Packager
56
57
  @packager: RubyWasm::Packager
57
58
  def initialize: (RubyWasm::Packager) -> void
58
59
  def build: (RubyWasm::BuildExecutor, untyped options) -> String
59
- def build_and_link_exts: (RubyWasm::BuildExecutor, bytes module_bytes) -> bytes
60
+ def build_gem_exts: (RubyWasm::BuildExecutor, string gem_home) -> void
61
+ def link_gem_exts: (RubyWasm::BuildExecutor, string ruby_root, string gem_home, bytes module_bytes) -> bytes
60
62
 
61
63
  extend Forwardable
62
64
 
@@ -72,16 +74,18 @@ class RubyWasm::Packager
72
74
  def initialize: (RubyWasm::Packager) -> void
73
75
  def build: (RubyWasm::BuildExecutor, untyped options) -> String
74
76
  def specs_with_extensions: () -> Array[[untyped, Array[string]]]
75
- def build_and_link_exts: (RubyWasm::BuildExecutor, bytes module_bytes) -> bytes
77
+ def build_gem_exts: (RubyWasm::BuildExecutor, string gem_home) -> void
78
+ def link_gem_exts: (RubyWasm::BuildExecutor, string ruby_root, string gem_home, bytes module_bytes) -> bytes
79
+ def wasi_exec_model: () -> String
76
80
  end
77
81
 
78
82
  class DynamicLinking < RubyWasm::Packager::Core::BuildStrategy
79
83
  @build: RubyWasm::Build
80
84
  def derive_build: () -> RubyWasm::Build
81
- def build_exts: (RubyWasm::BuildExecutor, RubyWasm::Build) -> void
82
85
  def name: () -> string
83
86
 
84
- private def link_exts: (RubyWasm::BuildExecutor, RubyWasm::Build) -> bytes
87
+ private def _build_gem_exts: (RubyWasm::BuildExecutor, RubyWasm::Build, string gem_home) -> void
88
+ private def _link_gem_exts: (RubyWasm::BuildExecutor, RubyWasm::Build, string ruby_root, string gem_home, bytes module_bytes) -> bytes
85
89
  end
86
90
 
87
91
  class StaticLinking < RubyWasm::Packager::Core::BuildStrategy
@@ -102,6 +106,7 @@ class RubyWasm::Packager
102
106
  def initialize: (string dest_dir, RubyWasm::Packager) -> void
103
107
  def package_ruby_root: (String tarball, RubyWasm::BuildExecutor) -> void
104
108
  def remove_stdlib: (RubyWasm::BuildExecutor) -> void
109
+ def remove_stdlib_component: (RubyWasm::BuildExecutor, string) -> void
105
110
  def package_gems: () -> void
106
111
 
107
112
  def setup_rb_content: () -> String
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_wasm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuta Saito
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 2024-05-05 00:00:00.000000000 Z
11
+ date: 2024-05-22 00:00:00.000000000 Z
11
12
  dependencies: []
12
13
  description: Ruby to WebAssembly toolkit. This gem takes Ruby code and Gemfile, and
13
14
  packages them with Ruby runtime into a WebAssembly binary.
@@ -34,10 +35,8 @@ files:
34
35
  - docs/cheat_sheet.md
35
36
  - docs/faq.md
36
37
  - exe/rbwasm
37
- - ext/.gitignore
38
- - ext/README.md
39
- - ext/extinit.c.erb
40
38
  - ext/ruby_wasm/Cargo.toml
39
+ - ext/ruby_wasm/README.md
41
40
  - ext/ruby_wasm/extconf.rb
42
41
  - ext/ruby_wasm/src/lib.rs
43
42
  - lib/ruby_wasm.rb
@@ -48,6 +47,7 @@ files:
48
47
  - lib/ruby_wasm/build/product.rb
49
48
  - lib/ruby_wasm/build/product/baseruby.rb
50
49
  - lib/ruby_wasm/build/product/crossruby.rb
50
+ - lib/ruby_wasm/build/product/crossruby/extinit.c.erb
51
51
  - lib/ruby_wasm/build/product/libyaml.rb
52
52
  - lib/ruby_wasm/build/product/openssl.rb
53
53
  - lib/ruby_wasm/build/product/product.rb
@@ -93,6 +93,7 @@ licenses:
93
93
  metadata:
94
94
  homepage_uri: https://github.com/ruby/ruby.wasm
95
95
  source_code_uri: https://github.com/ruby/ruby.wasm
96
+ post_install_message:
96
97
  rdoc_options: []
97
98
  require_paths:
98
99
  - lib
@@ -107,7 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
108
  - !ruby/object:Gem::Version
108
109
  version: '0'
109
110
  requirements: []
110
- rubygems_version: 3.6.0.dev
111
+ rubygems_version: 3.5.3
112
+ signing_key:
111
113
  specification_version: 4
112
114
  summary: Ruby to WebAssembly toolkit
113
115
  test_files: []
data/ext/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- *.o
2
- link.filelist
data/ext/README.md DELETED
@@ -1,11 +0,0 @@
1
- # Ruby extensions
2
- `ruby.wasm` uses two C extensions to turn Ruby in to a guest module.
3
- The `js` extension enables Ruby to use JavaScript APIs.
4
- The `witapi` extension exports Ruby's interpreter interface to allow the host to use the Ruby interpreter.
5
- In other words, `js` allows Ruby to talk to Javascript and `witapi` allows a host to talk to Ruby.
6
-
7
- Under each subdirectory, there is a `bindgen/*.wit` file outlining the interfaces for each form of communication.
8
- Specifically, `bindgen/rb-js-abi-host.wit` describes embedder's requirements and `bindgen/rb-js-abi-guest.wit` describes exported API from Ruby interpreter.
9
- The `.c` and `.h` files are autogenerated from [wit-bindgen](https://github.com/bytecodealliance/wit-bindgen#host-runtimes-for-components).
10
- You can read more about it in the [contributing guide](/CONTRIBUTING.md#re-bindgen-from-wit-files).
11
- Note that we currently do not use the latest version of wit-bindgen because of how fast it is changing, with features being changed or even [removed](https://github.com/bytecodealliance/wit-bindgen/pull/346) at times.