Skip to content

Commit

Permalink
Fixup readme
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-noland committed Oct 23, 2024
1 parent 818f5ab commit 82fc5c9
Showing 1 changed file with 44 additions and 20 deletions.
64 changes: 44 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@

### Prerequisites

- Recent linux machine of some kind required for development

> [!NOTE]
> I might be able to make this work on Mac if folks are interested and can help test.
- Recent `x86_64` linux machine of some kind required for development
- Bash (you very likely have this)
- [Docker](https://www.docker.com/) (install through your package manager
- Cargo / Rust (install via [`rustup`](https://rustup.rs/))
- [just](https://github.com/casey/just) (install through your package manager or cargo)

> [!WARNING]
> System privileges required for testing!
> This project requires root privileges to run the tests.
> This is because the tests require access to raw network interfaces.
> You can either run in docker or with `sudo`.
> `sudo` happens by default when you run `cargo test`.
* :warning: You need a recent version of rust (1.82.0 or better) to build the project.

```bash
rustup update
```
* :warning: You need to install both the glibc and musl targets to use the default builds.

```bash
rustup target add x86_64-unknown-linux-gnu
rustup target add x86_64-unknown-linux-musl
```

- [just](https://github.com/casey/just) (install through your package manager or cargo)

## Step 0. Clone the repository

Expand Down Expand Up @@ -64,27 +66,49 @@ just fake-nix
At this point you should be able to run

```bash
cargo build
just cargo build
```

You should now have statically linked ELF executables in `target/x86_64-unknown-linux-gnu/debug/scratch` and `target/x86_64-unknown-linux-musl/debug/scratch`.

Additionally, you can run
You can build in release mode with

```bash
just build
just cargo build --profile=release
```

## Step 4. Run the tests
at which point the executables will be in `target/x86_64-unknown-linux-gnu/release/scratch` and `target/x86_64-unknown-linux-musl/release/scratch`.

To run the test suite under glibc
## Step 4. Run the tests (debug mode)

To run the test suite you can run

```bash
cargo test --target x86_64-unknown-linux-gnu
just cargo test
```

To run the test suite under musl
By default, this will run both the musl and glibc tests.
To run the test suite under glibc or musl specifically, try

```bash
cargo test --target x86_64-unknown-linux-musl
just cargo test --target x86_64-unknown-linux-gnu
```

or

```bash
just cargo test --target x86_64-unknown-linux-musl
```

To run the test suite under release mode

```bash
just cargo test --profile=release
```

> [!NOTE]
> Why the `just` in `just cargo build ...`?
>
> `just` is computing the correct `RUSTFLAGS` for us depending on the profile.
> After that it just calls `cargo build`.
> Normally we would include those kinds of setting in `Cargo.toml` but `cargo` can not currently express all the `RUSTFLAGS` we are using (thus the `just` wrapper).

0 comments on commit 82fc5c9

Please sign in to comment.