You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|[ruby-head-wasm-wasi](./packages/npm-packages/ruby-head-wasm-wasi)| HEAD CRuby built on WASI with JS interop support |[](https://badge.fury.io/js/ruby-head-wasm-wasi)|
13
15
|[ruby-head-wasm-emscripten](./packages/npm-packages/ruby-head-wasm-emscripten)| HEAD CRuby built on Emscripten (not well tested) |[](https://badge.fury.io/js/ruby-head-wasm-emscripten)|
14
16
17
+
## Quick Example: How to package your Ruby application as a WASI application
|`wasm32-unknown-wasi`| Targeting WASI-compatible environments (e.g. Node.js, browsers with polyfill, [wasmtime](https://github.com/bytecodealliance/wasmtime), and so on) |
51
+
|`wasm32-unknown-emscripten`| Targeting JavaScript environments including Node.js and browsers |
|`minimal`| No standard extension libraries (like `json`, `yaml`, or `stringio`) |
58
+
|`full`| All standard extension libraries |
59
+
|`*-js`| Enabled JS interoperability, only usable with npm package |
60
+
|`*-debug`| With DWARF info and [`name` section](https://webassembly.github.io/spec/core/appendix/custom.html#name-section) for debugging |
61
+
62
+
Note: `*` is a wildcard that represents any other profile name except for itself, applied recursively. For example, `minimal-full-js-debug` is a valid profile.
33
63
34
64
## Building from source
35
65
66
+
If you want to build Ruby for WebAssembly from source yourself, follow the below instructions.
67
+
68
+
(However, in most cases, it's easier to use prebuilt binaries instead of building them yourself)
69
+
36
70
### Dependencies
37
71
38
-
-[wit-bindgen](https://github.com/bytecodealliance/wit-bindgen): A language bindings generator for `wit` used in the npm packages.
39
-
-[wasi-sdk](https://github.com/WebAssembly/wasi-sdk): For building for WASI target. Set `WASI_SDK_PATH` environment variable to the directory of wasi-sdk.
40
-
-[wasi-vfs](https://github.com/kateinoigakukun/wasi-vfs): A virtual filesystem layer for WASI.
41
-
-[wasi-preset-args](https://github.com/kateinoigakukun/wasi-preset-args): A tool to preset command-line arguments to a WASI module.
42
-
-[Emscripten](https://emscripten.org): For building for Emscripten target
72
+
-[wit-bindgen](https://github.com/bytecodealliance/wit-bindgen): A language bindings generator for `wit` used in the npm packages. Install in `PATH`.
73
+
-[wasi-sdk](https://github.com/WebAssembly/wasi-sdk): Only for building for WASI target. Set `WASI_SDK_PATH` environment variable to the directory of wasi-sdk.
74
+
-[wasi-vfs](https://github.com/kateinoigakukun/wasi-vfs): A virtual filesystem layer for WASI. Install CLI tool in `PATH`. Set `LIB_WASI_VFS_A` environment variable to the path to `libwasi_vfs.a`.
75
+
-[wasi-preset-args](https://github.com/kateinoigakukun/wasi-preset-args): A tool to preset command-line arguments to a WASI module. Install in `PATH`.
76
+
-[Emscripten](https://emscripten.org): Only for building for Emscripten target. Follow the official instructions to install.
43
77
44
-
It's recommended to build on a Docker container, which installs all dependencies and provides environment variables:
78
+
Note: It's recommended building on a builder Docker container, which installs all dependencies and provides environment variables:
45
79
46
80
```console
47
81
# For building ruby for WASI target
@@ -56,8 +90,21 @@ Then, you can build by `rake` command. See `rake -T` for more information.
56
90
# Build only a specific combination of ruby version, profile, and target
57
91
# Output is in the `rubies` directory
58
92
$ rake build:head-wasm32-unknown-wasi-full-js
59
-
# Build npm packages and required ruby
60
-
$ rake npm:all
93
+
$ tree -L 3 rubies/head-wasm32-unknown-wasi-full-js
94
+
rubies/head-wasm32-unknown-wasi-full-js/
95
+
├── usr
96
+
│ └── local
97
+
│ ├── bin
98
+
│ ├── include
99
+
│ ├── lib
100
+
│ └── share
101
+
└── var
102
+
└── lib
103
+
└── gems
104
+
105
+
# Or build npm package. Output is a tarball of npm package
106
+
$ rake npm:ruby-head-wasm-wasi
107
+
$ ls packages/npm-packages/ruby-head-wasm-wasi/ruby-head-wasm-wasi-*.tgz
0 commit comments