Skip to content

Commit 4c0e801

Browse files
Move build instructions to CONTRIBUTING.md
1 parent b9feebc commit 4c0e801

File tree

2 files changed

+57
-46
lines changed

2 files changed

+57
-46
lines changed

CONTRIBUTING.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,62 @@ $ rake npm:ruby-head-wasm-wasi
2323
$ rake npm:ruby-head-wasm-wasi-check
2424
```
2525

26+
If you need to re-build Ruby, please clean `./rubies` directory, and run `rake npm:ruby-head-wasm-wasi` again.
27+
28+
## Building CRuby from source
29+
30+
If you want to build CRuby for WebAssembly from source yourself, follow the below instructions.
31+
32+
> **Warning**
33+
> If you just want to build npm packages, you don't need to build CRuby from source.
34+
> You can download a prebuilt Ruby release by `rake build:download_prebuilt`.
35+
36+
### For WASI target
37+
38+
You can build CRuby for WebAssembly/WASI on Linux (x86_64) or macOS (x86_64, arm64).
39+
For WASI target, dependencies are automatically downloaded on demand, so you don't need to install them manually.
40+
41+
To select a build profile, see [profiles section in README](https://github.com/ruby/ruby.wasm#profiles).
42+
43+
```console
44+
# Build only a specific combination of ruby version, profile, and target
45+
$ rake build:head-wasm32-unknown-wasi-full-js
46+
# Output is in the `rubies` directory
47+
$ tree -L 3 rubies/head-wasm32-unknown-wasi-full-js
48+
rubies/head-wasm32-unknown-wasi-full-js/
49+
├── usr
50+
│   └── local
51+
│   ├── bin
52+
│   ├── include
53+
│   ├── lib
54+
│   └── share
55+
```
56+
57+
### For Emscripten target
58+
59+
To build CRuby for WebAssembly/Emscripten, you need to install [Emscripten](https://emscripten.org).
60+
Please follow the official instructions to install.
61+
62+
```console
63+
# Build only a specific combination of ruby version, profile, and target
64+
$ rake build:head-wasm32-unknown-emscripten-full-js
65+
# Output is in the `rubies` directory
66+
$ tree -L 3 rubies/head-wasm32-unknown-emscripten-full-js
67+
rubies/head-wasm32-unknown-emscripten-full
68+
└── usr
69+
└── local
70+
├── bin
71+
├── include
72+
├── lib
73+
└── share
74+
```
75+
76+
## Code Formatting
77+
78+
This project uses multiple code formatters for each language.
79+
To format all files, run `rake format`.
80+
Please make sure to run this command before submitting a pull request.
81+
2682
## Re-bindgen from `.wit` files
2783

2884
If you update [`*.wit`](https://github.com/WebAssembly/component-model/blob/ed90add27ae845b2e2b9d7db38a966d9f78aa4c0/design/mvp/WIT.md), which describe the interface of a WebAssembly module, either imported or exported, you need to re-generate glue code from `*.wit`.

README.md

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -78,52 +78,6 @@ A _build_ is a combination of ruby version, _profile_, and _target_.
7878

7979
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.
8080

81-
## Building from source
82-
83-
If you want to build Ruby for WebAssembly from source yourself, follow the below instructions.
84-
85-
(However, in most cases, it's easier to use prebuilt binaries instead of building them yourself)
86-
87-
### Dependencies
88-
89-
- [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.
90-
- [Binaryen](https://github.com/WebAssembly/binaryen): Only for building for WASI target. Install `wasm-opt` in `PATH`
91-
- [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`.
92-
- [wasi-preset-args](https://github.com/kateinoigakukun/wasi-preset-args): A tool to preset command-line arguments to a WASI module. Install in `PATH`.
93-
- [Emscripten](https://emscripten.org): Only for building for Emscripten target. Follow the official instructions to install.
94-
95-
Note: It's recommended building on a builder Docker container, which installs all dependencies and provides environment variables:
96-
97-
```console
98-
# For building ruby for WASI target
99-
$ docker run -v $(pwd):/src -w /src --rm -it ghcr.io/ruby/ruby.wasm-builder:wasm32-unknown-wasi /bin/bash
100-
# For building ruby for Emscripten target
101-
$ docker run -v $(pwd):/src -w /src --rm -it ghcr.io/ruby/ruby.wasm-builder:wasm32-unknown-emscripten /bin/bash
102-
```
103-
104-
Then, you can build by `rake` command. See `rake -T` for more information.
105-
106-
```console
107-
# Build only a specific combination of ruby version, profile, and target
108-
# Output is in the `rubies` directory
109-
$ rake build:head-wasm32-unknown-wasi-full-js
110-
$ tree -L 3 rubies/head-wasm32-unknown-wasi-full-js
111-
rubies/head-wasm32-unknown-wasi-full-js/
112-
├── usr
113-
│   └── local
114-
│   ├── bin
115-
│   ├── include
116-
│   ├── lib
117-
│   └── share
118-
└── var
119-
└── lib
120-
└── gems
121-
122-
# Or build npm package. Output is a tarball of npm package
123-
$ rake npm:ruby-head-wasm-wasi
124-
$ ls packages/npm-packages/ruby-head-wasm-wasi/ruby-head-wasm-wasi-*.tgz
125-
```
126-
12781
## Notable Limitations
12882

12983
The current WASI target build does not yet support `Thread` related APIs. Specifically, WASI does not yet have an API for creating and managing threads yet.
@@ -133,4 +87,5 @@ Also there is no support for networking. It is one of the goal of WASI to suppor
13387

13488
## Contributing
13589

90+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for how to build and test, and how to contribute to this project.
13691
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/ruby.wasm

0 commit comments

Comments
 (0)