ruby_wasm 2.7.0 → 2.7.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: 87f8bebce4287929607bb630f4f7c1bd5ec032cce19fbae498a0d1330c4054a3
4
- data.tar.gz: 5511e393ea005a6160ae9477b143e8e3168b7e57db6ca58736bfd106aa195dcf
3
+ metadata.gz: 66b759c02ace22303d907da3a0946c2f45f8e748c9999f158315297a9f6ba228
4
+ data.tar.gz: 435fd739cfc81ed29845981604996490322a34902289838495dfa6c6142c46ee
5
5
  SHA512:
6
- metadata.gz: 6019cc2c3c8c70c8a38269dcdd7eb8d384dd0b92181ca0cdf6186a72846121f4055cb014a619106eb112cb33d0981637a9ba3484dbef2125728161595ffa4cae
7
- data.tar.gz: a6ef643527574a4a18d033a9789f0cf2170e93c49f14ddfa1899e110cc113133178ec3aeebdb3b4a09d499f14d2b8115a506fe853f09e2dffc2b88eb3b7839c7
6
+ metadata.gz: 8b3400df7a4004808c0c4e89f2dfa2e3ce8ad6d2d179edbd794c71b6d87143533c1acf116af7df1c21562b70cb9f82bd9728e4477cb56b3ec7fdca808835d62a
7
+ data.tar.gz: 8ce2c317c921e927ceb6a9b696c98d485b58139e077fbb2fe38d8118f40eb675c7eed0742089131b6940259cb5c066db6ed1fedd0bff81e5de4f15ce03e19bbd
data/CONTRIBUTING.md CHANGED
@@ -112,7 +112,7 @@ $ git push origin 0.6.0
112
112
  # After GitHub Actions "Build gems" is done
113
113
  # https://github.com/ruby/ruby.wasm/actions/workflows/build-gems.yml
114
114
  $ gh run download <run-id>
115
- $ for pkg in cross-gem/pkg/ruby_wasm-*; do gem push $pkg; done
115
+ $ for pkg in cross-gem-*/ruby_wasm-*; do gem push $pkg; done
116
116
  $ gem build && gem push ruby_wasm-*.gem && rm ruby_wasm-*.gem
117
117
  $ (cd packages/gems/js/ && gem build && gem push js-*.gem && rm js-*.gem)
118
118
  $ rake bump_dev_version
@@ -129,5 +129,45 @@ $ npm install --save @ruby/wasm-wasi@latest
129
129
  # or if you want the nightly snapshot
130
130
  $ npm install --save @ruby/wasm-wasi@next
131
131
  # or you can specify the exact snapshot version
132
- $ npm install --save @ruby/wasm-wasi@2.7.0-2024-11-11-a
132
+ $ npm install --save @ruby/wasm-wasi@2.7.1-2025-01-23-a
133
133
  ```
134
+
135
+
136
+ ## Adding Support for a New Ruby Version
137
+
138
+ When a new version of Ruby is released, the following steps need to be taken to add support for it in ruby.wasm:
139
+
140
+ 1. Update `lib/ruby_wasm/cli.rb`:
141
+ - Add a new entry in the `build_source_aliases` method for the new version
142
+ - Specify the tarball URL and required default extensions
143
+
144
+ 2. Update `Rakefile`:
145
+ - Add the new version to `BUILD_SOURCES`
146
+ - Add a new entry in `NPM_PACKAGES` for the new version
147
+
148
+ 3. Create a new npm package:
149
+ ```console
150
+ # Copy from head package
151
+ $ cp -r packages/npm-packages/ruby-head-wasm-wasi packages/npm-packages/ruby-NEW.VERSION-wasm-wasi
152
+
153
+ # Update version references
154
+ # - In package.json: Update name, version, and description
155
+ # - In README.md: Update version references
156
+ ```
157
+ Note: Most of the package contents can be reused from the head package as is, since the JavaScript API and build configuration remain the same across versions.
158
+
159
+ 4. Update `package-lock.json` by `npm install`
160
+
161
+ 4. Update documentation:
162
+ - Update version references in `README.md`
163
+ - Update examples in `docs/cheat_sheet.md`
164
+ - Update the package list in `packages/npm-packages/ruby-wasm-wasi/README.md`
165
+
166
+ 5. Test the build:
167
+ ```console
168
+ $ rake build:NEW.VERSION-wasm32-unknown-wasip1-full
169
+ $ rake npm:ruby-NEW.VERSION-wasm-wasi:build
170
+ $ rake npm:ruby-NEW.VERSION-wasm-wasi:check
171
+ ```
172
+
173
+ 6. Create a pull request with all the changes
data/Cargo.lock CHANGED
@@ -1269,18 +1269,18 @@ dependencies = [
1269
1269
 
1270
1270
  [[package]]
1271
1271
  name = "rb-sys"
1272
- version = "0.9.97"
1272
+ version = "0.9.108"
1273
1273
  source = "registry+https://github.com/rust-lang/crates.io-index"
1274
- checksum = "47d30bcad206b51f2f66121190ca678dce1fdf3a2eae0ac5d838d1818b19bdf5"
1274
+ checksum = "1e955384e1a4dc64b71d1e4b39ed0edbd77c7bde4a10dfd5ad208e1160fddfa7"
1275
1275
  dependencies = [
1276
1276
  "rb-sys-build",
1277
1277
  ]
1278
1278
 
1279
1279
  [[package]]
1280
1280
  name = "rb-sys-build"
1281
- version = "0.9.97"
1281
+ version = "0.9.108"
1282
1282
  source = "registry+https://github.com/rust-lang/crates.io-index"
1283
- checksum = "3cbd92f281615f3c2dcb9dcb0f0576624752afbf9a7f99173b37c4b55b62dd8a"
1283
+ checksum = "c167c6571889b2550d6fcb315e8aa60bdb95e47e4b64793e3f65a30dc25afc85"
1284
1284
  dependencies = [
1285
1285
  "bindgen",
1286
1286
  "lazy_static",
data/Gemfile CHANGED
@@ -7,12 +7,12 @@ gemspec
7
7
  group :development do
8
8
  gem "rake"
9
9
  gem "rake-compiler"
10
- gem "rb_sys", "0.9.97"
10
+ gem "rb_sys", "0.9.108"
11
11
  end
12
12
 
13
13
  group :check do
14
14
  # Use the latest version of webrick for URI change in Ruby 3.4
15
15
  gem "webrick", "~> 1.8.2"
16
16
  gem "syntax_tree", "~> 3.5"
17
- gem "steep"
17
+ gem "steep", "~> 1.9" if RUBY_VERSION >= "3.1.0"
18
18
  end
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.7.0/dist/browser.script.iife.js"></script>
26
+ <script src="https://cdn.jsdelivr.net/npm/@ruby/3.4-wasm-wasi@2.7.1/dist/browser.script.iife.js"></script>
27
27
  <script type="text/ruby">
28
28
  require "js"
29
29
 
@@ -40,18 +40,18 @@ Dependencies: [wasmtime](https://github.com/bytecodealliance/wasmtime)
40
40
  ```console
41
41
  $ gem install ruby_wasm
42
42
  # Download a prebuilt Ruby release
43
- $ curl -LO https://github.com/ruby/ruby.wasm/releases/latest/download/ruby-3.3-wasm32-unknown-wasip1-full.tar.gz
44
- $ tar xfz ruby-3.3-wasm32-unknown-wasip1-full.tar.gz
43
+ $ curl -LO https://github.com/ruby/ruby.wasm/releases/latest/download/ruby-3.4-wasm32-unknown-wasip1-full.tar.gz
44
+ $ tar xfz ruby-3.4-wasm32-unknown-wasip1-full.tar.gz
45
45
 
46
46
  # Extract ruby binary not to pack itself
47
- $ mv ruby-3.3-wasm32-unknown-wasip1-full/usr/local/bin/ruby ruby.wasm
47
+ $ mv ruby-3.4-wasm32-unknown-wasip1-full/usr/local/bin/ruby ruby.wasm
48
48
 
49
49
  # Put your app code
50
50
  $ mkdir src
51
51
  $ echo "puts 'Hello'" > src/my_app.rb
52
52
 
53
53
  # Pack the whole directory under /usr and your app dir
54
- $ rbwasm pack ruby.wasm --dir ./src::/src --dir ./ruby-3.3-wasm32-unknown-wasip1-full/usr::/usr -o my-ruby-app.wasm
54
+ $ rbwasm pack ruby.wasm --dir ./src::/src --dir ./ruby-3.4-wasm32-unknown-wasip1-full/usr::/usr -o my-ruby-app.wasm
55
55
 
56
56
  # Run the packed scripts
57
57
  $ wasmtime my-ruby-app.wasm /src/my_app.rb
@@ -71,6 +71,11 @@ See the `README.md` of each package for more detail and its usage.
71
71
  </tr>
72
72
  </thead>
73
73
  <tbody>
74
+ <tr>
75
+ <td><a href="/packages/npm-packages/ruby-3.4-wasm-wasi">@ruby/3.4-wasm-wasi</a></td>
76
+ <td>CRuby 3.4 built on WASI with JS interop support</td>
77
+ <td><a href="https://www.npmjs.com/package/@ruby/3.4-wasm-wasi" rel="nofollow"><img src="https://badge.fury.io/js/@ruby%2F3.4-wasm-wasi.svg" alt="npm version" style="max-width: 100%;"></a></td>
78
+ </tr>
74
79
  <tr>
75
80
  <td><a href="/packages/npm-packages/ruby-3.3-wasm-wasi">@ruby/3.3-wasm-wasi</a></td>
76
81
  <td>CRuby 3.3 built on WASI with JS interop support</td>
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ require "ruby_wasm/rake_task"
9
9
  require "ruby_wasm/packager"
10
10
  require "ruby_wasm/cli"
11
11
 
12
- BUILD_SOURCES = %w[3.3 3.2 head]
12
+ BUILD_SOURCES = %w[3.4 3.3 3.2 head]
13
13
  BUILD_PROFILES = %w[full minimal]
14
14
 
15
15
  BUILDS =
@@ -38,6 +38,12 @@ NPM_PACKAGES = [
38
38
  target: "wasm32-unknown-wasip2",
39
39
  enable_component_model: true,
40
40
  },
41
+ {
42
+ name: "ruby-3.4-wasm-wasi",
43
+ ruby_version: "3.4",
44
+ gemfile: "packages/npm-packages/ruby-3.3-wasm-wasi/Gemfile",
45
+ target: "wasm32-unknown-wasip1"
46
+ },
41
47
  {
42
48
  name: "ruby-3.3-wasm-wasi",
43
49
  ruby_version: "3.3",
data/docs/cheat_sheet.md CHANGED
@@ -8,10 +8,10 @@
8
8
 
9
9
  ## Node.js
10
10
 
11
- To install the package, install `@ruby/3.3-wasm-wasi` and `@ruby/wasm-wasi` from npm:
11
+ To install the package, install `@ruby/3.4-wasm-wasi` and `@ruby/wasm-wasi` from npm:
12
12
 
13
13
  ```console
14
- npm install --save @ruby/3.3-wasm-wasi @ruby/wasm-wasi
14
+ npm install --save @ruby/3.4-wasm-wasi @ruby/wasm-wasi
15
15
  ```
16
16
 
17
17
  Then instantiate a Ruby VM by the following code:
@@ -20,7 +20,7 @@ Then instantiate a Ruby VM by the following code:
20
20
  import fs from "fs/promises";
21
21
  import { DefaultRubyVM } from "@ruby/wasm-wasi/dist/node";
22
22
 
23
- const binary = await fs.readFile("./node_modules/@ruby/3.3-wasm-wasi/dist/ruby.wasm");
23
+ const binary = await fs.readFile("./node_modules/@ruby/3.4-wasm-wasi/dist/ruby.wasm");
24
24
  const module = await WebAssembly.compile(binary);
25
25
  const { vm } = await DefaultRubyVM(module);
26
26
  vm.eval(`puts "hello world"`);
@@ -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.7.0/dist/browser.script.iife.js"></script>
41
+ <script src="https://cdn.jsdelivr.net/npm/@ruby/3.4-wasm-wasi@2.7.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.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");
54
+ import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.7.1/dist/browser/+esm";
55
+ const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.4-wasm-wasi@2.7.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.7.0/dist/browser.umd.js"></script>
72
+ <script src="https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.7.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.7.0/dist/ruby+stdlib.wasm");
76
+ const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.4-wasm-wasi@2.7.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.7.0/dist/browser.script.iife.js"></script>
131
+ <script src="https://cdn.jsdelivr.net/npm/@ruby/3.4-wasm-wasi@2.7.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.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");
146
+ import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.7.1/dist/browser/+esm";
147
+ const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.4-wasm-wasi@2.7.1/dist/ruby+stdlib.wasm");
148
148
  const module = await WebAssembly.compileStreaming(response);
149
149
  const { vm } = await DefaultRubyVM(module);
150
150
 
@@ -32,7 +32,7 @@ module RubyWasm
32
32
  end
33
33
 
34
34
  def make_args(crossruby)
35
- make_args = []
35
+ make_args = [] #: Array[String]
36
36
  make_args << "CC=#{@toolchain.cc}"
37
37
  make_args << "CXX=#{@toolchain.cc}"
38
38
  make_args << "LD=#{@toolchain.ld}"
@@ -90,10 +90,19 @@ module RubyWasm
90
90
  "--disable=gems",
91
91
  # HACK: top_srcdir is required to find ruby headers
92
92
  "-e",
93
- %Q($top_srcdir="#{source.src_dir}"),
93
+ %Q($top_srcdir=ENV["top_srcdir"]="#{source.src_dir}"),
94
94
  # HACK: extout is required to find config.h
95
95
  "-e",
96
- %Q($extout="#{crossruby.build_dir}/.ext"),
96
+ %Q($extout=ENV["extout"]="#{crossruby.build_dir}/.ext"),
97
+ ]
98
+ unless @features.support_component_model?
99
+ extconf_args.concat([
100
+ # HACK: skip have_devel check since ruby is not installed yet
101
+ "-e",
102
+ "$have_devel = true",
103
+ ])
104
+ end
105
+ extconf_args.concat([
97
106
  # HACK: force static ext build by imitating extmk
98
107
  "-e",
99
108
  "$static = true; trace_var(:$static) {|v| $static = true }",
@@ -110,7 +119,7 @@ module RubyWasm
110
119
  %Q(require "json"; File.write("#{metadata_json(crossruby)}", JSON.dump({target: $target}))),
111
120
  "-I#{crossruby.build_dir}",
112
121
  "--",
113
- ]
122
+ ])
114
123
  extconf_args << "--disable-component-model" unless @features.support_component_model?
115
124
  # Clear RUBYOPT to avoid loading unrelated bundle setup
116
125
  executor.system crossruby.baseruby_path,
@@ -11,7 +11,7 @@ module RubyWasm
11
11
  @toolchain = toolchain
12
12
  end
13
13
  def system_triplet_args
14
- args = []
14
+ args = [] #: Array[String]
15
15
  case @target.triple
16
16
  when /^wasm32-unknown-wasi/
17
17
  args.concat(%W[--host wasm32-wasi])
@@ -24,7 +24,7 @@ module RubyWasm
24
24
  end
25
25
 
26
26
  def tools_args
27
- args = []
27
+ args = [] #: Array[String]
28
28
  args << "CC=#{@toolchain.cc}"
29
29
  args << "CXX=#{@toolchain.cxx}"
30
30
  args << "LD=#{@toolchain.ld}"
@@ -45,7 +45,7 @@ module RubyWasm
45
45
 
46
46
  %i[cc cxx ranlib ld ar].each do |name|
47
47
  define_method(name) do
48
- @tools_cache ||= {}
48
+ @tools_cache ||= {} #: Hash[String, String]
49
49
  @tools_cache[name] ||= find_tool(name)
50
50
  @tools_cache[name]
51
51
  end
data/lib/ruby_wasm/cli.rb CHANGED
@@ -242,6 +242,11 @@ module RubyWasm
242
242
  rev: "master",
243
243
  all_default_exts: RubyWasm::Packager::ALL_DEFAULT_EXTS,
244
244
  },
245
+ "3.4" => {
246
+ type: "tarball",
247
+ url: "https://cache.ruby-lang.org/pub/ruby/3.4/ruby-3.4.1.tar.gz",
248
+ all_default_exts: "cgi/escape,continuation,coverage,date,digest/bubblebabble,digest,digest/md5,digest/rmd160,digest/sha1,digest/sha2,etc,fcntl,json,json/generator,json/parser,objspace,pathname,psych,rbconfig/sizeof,ripper,stringio,strscan,monitor,zlib,openssl",
249
+ },
245
250
  "3.3" => {
246
251
  type: "tarball",
247
252
  url: "https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.3.tar.gz",
@@ -111,7 +111,7 @@ class RubyWasm::Packager::Core
111
111
  end
112
112
 
113
113
  def _link_gem_exts(executor, build, ruby_root, gem_home, module_bytes)
114
- libraries = []
114
+ libraries = [] #: Array[String]
115
115
 
116
116
  # TODO: Should be computed from dyinfo of ruby binary
117
117
  wasi_libc_shared_libs = [
@@ -130,7 +130,7 @@ class RubyWasm::Packager::Core
130
130
  wasi_sdk_path = toolchain.wasi_sdk_path
131
131
  libraries << File.join(wasi_sdk_path, "share/wasi-sysroot/lib/wasm32-wasi", lib)
132
132
  end
133
- dl_openable_libs = []
133
+ dl_openable_libs = [] #: Array[[string, Array[String]]]
134
134
  dl_openable_libs << [File.dirname(ruby_root), Dir.glob(File.join(ruby_root, "lib", "ruby", "**", "*.so"))]
135
135
  dl_openable_libs << [gem_home, Dir.glob(File.join(gem_home, "**", "*.so"))]
136
136
 
@@ -1,3 +1,3 @@
1
1
  module RubyWasm
2
- VERSION = "2.7.0"
2
+ VERSION = "2.7.1"
3
3
  end