Skip to content

Commit 76da96b

Browse files
Update contribution guide
1 parent e2fc0bb commit 76da96b

File tree

1 file changed

+27
-29
lines changed

1 file changed

+27
-29
lines changed
Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,50 @@
11
# How to build toolchain
22

3+
This document describes how to build the toolchain for WebAssembly.
4+
This is just a quick guide, so if you want to know more about the toolchain, it might be good entry point to read [continuous integration scripts](https://github.com/swiftwasm/swift/blob/swiftwasm/.github/workflows/build-toolchain.yml).
5+
Or you can ask questions in GitHub issues or SwiftWasm Discord server (see [the official website](https://swiftwasm.org) for the link).
6+
37
## 1. Checkout the project source code.
48

59
```sh
610
$ mkdir swiftwasm-source
711
$ cd swiftwasm-source
812
$ git clone https://github.com/swiftwasm/swift.git
9-
$ ./swift/utils/update-checkout --scheme wasm --clone
13+
$ ./swift/utils/update-checkout --clone --scheme wasm
1014
```
1115

1216
## 2. Install required dependencies
1317

14-
Before building Swift, please install required dependencies.
18+
1. [Please follow the upstream instruction](https://github.com/apple/swift/blob/main/docs/HowToGuides/GettingStarted.md#installing-dependencies)
19+
2. Download WebAssembly specific build toolchain
1520

1621
```sh
17-
# On macOS
18-
$ brew install cmake ninja llvm sccache wasmer
19-
$ ./utils/webassembly/macos/install-dependencies.sh
20-
# On Linux
21-
$ ./utils/webassembly/linux/install-dependencies.sh
22+
$ ./swift/utils/webassembly/install-build-sdk.sh
2223
```
2324

24-
## 3. Build using custom preset options
25+
3. (If you want to run test suite) Install [`Wasmer`](https://wasmer.io/)
2526

26-
We support both Linux and macOS to build Swift. You need to select the preset name, `sccache` path and LLVM tools directory.
27+
## 3. Build the toolchain
2728

29+
`./swift/utils/webassembly/build-toolchain.sh` will build:
2830

29-
```sh
30-
# On macOS
31-
$ ./utils/build-script \
32-
--preset=webassembly-macos-target \
33-
--preset-file ./utils/webassembly/build-presets.ini \
34-
SOURCE_PATH=$(dirname $(pwd)) \
35-
LLVM_BIN_DIR=/usr/local/opt/llvm/bin \
36-
C_CXX_LAUNCHER=$(which sccache)
37-
# On Linux
38-
$ ./utils/build-script \
39-
--preset=webassembly-linux-target \
40-
--preset-file ./utils/webassembly/build-presets.ini \
41-
SOURCE_PATH=$(dirname $(pwd)) \
42-
LLVM_BIN_DIR=/usr/local/opt/llvm/bin \
43-
C_CXX_LAUNCHER=$(which sccache)
44-
```
31+
1. Swift compiler that can compile Swift code to WebAssembly support
32+
2. Swift standard library and core libraries for WebAssembly
4533

46-
Or if you want to build whole toolchain, please use `./utils/webassembly/build-toolchain.sh`. This script builds compiler, Swift Standard Library for host environment (e.g. macOS or Linux) and target environment (`wasm32-unknown-wasi`), Foundation and other packages. So it takes longer time than the above script.
4734

48-
```bash
49-
$ ./utils/webassembly/build-toolchain.sh
35+
## Build on Docker
36+
37+
You can also build the toolchain on Docker image used in CI.
38+
39+
```sh
40+
$ docker volume create oss-swift-package
41+
$ docker run --name swiftwasm-ci-buildbot \
42+
-dit \
43+
-w /home/build-user/ \
44+
-v $PWD/swift:/home/build-user/swift \
45+
-v oss-swift-package:/home/build-user \
46+
ghcr.io/swiftwasm/swift-ci:main-ubuntu-20.04
47+
$ docker exec swiftwasm-ci-buildbot ./swift/utils/webassembly/ci.sh
48+
$ docker cp swiftwasm-ci-buildbot:/home/build-user/swift-wasm-DEVELOPMENT-SNAPSHOT-*-ubuntu-20.04.tar.gz .
5049
```
5150

52-
If you want to get more information about build system, please feel free to ask @kateinoigakukun on Twitter or GitHub.

0 commit comments

Comments
 (0)