ruby_wasm 2.6.0-x86_64-darwin → 2.6.1-x86_64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +4 -2
- data/README.md +1 -1
- data/docs/cheat_sheet.md +8 -8
- data/ext/ruby_wasm/README.md +3 -0
- data/lib/ruby_wasm/3.1/ruby_wasm.bundle +0 -0
- data/lib/ruby_wasm/3.2/ruby_wasm.bundle +0 -0
- data/lib/ruby_wasm/3.3/ruby_wasm.bundle +0 -0
- data/lib/ruby_wasm/build/product/crossruby.rb +5 -5
- data/lib/ruby_wasm/build/toolchain/wit_bindgen.rb +1 -1
- data/lib/ruby_wasm/cli.rb +13 -1
- data/lib/ruby_wasm/packager/core.rb +58 -24
- data/lib/ruby_wasm/packager/file_system.rb +17 -0
- data/lib/ruby_wasm/packager.rb +11 -3
- data/lib/ruby_wasm/version.rb +1 -1
- data/package-lock.json +7 -6
- data/package.json +2 -1
- data/sig/ruby_wasm/build.rbs +1 -1
- data/sig/ruby_wasm/cli.rbs +2 -0
- data/sig/ruby_wasm/packager.rbs +9 -4
- metadata +4 -5
- data/ext/.gitignore +0 -2
- data/ext/README.md +0 -11
- /data/{ext → lib/ruby_wasm/build/product/crossruby}/extinit.c.erb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03b91bccc370d225e9bb781d00ae39f434e44f225cd2513cac8c9131c01654e0
|
4
|
+
data.tar.gz: 2c9b9c9071994734a49b268aaa43b08b4ef16be7bd8f99640685f7fd817e10e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 044e4506b6818553a9dc618c0831ae38fc717c10f5bf9c70e0899c178016d11e60f455a801a5442177bd5738555780d9a52e843db0336908387e675f78d69935
|
7
|
+
data.tar.gz: 8c7dcebeeaa6d37721e0e8aba2539c5ba5d9827334bf792262442d6b434549d2f6e3be52d34ff21799d8393b4d8b5810616b55a85c5275d7e0dd59430f06a4f9
|
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.
|
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.
|
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.
|
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.
|
55
|
-
const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.
|
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.
|
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.
|
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.
|
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.
|
147
|
-
const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.
|
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
|
|
Binary file
|
Binary file
|
Binary file
|
@@ -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
|
-
|
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
|
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[:
|
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, :
|
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
|
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
|
108
|
+
def build_gem_exts(executor, gem_home)
|
97
109
|
build = derive_build
|
98
|
-
self.
|
99
|
-
self.link_exts(executor, build)
|
110
|
+
self._build_gem_exts(executor, build, gem_home)
|
100
111
|
end
|
101
112
|
|
102
|
-
def
|
103
|
-
|
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
|
-
|
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(
|
138
|
+
wasi_adapter = RubyWasm::Packager::ComponentAdapter.wasi_snapshot_preview1(wasi_exec_model)
|
123
139
|
adapters = [wasi_adapter]
|
124
|
-
dl_openable_libs =
|
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(
|
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 |
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
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
|
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
|
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(
|
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(
|
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}"
|
data/lib/ruby_wasm/packager.rb
CHANGED
@@ -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
|
-
|
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.
|
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
|
data/lib/ruby_wasm/version.rb
CHANGED
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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
data/sig/ruby_wasm/build.rbs
CHANGED
@@ -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
|
|
data/sig/ruby_wasm/cli.rbs
CHANGED
@@ -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
|
data/sig/ruby_wasm/packager.rbs
CHANGED
@@ -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
|
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
|
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
|
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,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_wasm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.1
|
5
5
|
platform: x86_64-darwin
|
6
6
|
authors:
|
7
7
|
- Yuta Saito
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-22 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.
|
@@ -32,9 +32,7 @@ files:
|
|
32
32
|
- docs/cheat_sheet.md
|
33
33
|
- docs/faq.md
|
34
34
|
- exe/rbwasm
|
35
|
-
- ext
|
36
|
-
- ext/README.md
|
37
|
-
- ext/extinit.c.erb
|
35
|
+
- ext/ruby_wasm/README.md
|
38
36
|
- lib/ruby_wasm.rb
|
39
37
|
- lib/ruby_wasm/3.1/ruby_wasm.bundle
|
40
38
|
- lib/ruby_wasm/3.2/ruby_wasm.bundle
|
@@ -46,6 +44,7 @@ files:
|
|
46
44
|
- lib/ruby_wasm/build/product.rb
|
47
45
|
- lib/ruby_wasm/build/product/baseruby.rb
|
48
46
|
- lib/ruby_wasm/build/product/crossruby.rb
|
47
|
+
- lib/ruby_wasm/build/product/crossruby/extinit.c.erb
|
49
48
|
- lib/ruby_wasm/build/product/libyaml.rb
|
50
49
|
- lib/ruby_wasm/build/product/openssl.rb
|
51
50
|
- lib/ruby_wasm/build/product/product.rb
|
data/ext/.gitignore
DELETED
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.
|
File without changes
|