ruby_wasm 2.7.0-x86_64-darwin → 2.7.1-x86_64-darwin

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: 0a009971fbdd7e7ba5fecf2fa83833b570fc15d0c471db7ae6e84248a0386857
4
- data.tar.gz: d66968df89e5fb5062cd42ad9fa71a45c1397e64e768ba86dafe916ca13ed5f3
3
+ metadata.gz: 0c8b8086773793df7a7208686bdc318cc894c3a6e3ff32212aa0d7702cfee14d
4
+ data.tar.gz: 8a4339e2ac1a2605ec466a86e8601f08d5dd4d4222a431d94a4ed8907224ec54
5
5
  SHA512:
6
- metadata.gz: 29c2274ba5b0e7eca9ebf3b0b7450aa31209dd407f118f4e61b96b19f8d7e22aa990da6f65d51828bf565de9a2a2c8ddccafd21689303deb09678232192efef5
7
- data.tar.gz: 2df93b6d257a4fe72e83037d6b1ec7679c338f12abf215dd426be6e8925caffadabb5d4320d5deb2e9e1cb68d0fc012e87aa153a7868fdad296835042b424efd
6
+ metadata.gz: 4fed3ff0637d71fcbd4de7134698017453a6efd11a186f7555973efd602ca6f934518741d4458a597d88d4b4653828f726fc7b4af0d7d03b4e341a64deab588e
7
+ data.tar.gz: 75e8d83b41580047b03cc57ae7d14268b03e628980ce1690522f6424cd50917bae01eb4e751efce198be1f4ef810c58c861e87805475afdcc0a75c8e74b1055d
data/CONTRIBUTING.md CHANGED
@@ -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/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
 
Binary file
Binary file
Binary file
Binary file
@@ -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