ruby_wasm 2.5.1 → 2.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +1 -1
- data/README.md +1 -1
- data/Rakefile +2 -1
- data/docs/cheat_sheet.md +8 -8
- data/lib/ruby_wasm/build/product/crossruby.rb +6 -2
- data/lib/ruby_wasm/build/toolchain/wit_bindgen.rb +2 -2
- data/lib/ruby_wasm/cli.rb +2 -2
- data/lib/ruby_wasm/packager/core.rb +14 -8
- data/lib/ruby_wasm/packager.rb +4 -2
- data/lib/ruby_wasm/version.rb +1 -1
- data/package-lock.json +5519 -7240
- data/package.json +2 -2
- data/rakelib/check.rake +23 -10
- data/rakelib/packaging.rake +18 -3
- data/sig/ruby_wasm/build.rbs +2 -1
- data/sig/ruby_wasm/packager.rbs +2 -2
- metadata +3 -6
data/package.json
CHANGED
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
|
8
|
+
task legacy_bindgen_c: :install_wit_bindgen do
|
7
9
|
wits = [
|
8
|
-
%w[packages/gems/js/ext/
|
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 "#{
|
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
|
19
|
+
task legacy_bindgen_js: :install_wit_bindgen do
|
18
20
|
sh *[
|
19
|
-
|
21
|
+
legacy_wit_bindgen.bin_path,
|
20
22
|
"host",
|
21
23
|
"js",
|
22
24
|
"--import",
|
23
|
-
"packages/gems/js/ext/
|
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
|
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/packaging.rake
CHANGED
@@ -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" =>
|
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
|
-
|
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
|
-
|
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
|
@@ -72,6 +75,18 @@ namespace :npm do
|
|
72
75
|
*build_command,
|
73
76
|
"-o",
|
74
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
|
75
90
|
end
|
76
91
|
sh wasi_sdk.wasm_opt,
|
77
92
|
"--strip-debug",
|
data/sig/ruby_wasm/build.rbs
CHANGED
@@ -158,9 +158,10 @@ module RubyWasm
|
|
158
158
|
@toolchain: Toolchain
|
159
159
|
@srcdir: String
|
160
160
|
@ext_relative_path: String
|
161
|
+
@features: RubyWasm::FeatureSet
|
161
162
|
|
162
163
|
attr_reader name: String
|
163
|
-
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
|
164
165
|
def product_build_dir: (CrossRubyProduct crossruby) -> String
|
165
166
|
def linklist: (CrossRubyProduct crossruby) -> String
|
166
167
|
def metadata_json: (CrossRubyProduct crossruby) -> String
|
data/sig/ruby_wasm/packager.rbs
CHANGED
@@ -56,7 +56,7 @@ class RubyWasm::Packager
|
|
56
56
|
@packager: RubyWasm::Packager
|
57
57
|
def initialize: (RubyWasm::Packager) -> void
|
58
58
|
def build: (RubyWasm::BuildExecutor, untyped options) -> String
|
59
|
-
def build_and_link_exts: (RubyWasm::BuildExecutor) -> bytes
|
59
|
+
def build_and_link_exts: (RubyWasm::BuildExecutor, bytes module_bytes) -> bytes
|
60
60
|
|
61
61
|
extend Forwardable
|
62
62
|
|
@@ -72,7 +72,7 @@ class RubyWasm::Packager
|
|
72
72
|
def initialize: (RubyWasm::Packager) -> void
|
73
73
|
def build: (RubyWasm::BuildExecutor, untyped options) -> String
|
74
74
|
def specs_with_extensions: () -> Array[[untyped, Array[string]]]
|
75
|
-
def build_and_link_exts: (RubyWasm::BuildExecutor) -> bytes
|
75
|
+
def build_and_link_exts: (RubyWasm::BuildExecutor, bytes module_bytes) -> bytes
|
76
76
|
end
|
77
77
|
|
78
78
|
class DynamicLinking < RubyWasm::Packager::Core::BuildStrategy
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_wasm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuta Saito
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date: 2024-04
|
10
|
+
date: 2024-05-04 00:00:00.000000000 Z
|
12
11
|
dependencies: []
|
13
12
|
description: Ruby to WebAssembly toolkit. This gem takes Ruby code and Gemfile, and
|
14
13
|
packages them with Ruby runtime into a WebAssembly binary.
|
@@ -94,7 +93,6 @@ licenses:
|
|
94
93
|
metadata:
|
95
94
|
homepage_uri: https://github.com/ruby/ruby.wasm
|
96
95
|
source_code_uri: https://github.com/ruby/ruby.wasm
|
97
|
-
post_install_message:
|
98
96
|
rdoc_options: []
|
99
97
|
require_paths:
|
100
98
|
- lib
|
@@ -109,8 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
107
|
- !ruby/object:Gem::Version
|
110
108
|
version: '0'
|
111
109
|
requirements: []
|
112
|
-
rubygems_version: 3.
|
113
|
-
signing_key:
|
110
|
+
rubygems_version: 3.6.0.dev
|
114
111
|
specification_version: 4
|
115
112
|
summary: Ruby to WebAssembly toolkit
|
116
113
|
test_files: []
|