ruby_wasm 2.6.2-x86_64-linux → 2.7.0-x86_64-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +8 -6
- data/Gemfile +2 -1
- data/NOTICE +1 -2
- data/README.md +1 -1
- data/Rakefile +9 -3
- data/docs/api.md +1 -1
- data/docs/cheat_sheet.md +8 -8
- data/lib/ruby_wasm/3.1/ruby_wasm.so +0 -0
- data/lib/ruby_wasm/3.2/ruby_wasm.so +0 -0
- data/lib/ruby_wasm/3.3/ruby_wasm.so +0 -0
- data/lib/ruby_wasm/build/product/crossruby.rb +11 -3
- data/lib/ruby_wasm/cli.rb +9 -3
- data/lib/ruby_wasm/packager/core.rb +56 -38
- data/lib/ruby_wasm/packager/file_system.rb +0 -1
- data/lib/ruby_wasm/packager.rb +1 -1
- data/lib/ruby_wasm/version.rb +1 -1
- data/package-lock.json +1515 -7900
- data/package.json +4 -3
- data/rakelib/check.rake +5 -1
- data/rakelib/ci.rake +11 -5
- data/rakelib/doc.rake +11 -14
- data/rakelib/packaging.rake +98 -59
- data/rakelib/version.rake +19 -1
- data/sbom.spdx.json +114 -0
- data/sig/ruby_wasm/build.rbs +1 -0
- metadata +3 -5
- data/tools/clang-format-diff.sh +0 -18
- data/tools/exe/rbminify +0 -12
- data/tools/lib/syntax_tree/minify_ruby.rb +0 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be8d4e05dc667756330aee7ffd43382d66324b570baa6d4714fa72507077dd65
|
4
|
+
data.tar.gz: c7e31318e09717331fd953cab96a4ec16fab47f1e05045b9b308b641b8d9ff34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a668d2b76596b9cfe3eab9c3009139c02e93acdbc66ea291b037fcd87733776efb8a5a1fbb47a6daf2495a04acfc100151294afd872d371488c5f362ddb0772
|
7
|
+
data.tar.gz: ad031cfc0c142bfb56e2aec88db99f5ab72b489b3ac07a382cf6fa5f3101603730e88cfac92c9edfcdd9c53f4bd8ac3ff43ba3cd1136a4c90ae57e328fb1991b
|
data/CONTRIBUTING.md
CHANGED
@@ -9,8 +9,6 @@ This document describes development setup and pointers for diving into this proj
|
|
9
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
|
14
12
|
# Compile extension library
|
15
13
|
$ bundle exec rake compile
|
16
14
|
$ rake --tasks
|
@@ -26,9 +24,9 @@ $ rake build:download_prebuilt
|
|
26
24
|
$ rake build:head-wasm32-unknown-wasip1-full
|
27
25
|
|
28
26
|
# Build npm package
|
29
|
-
$ rake npm:ruby-head-wasm-
|
27
|
+
$ rake npm:ruby-head-wasm-wasip2:build
|
30
28
|
# Test npm package
|
31
|
-
$ rake npm:ruby-head-wasm-
|
29
|
+
$ rake npm:ruby-head-wasm-wasip2:check
|
32
30
|
```
|
33
31
|
|
34
32
|
If you need to re-build Ruby, please clean `./rubies` directory, and run `rake npm:ruby-head-wasm-wasi` again.
|
@@ -111,9 +109,13 @@ $ rake 'bump_version[0.6.0]'
|
|
111
109
|
$ git commit -m"Bump version to 0.6.0"
|
112
110
|
$ git tag 0.6.0
|
113
111
|
$ git push origin 0.6.0
|
114
|
-
|
112
|
+
# After GitHub Actions "Build gems" is done
|
113
|
+
# https://github.com/ruby/ruby.wasm/actions/workflows/build-gems.yml
|
114
|
+
$ gh run download <run-id>
|
115
|
+
$ for pkg in cross-gem/pkg/ruby_wasm-*; do gem push $pkg; done
|
115
116
|
$ gem build && gem push ruby_wasm-*.gem && rm ruby_wasm-*.gem
|
116
117
|
$ (cd packages/gems/js/ && gem build && gem push js-*.gem && rm js-*.gem)
|
118
|
+
$ rake bump_dev_version
|
117
119
|
```
|
118
120
|
|
119
121
|
## Release Channels
|
@@ -127,5 +129,5 @@ $ npm install --save @ruby/wasm-wasi@latest
|
|
127
129
|
# or if you want the nightly snapshot
|
128
130
|
$ npm install --save @ruby/wasm-wasi@next
|
129
131
|
# or you can specify the exact snapshot version
|
130
|
-
$ npm install --save @ruby/wasm-wasi@2.
|
132
|
+
$ npm install --save @ruby/wasm-wasi@2.7.0-2024-11-11-a
|
131
133
|
```
|
data/Gemfile
CHANGED
data/NOTICE
CHANGED
@@ -1264,8 +1264,7 @@ Licensed under the Apache License 2.0 https://www.openssl.org/source/license.htm
|
|
1264
1264
|
https://github.com/kateinoigakukun/wasi-vfs
|
1265
1265
|
|
1266
1266
|
```
|
1267
|
-
|
1268
|
-
Licensed under the MIT License
|
1267
|
+
Licensed under the Apache License v2.0 with LLVM Exceptions
|
1269
1268
|
```
|
1270
1269
|
|
1271
1270
|
---
|
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.
|
26
|
+
<script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.7.0/dist/browser.script.iife.js"></script>
|
27
27
|
<script type="text/ruby">
|
28
28
|
require "js"
|
29
29
|
|
data/Rakefile
CHANGED
@@ -28,20 +28,26 @@ NPM_PACKAGES = [
|
|
28
28
|
{
|
29
29
|
name: "ruby-head-wasm-wasi",
|
30
30
|
ruby_version: "head",
|
31
|
-
gemfile: "packages/npm-packages/ruby-wasm-wasi/Gemfile",
|
31
|
+
gemfile: "packages/npm-packages/ruby-head-wasm-wasi/Gemfile",
|
32
32
|
target: "wasm32-unknown-wasip1",
|
33
|
+
},
|
34
|
+
{
|
35
|
+
name: "ruby-head-wasm-wasip2",
|
36
|
+
ruby_version: "head",
|
37
|
+
gemfile: "packages/npm-packages/ruby-head-wasm-wasip2/Gemfile",
|
38
|
+
target: "wasm32-unknown-wasip2",
|
33
39
|
enable_component_model: true,
|
34
40
|
},
|
35
41
|
{
|
36
42
|
name: "ruby-3.3-wasm-wasi",
|
37
43
|
ruby_version: "3.3",
|
38
|
-
gemfile: "packages/npm-packages/ruby-wasm-wasi/Gemfile",
|
44
|
+
gemfile: "packages/npm-packages/ruby-3.3-wasm-wasi/Gemfile",
|
39
45
|
target: "wasm32-unknown-wasip1"
|
40
46
|
},
|
41
47
|
{
|
42
48
|
name: "ruby-3.2-wasm-wasi",
|
43
49
|
ruby_version: "3.2",
|
44
|
-
gemfile: "packages/npm-packages/ruby-wasm-wasi/Gemfile",
|
50
|
+
gemfile: "packages/npm-packages/ruby-3.2-wasm-wasi/Gemfile",
|
45
51
|
target: "wasm32-unknown-wasip1"
|
46
52
|
},
|
47
53
|
{ name: "ruby-wasm-wasi", target: "wasm32-unknown-wasip1" }
|
data/docs/api.md
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
- [Ruby API](https://ruby.github.io/ruby.wasm/JS.html)
|
2
|
-
- [JavaScript API](https://github.
|
2
|
+
- [JavaScript API](https://ruby.github.io/ruby.wasm/npm/@ruby/wasm-wasi/)
|
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.
|
41
|
+
<script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.7.0/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.
|
55
|
-
const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.
|
54
|
+
import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.7.0/dist/browser/+esm";
|
55
|
+
const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.7.0/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.
|
72
|
+
<script src="https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.7.0/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.
|
76
|
+
const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.7.0/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.
|
131
|
+
<script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.7.0/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.
|
147
|
-
const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.
|
146
|
+
import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.7.0/dist/browser/+esm";
|
147
|
+
const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.7.0/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
|
@@ -71,14 +71,14 @@ module RubyWasm
|
|
71
71
|
return
|
72
72
|
end
|
73
73
|
objdir = product_build_dir crossruby
|
74
|
-
rbconfig_rb =
|
74
|
+
rbconfig_rb = crossruby.rbconfig_rb
|
75
75
|
raise "rbconfig.rb not found" unless rbconfig_rb
|
76
76
|
extconf_args = [
|
77
77
|
"-C", objdir,
|
78
78
|
"#{@srcdir}/extconf.rb",
|
79
79
|
"--target-rbconfig=#{rbconfig_rb}",
|
80
80
|
]
|
81
|
-
extconf_args << "--
|
81
|
+
extconf_args << "--disable-component-model" unless @features.support_component_model?
|
82
82
|
executor.system crossruby.baseruby_path, *extconf_args
|
83
83
|
end
|
84
84
|
|
@@ -111,7 +111,7 @@ module RubyWasm
|
|
111
111
|
"-I#{crossruby.build_dir}",
|
112
112
|
"--",
|
113
113
|
]
|
114
|
-
extconf_args << "--
|
114
|
+
extconf_args << "--disable-component-model" unless @features.support_component_model?
|
115
115
|
# Clear RUBYOPT to avoid loading unrelated bundle setup
|
116
116
|
executor.system crossruby.baseruby_path,
|
117
117
|
*extconf_args,
|
@@ -222,6 +222,10 @@ module RubyWasm
|
|
222
222
|
end
|
223
223
|
install_dir = File.join(build_dir, "install")
|
224
224
|
if !File.exist?(install_dir) || remake || reconfigure
|
225
|
+
unless target.pic?
|
226
|
+
# HACK: force static linking for non-pic target
|
227
|
+
executor.rm_f File.join(build_dir, "ruby")
|
228
|
+
end
|
225
229
|
executor.system "make",
|
226
230
|
"-j#{executor.process_count}",
|
227
231
|
"install",
|
@@ -301,6 +305,10 @@ module RubyWasm
|
|
301
305
|
File.expand_path("../crossruby/extinit.c.erb", __FILE__)
|
302
306
|
end
|
303
307
|
|
308
|
+
def rbconfig_rb
|
309
|
+
Dir.glob(File.join(dest_dir, "usr/local/lib/ruby/*/wasm32-wasi/rbconfig.rb")).first
|
310
|
+
end
|
311
|
+
|
304
312
|
def baseruby_path
|
305
313
|
File.join(@baseruby.install_dir, "bin/ruby")
|
306
314
|
end
|
data/lib/ruby_wasm/cli.rb
CHANGED
@@ -310,7 +310,10 @@ module RubyWasm
|
|
310
310
|
|
311
311
|
def derive_packager(options)
|
312
312
|
__skip__ = definition = nil
|
313
|
-
|
313
|
+
features = RubyWasm::FeatureSet.derive_from_env
|
314
|
+
# The head ruby & dynamic linking uses "bundle" command to build gems instead of in-process integration.
|
315
|
+
use_in_process_gem_building = !(options[:ruby_version] == "head" && features.support_dynamic_linking?)
|
316
|
+
__skip__ = if defined?(Bundler) && !options[:disable_gems] && use_in_process_gem_building
|
314
317
|
begin
|
315
318
|
# Silence Bundler UI if --print-ruby-cache-key is specified not to bother the JSON output.
|
316
319
|
level = options[:print_ruby_cache_key] ? :silent : Bundler.ui.level
|
@@ -321,10 +324,10 @@ module RubyWasm
|
|
321
324
|
Bundler.ui.level = old_level
|
322
325
|
end
|
323
326
|
end
|
324
|
-
RubyWasm.logger.info "Using Gemfile: #{definition.gemfiles}" if definition
|
327
|
+
RubyWasm.logger.info "Using Gemfile: #{definition.gemfiles.map(&:to_s).join(", ")}" if definition
|
325
328
|
RubyWasm::Packager.new(
|
326
329
|
root, build_config(options), definition,
|
327
|
-
features:
|
330
|
+
features: features,
|
328
331
|
)
|
329
332
|
end
|
330
333
|
|
@@ -332,6 +335,9 @@ module RubyWasm
|
|
332
335
|
ruby_core_build = packager.ruby_core_build
|
333
336
|
require "digest"
|
334
337
|
digest = Digest::SHA256.new
|
338
|
+
# The build system key is used to invalidate the cache when the build system is updated.
|
339
|
+
build_system_key = 1
|
340
|
+
digest.update(build_system_key.to_s)
|
335
341
|
ruby_core_build.cache_key(digest)
|
336
342
|
hexdigest = digest.hexdigest
|
337
343
|
require "json"
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "forwardable"
|
2
|
+
require "pathname"
|
2
3
|
|
3
4
|
class RubyWasm::Packager::Core
|
4
5
|
def initialize(packager)
|
@@ -19,7 +20,6 @@ class RubyWasm::Packager::Core
|
|
19
20
|
def build_strategy
|
20
21
|
@build_strategy ||=
|
21
22
|
begin
|
22
|
-
has_exts = @packager.specs.any? { |spec| spec.extensions.any? }
|
23
23
|
if @packager.features.support_dynamic_linking?
|
24
24
|
DynamicLinking.new(@packager)
|
25
25
|
else
|
@@ -59,14 +59,6 @@ class RubyWasm::Packager::Core
|
|
59
59
|
end
|
60
60
|
end
|
61
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
|
-
|
70
62
|
def with_unbundled_env(&block)
|
71
63
|
__skip__ = if defined?(Bundler)
|
72
64
|
Bundler.with_unbundled_env(&block)
|
@@ -138,12 +130,16 @@ class RubyWasm::Packager::Core
|
|
138
130
|
wasi_sdk_path = toolchain.wasi_sdk_path
|
139
131
|
libraries << File.join(wasi_sdk_path, "share/wasi-sysroot/lib/wasm32-wasi", lib)
|
140
132
|
end
|
141
|
-
wasi_adapter = RubyWasm::Packager::ComponentAdapter.wasi_snapshot_preview1(wasi_exec_model)
|
142
|
-
adapters = [wasi_adapter]
|
143
133
|
dl_openable_libs = []
|
144
134
|
dl_openable_libs << [File.dirname(ruby_root), Dir.glob(File.join(ruby_root, "lib", "ruby", "**", "*.so"))]
|
145
135
|
dl_openable_libs << [gem_home, Dir.glob(File.join(gem_home, "**", "*.so"))]
|
146
136
|
|
137
|
+
has_js_so = dl_openable_libs.any? do |root, libs|
|
138
|
+
libs.any? { |lib| lib.end_with?("/js.so") }
|
139
|
+
end
|
140
|
+
wasi_adapter = RubyWasm::Packager::ComponentAdapter.wasi_snapshot_preview1(has_js_so ? "reactor" : "command")
|
141
|
+
adapters = [wasi_adapter]
|
142
|
+
|
147
143
|
linker = RubyWasmExt::ComponentLink.new
|
148
144
|
linker.use_built_in_libdl(true)
|
149
145
|
linker.stub_missing_functions(false)
|
@@ -151,11 +147,13 @@ class RubyWasm::Packager::Core
|
|
151
147
|
|
152
148
|
linker.library("ruby", module_bytes, false)
|
153
149
|
|
150
|
+
RubyWasm.logger.info "Linking Ruby with extensions"
|
151
|
+
|
154
152
|
libraries.each do |lib|
|
155
153
|
# Non-DL openable libraries should be referenced as base name
|
156
154
|
lib_name = File.basename(lib)
|
157
155
|
module_bytes = File.binread(lib)
|
158
|
-
RubyWasm.logger.
|
156
|
+
RubyWasm.logger.debug "Linking #{lib_name} (#{module_bytes.size} bytes)"
|
159
157
|
linker.library(lib_name, module_bytes, false)
|
160
158
|
end
|
161
159
|
|
@@ -164,7 +162,7 @@ class RubyWasm::Packager::Core
|
|
164
162
|
# DL openable lib_name should be a relative path from ruby_root
|
165
163
|
lib_name = "/" + Pathname.new(lib).relative_path_from(Pathname.new(File.dirname(root))).to_s
|
166
164
|
module_bytes = File.binread(lib)
|
167
|
-
RubyWasm.logger.
|
165
|
+
RubyWasm.logger.debug "Linking #{lib_name} (#{module_bytes.size} bytes)"
|
168
166
|
linker.library(lib_name, module_bytes, true)
|
169
167
|
end
|
170
168
|
end
|
@@ -174,7 +172,7 @@ class RubyWasm::Packager::Core
|
|
174
172
|
# e.g. wasi_snapshot_preview1.command.wasm -> wasi_snapshot_preview1
|
175
173
|
adapter_name = adapter_name.split(".")[0]
|
176
174
|
module_bytes = File.binread(adapter)
|
177
|
-
RubyWasm.logger.
|
175
|
+
RubyWasm.logger.debug "Linking adapter #{adapter_name}=#{adapter} (#{module_bytes.size} bytes)"
|
178
176
|
linker.adapter(adapter_name, module_bytes)
|
179
177
|
end
|
180
178
|
return linker.encode()
|
@@ -187,31 +185,43 @@ class RubyWasm::Packager::Core
|
|
187
185
|
baseruby.build(executor)
|
188
186
|
end
|
189
187
|
|
190
|
-
|
191
|
-
|
192
|
-
ext_feature = File.dirname(ext) # e.g. "ext/cgi/escape"
|
193
|
-
ext_srcdir = File.join(spec.full_gem_path, ext_feature)
|
194
|
-
ext_relative_path = File.join(spec.full_name, ext_feature)
|
195
|
-
prod = RubyWasm::CrossRubyExtProduct.new(
|
196
|
-
ext_srcdir,
|
197
|
-
build.toolchain,
|
198
|
-
features: @packager.features,
|
199
|
-
ext_relative_path: ext_relative_path
|
200
|
-
)
|
201
|
-
[prod, spec]
|
202
|
-
end
|
203
|
-
end
|
188
|
+
crossruby = build.crossruby
|
189
|
+
rbconfig_rb = crossruby.rbconfig_rb
|
204
190
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
191
|
+
options = @packager.full_build_options
|
192
|
+
target_triplet = options[:target]
|
193
|
+
|
194
|
+
local_path = File.join("bundle", target_triplet)
|
195
|
+
env = {
|
196
|
+
"BUNDLE_APP_CONFIG" => File.join(".bundle", target_triplet),
|
197
|
+
"BUNDLE_PATH" => local_path,
|
198
|
+
"BUNDLE_WITHOUT" => "build",
|
199
|
+
# Do not auto-switch bundler version by Gemfile.lock
|
200
|
+
"BUNDLE_VERSION" => "system",
|
201
|
+
# FIXME: BUNDLE_PATH is set as a installation destination here, but
|
202
|
+
# it is also used as a source of gems to be loaded by RubyGems itself.
|
203
|
+
# RubyGems loads "psych" gem and if Gemfile includes "psych" gem,
|
204
|
+
# RubyGems tries to load "psych" gem from BUNDLE_PATH at the second
|
205
|
+
# time of "bundle install" command. But the extension of "psych" gem
|
206
|
+
# under BUNDLE_PATH is built for Wasm target, not for host platform,
|
207
|
+
# so it fails to load the extension.
|
208
|
+
#
|
209
|
+
# Thus we preload psych from the default LOAD_PATH here to avoid
|
210
|
+
# loading Wasm version of psych.so via `Kernel#require` patched by
|
211
|
+
# RubyGems.
|
212
|
+
"RUBYOPT" => "-rpsych",
|
213
|
+
}
|
214
|
+
|
215
|
+
args = [
|
216
|
+
File.join(baseruby.install_dir, "bin", "bundle"),
|
217
|
+
"install",
|
218
|
+
"--standalone",
|
219
|
+
"--target-rbconfig",
|
220
|
+
rbconfig_rb,
|
221
|
+
]
|
222
|
+
|
223
|
+
executor.system(*args, env: env)
|
224
|
+
executor.cp_r(local_path, gem_home)
|
215
225
|
end
|
216
226
|
|
217
227
|
def cache_key(digest)
|
@@ -337,6 +347,14 @@ class RubyWasm::Packager::Core
|
|
337
347
|
# No-op because we already built extensions as part of the Ruby build
|
338
348
|
end
|
339
349
|
|
350
|
+
def wasi_exec_model
|
351
|
+
# TODO: Detect WASI exec-model from binary exports (_start or _initialize)
|
352
|
+
use_js_gem = @packager.specs.any? do |spec|
|
353
|
+
spec.name == "js"
|
354
|
+
end
|
355
|
+
use_js_gem ? "reactor" : "command"
|
356
|
+
end
|
357
|
+
|
340
358
|
def link_gem_exts(executor, ruby_root, gem_home, module_bytes)
|
341
359
|
return module_bytes unless @packager.features.support_component_model?
|
342
360
|
|
@@ -44,7 +44,6 @@ class RubyWasm::Packager::FileSystem
|
|
44
44
|
when "enc"
|
45
45
|
# Remove all encodings except for encdb.so and transdb.so
|
46
46
|
enc_dir = File.join(@ruby_root, "lib", "ruby", ruby_version, "wasm32-wasi", "enc")
|
47
|
-
puts File.join(enc_dir, "**/*.so")
|
48
47
|
Dir.glob(File.join(enc_dir, "**/*.so")).each do |entry|
|
49
48
|
next if entry.end_with?("encdb.so", "transdb.so")
|
50
49
|
RubyWasm.logger.debug "Removing stdlib encoding: #{entry}"
|
data/lib/ruby_wasm/packager.rb
CHANGED
@@ -34,7 +34,7 @@ class RubyWasm::Packager
|
|
34
34
|
|
35
35
|
ruby_core.build_gem_exts(executor, fs.bundle_dir)
|
36
36
|
|
37
|
-
fs.package_gems
|
37
|
+
fs.package_gems unless features.support_component_model?
|
38
38
|
fs.remove_non_runtime_files(executor)
|
39
39
|
if options[:stdlib]
|
40
40
|
options[:without_stdlib_components].each do |component|
|
data/lib/ruby_wasm/version.rb
CHANGED