Skip to content

Commit 6b21bc5

Browse files
docs: update dev docs
1 parent 975b20d commit 6b21bc5

File tree

1 file changed

+112
-70
lines changed

1 file changed

+112
-70
lines changed

docs/dev/developer-guide.md

Lines changed: 112 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -49,41 +49,57 @@ as well as to the `--help` text for each tool.
4949
5050
> 💡 If you are a member of Nextstrain team, then you don't need a fork and you can contribute directly to the origin repository. Still, in most cases, please submit pull requests for review, rather than pushing changes to major branches directly.
5151
52-
2. Install Rust if not already (once) ([https://www.rust-lang.org/tools/install](https://www.rust-lang.org/tools/install)):
52+
2. Install build dependencies (once)
5353

54-
This step is the same as for Nextclade CLI (see above). You can skip this step if you've done the setup for Nextclade CLI already.
54+
<details>
55+
<summary>🐧 Linux (Ubuntu/Debian)</summary>
56+
57+
```bash
58+
sudo apt-get update
59+
sudo apt-get install --yes build-essential libssl-dev pkg-config
60+
```
61+
62+
</details>
63+
64+
<details>
65+
<summary>🍏 macOS</summary>
66+
67+
Install Xcode Command Line Tools (provides compiler and linker):
5568

56-
The only supported Rust version is the one declared in [`rust-toolchain.toml`](https://github.com/nextstrain/nextclade/blob/master/rust-toolchain.toml). It may change in the future.
69+
```bash
70+
xcode-select --install
71+
```
72+
73+
</details>
74+
75+
3. Install Rust (once) ([https://www.rust-lang.org/tools/install](https://www.rust-lang.org/tools/install)):
76+
77+
The only supported Rust version is the one declared in [`rust-toolchain.toml`](https://github.com/nextstrain/nextclade/blob/master/rust-toolchain.toml) (currently **1.92.0**).
5778

5879
```bash
59-
# [once] Install Rustup, the Rust version manager
80+
# Install Rustup, the Rust version manager
6081
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
61-
62-
# [once] Add Rust tools to the $PATH
82+
83+
# Add Rust tools to the $PATH
6384
export PATH="$PATH:$HOME/.cargo/bin"
64-
65-
# [once] [Linux only] install openssl and pkgconfig. Example for Ubuntu:
66-
sudo apt-get update
67-
sudo apt-get install --yes libssl-dev pkg-config
68-
69-
# Check your installed versions of Rust compiler, Cargo and Rustup
70-
$ rustc -V
71-
$ cargo -V
72-
$ rustup -V
85+
86+
# Check your installed versions
87+
rustc -V
88+
cargo -V
89+
rustup -V
7390
```
7491

7592
> ⚠️ Nextclade team doesn't have bandwidth to support Rust installations deviating from the [officially recommended steps](https://doc.rust-lang.org/book/ch01-01-installation.html) and Rust versions different from what is declared in [rust-toolchain.toml](https://github.com/nextstrain/nextclade/blob/master/rust-toolchain.toml). If you install Rust from Linux package repositories, Homebrew, Conda etc., things may or may not work, or they may work but produce wrong results. Nextclade team doesn't have bandwidth to try every platform and config, so if you decide to go unofficial route, then you are on your own. But feel free to open pull requests if fixes are necessary to make your setup work.
7693

7794
> 💡 Note, Rustup allows to install multiple versions of Rust and to switch between them. This repository contains a [rust-toolchain.toml](https://github.com/nextstrain/nextclade/blob/master/rust-toolchain.toml) file, which describes which version of Rust is currently in use by Nextclade official build. Cargo and Rustup should be able to [pick it up automatically](https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file), install the required toolchain and use it when you type `cargo` commands. Any other versions of Rust toolchain are not supported.
7895

79-
3. Prepare environment variables (once). They configure Nextclade build-time settings. Optionally adjust the variables in the `.env` file to your needs.
96+
4. Prepare environment variables (once). They configure Nextclade build-time settings. Optionally adjust the variables in the `.env` file to your needs.
8097

8198
```bash
82-
# [once] Prepare dotenv file with default values
8399
cp .env.example .env
84100
```
85101

86-
4. Build and run Nextclade CLI in debug mode (convenient for development - faster to build, slow to run, has more debug info in the executable, error messages are more elaborate):
102+
5. Build and run Nextclade CLI in debug mode (convenient for development - faster to build, slow to run, has more debug info in the executable, error messages are more elaborate):
87103

88104
```bash
89105
# (Re-)build Nextclade in debug mode.
@@ -117,7 +133,7 @@ as well as to the `--help` text for each tool.
117133

118134
> 💡 Add `-v` to Nextclade arguments to make console output more verbose. Add more occurrences, e.g. `-vv`, for even more verbose output.
119135

120-
5. Build and run Nextclade CLI in release mode (slow to build, fast to run, very little debug info):
136+
6. Build and run Nextclade CLI in release mode (slow to build, fast to run, very little debug info):
121137

122138
```bash
123139
# Build Nextclade in release mode.
@@ -162,92 +178,118 @@ Note that there is no actual programmable backend server. Nextclade Web is a sta
162178

163179
> 💡 If you are a member of Nextstrain team, then you don't need a fork and you can contribute directly to the origin repository. Still, in most cases, please submit pull requests for review, rather than pushing changes to branches directly.
164180
165-
2. Install Node.js (once), by either downloading it from the official website: [nodejs.org](https://nodejs.org), or by using [nvm](https://github.com/nvm-sh/nvm).
181+
2. Install Node.js and Bun (once)
166182
167-
The only supported Node.js version is the one that is currently declared in the [`.nvmrc`](https://github.com/nextstrain/nextclade/blob/master/.nvmrc) file. It may change in the future.
183+
The only supported Node.js version is the one declared in [`.nvmrc`](https://github.com/nextstrain/nextclade/blob/master/.nvmrc) (currently **22.16.0**).
168184
169-
If you have `nvm` installed and configured, you can quickly install and switch to this Node.js version by navigating to the root of nextclade repository (where the [`.nvmrc`](https://github.com/nextstrain/nextclade/blob/master/.nvmrc) file is) and running:
185+
Install Node.js from [nodejs.org](https://nodejs.org), or using [nvm](https://github.com/nvm-sh/nvm):
170186
171187
```bash
172188
cd nextclade/
173189
nvm install
174190
nvm use
175191
node --version
176-
bun --version
177192
```
178193
179-
Install Bun if you don't have it ([https://bun.sh](https://bun.sh)):
194+
Install Bun (version **1.2.14** recommended) from [bun.sh](https://bun.sh):
180195
181196
```bash
182197
curl -fsSL https://bun.sh/install | bash
198+
bun --version
183199
```
184200
185201
> ⚠️ Nextclade team doesn't have bandwidth to support Node.js installations from Linux package repositories, Homebrew, Conda, as well as versions of Node.js which are not the same as the one currently declared in the [`.nvmrc`](https://github.com/nextstrain/nextclade/blob/master/.nvmrc), and everything else deviating from the recommended setup. If you decide to go that route - things may or may not work - you are on your own. But feel free to open pull requests if fixes are necessary to make your setup work.
186202

187-
3. Install Rust if not already (once) ([https://www.rust-lang.org/tools/install](https://www.rust-lang.org/tools/install)):
203+
3. Install Rust and build dependencies (once)
188204

189-
This step is the same as for Nextclade CLI (see above). You can skip this step if you've done the setup for Nextclade CLI already.
205+
Follow the same steps as for Nextclade CLI (see above). If you've already set up for CLI development, you can skip this step.
190206
191-
The only supported Rust version is the one declared in [`rust-toolchain.toml`](https://github.com/nextstrain/nextclade/blob/master/rust-toolchain.toml). It may change in the future.
207+
4. Install LLVM/Clang toolchain (once)
192208
193-
```bash
194-
# [once] Install Rustup, the Rust version manager
195-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
196-
197-
# [once] Add Rust tools to the $PATH
198-
export PATH="$PATH:$HOME/.cargo/bin"
199-
200-
# [once] [Linux only] install openssl and pkgconfig. Example for Ubuntu:
201-
sudo apt-get update
202-
sudo apt-get install --yes libssl-dev pkg-config
203-
204-
# Check your installed versions of Rust compiler, Cargo and Rustup
205-
$ rustc -V
206-
$ cargo -V
207-
$ rustup -V
208-
```
209+
LLVM/Clang is required for compiling Rust code to WebAssembly. Version **13** is used in the official build environment.
209210
210-
> ⚠️ Nextclade team doesn't have bandwidth to support Rust installations deviating from the [officially recommended steps](https://doc.rust-lang.org/book/ch01-01-installation.html) and Rust versions different from what is declared in [rust-toolchain.toml](https://github.com/nextstrain/nextclade/blob/master/rust-toolchain.toml). If you install Rust from Linux package repositories, Homebrew, Conda etc., things may or may not work, or they may work but produce wrong results. Nextclade team doesn't have bandwidth to try every platform and config, so if you decide to go unofficial route, then you are on your own. But feel free to open pull requests if fixes are necessary to make your setup work.
211+
<details>
212+
<summary>🐧 Linux (Ubuntu/Debian)</summary>
211213
212-
> 💡 Note, Rustup allows to install multiple versions of Rust and to switch between them. This repository contains a [rust-toolchain.toml](https://github.com/nextstrain/nextclade/blob/master/rust-toolchain.toml) file, which describes which version of Rust is currently in use by Nextclade official build. Cargo and Rustup should be able to [pick it up automatically](https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file), install the required toolchain and use it when you type `cargo` commands. Any other versions of Rust toolchain are not supported.
214+
```bash
215+
# Add LLVM apt repository
216+
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
217+
echo "deb https://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-13 main" | sudo tee /etc/apt/sources.list.d/llvm.list
213218
214-
4. Prepare environment variables (once). They configure Nextclade build-time settings. Optionally adjust the variables in the `.env` file to your needs.
219+
# Install Clang 13
220+
sudo apt-get update
221+
sudo apt-get install --yes clang-13 lld-13 llvm-13
222+
```
223+
224+
</details>
225+
226+
<details>
227+
<summary>🍏 macOS</summary>
228+
229+
```bash
230+
brew install llvm
231+
```
232+
233+
Set the following environment variables before invoking `bun wasm-prod`:
234+
235+
```bash
236+
export CC=/opt/homebrew/opt/llvm/bin/clang
237+
export AR=/opt/homebrew/opt/llvm/bin/llvm-ar
238+
```
239+
240+
</details>
241+
242+
5. Prepare environment variables (once). They configure Nextclade build-time settings. Optionally adjust the variables in the `.env` file to your needs.
215243
216244
```bash
217245
cp .env.example .env
218246
```
219247
220-
5. Install other required tools (once)
248+
6. Install WebAssembly toolchain (once)
249+
250+
The following versions are pinned for build reproducibility:
251+
252+
| Tool | Version |
253+
|------|---------|
254+
| wasm-pack | 0.13.1 |
255+
| wasm-bindgen-cli | 0.2.106 |
256+
| binaryen | 125 |
221257
222258
```bash
223-
cargo install wasm-pack --locked
259+
# Install wasm-pack
260+
cargo install wasm-pack@0.13.1 --locked
261+
262+
# Install wasm-bindgen-cli (must match the version in Cargo.toml)
263+
cargo install wasm-bindgen-cli@0.2.106 --locked
264+
265+
# Add WebAssembly compilation target
266+
rustup target add wasm32-unknown-unknown
224267
```
225268
226269
<details>
227-
<summary>🍏 Extra requirements for macOS [click to expand]</summary>
270+
<summary>🐧 Install binaryen on Linux</summary>
228271
229-
> For macOS, you will also have to install llvm:
230-
>
231-
> ```bash
232-
> brew install llvm
233-
> ```
234-
>
235-
> Furthermore, you will need to set the following environment variables before invoking `bun wasm-prod`:
236-
>
237-
> ```bash
238-
> export CC=/opt/homebrew/opt/llvm/bin/clang
239-
> export AR=/opt/homebrew/opt/llvm/bin/llvm-ar
240-
> ```
272+
```bash
273+
# Ubuntu/Debian (version may differ)
274+
sudo apt-get install binaryen
241275
242-
</details>
276+
# Or download pinned version (recommended):
277+
export BINARYEN_VERSION="125"
278+
curl -sSL "https://github.com/WebAssembly/binaryen/releases/download/version_${BINARYEN_VERSION}/binaryen-version_${BINARYEN_VERSION}-x86_64-linux.tar.gz" | sudo tar -C /usr/local -xz --strip-components=1
279+
```
243280
244-
You might also have to install a particular version of `wasm-bindgen-cli` (if you get an error during `bun wasm-prod`):
281+
</details>
245282
246-
```bash
247-
cargo install wasm-bindgen-cli@0.2.106 --locked
248-
```
283+
<details>
284+
<summary>🍏 Install binaryen on macOS</summary>
285+
286+
```bash
287+
brew install binaryen
288+
```
289+
290+
</details>
249291
250-
6. Install NPM dependencies (once)
292+
7. Install NPM dependencies (once)
251293
252294
```bash
253295
cd packages/nextclade-web
@@ -256,7 +298,7 @@ Note that there is no actual programmable backend server. Nextclade Web is a sta
256298
257299
> ⚠️ Nextclade uses `bun` to manage NPM dependencies. While you could try `npm` or other tools instead, we don't support this.
258300

259-
7. Build the WebAssembly module
301+
8. Build the WebAssembly module
260302

261303
```bash
262304
cd packages/nextclade-web
@@ -267,7 +309,7 @@ Note that there is no actual programmable backend server. Nextclade Web is a sta
267309

268310
Repeat this step every time you are changing Rust code.
269311

270-
8. Build and serve the development version of the web app locally
312+
9. Build and serve the development version of the web app locally
271313

272314
We are going to run a development web server, which runs continuously (it does not yield terminal prompt until you stop it). It's convenient to do it in a separate terminal instance from WebAssembly module build to allow rebuilding the app and the module independently.
273315
@@ -282,7 +324,7 @@ Note that there is no actual programmable backend server. Nextclade Web is a sta
282324
283325
Note that changes in Rust code (the algorithms) are not picked up automatically and the requirement rebuilding the WebAssembly module manually (as explained above). Once you rebuild the WebAssembly module in a separate terminal instance, the dev server should pick up the changes in the algorithms - no dev server restart is necessary.
284326
285-
9. Build and serve the production version of the web app locally
327+
10. Build and serve the production version of the web app locally
286328
287329
Alternatively, the optimized ("production") version of the web app can be built and (optionally) served with
288330

0 commit comments

Comments
 (0)