diff --git a/.gitignore b/.gitignore index 55e0947..75ef397 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,6 @@ Desktop.ini # Test artifacts /tests/tmp/ + +# Release artifacts +release-artifacts/ \ No newline at end of file diff --git a/README.md b/README.md index 3d66dd7..7f1ec89 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,9 @@ This installs `arduino-cli` and the `arduino:avr` core. If something is already installed, Anvil skips it. Run `anvil doctor` at any time to check your environment. +If there is no pre-built binary for your platform, or you want to hack on +Anvil itself, see [Building from Source](#building-from-source) below. + ### Create a project ```bash @@ -360,14 +363,72 @@ vid_pid = "0403:6001" ## Building from Source +If you want to build Anvil yourself -- either because there is no pre-built +binary for your platform, or because you want to contribute -- here is what +you need. + +### Prerequisites + +Anvil is written in Rust and compiles to a single static binary. You need: + +- **Rust toolchain** (stable, 2021 edition or later) +- **A C linker** (`gcc` or equivalent -- Rust uses it under the hood) +- **MinGW** (only if cross-compiling a Windows binary from Linux) +- **zip** (only for packaging release artifacts) + +### Linux / WSL from scratch + +A fresh Ubuntu or WSL instance needs three commands: + ```bash +# 1. System packages (C linker + cross-compile + packaging tools) +sudo apt update && sudo apt install build-essential mingw-w64 zip + +# 2. Rust toolchain +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +source ~/.cargo/env + +# 3. Build cargo build --release ``` -Binary at `target/release/anvil` (Linux) or `target\release\anvil.exe` -(Windows). Requires Rust 2021 edition. +The release binary lands at `target/release/anvil`. Copy it somewhere in +your PATH. -The test suite: +### Windows (native) + +Install Rust from [rustup.rs](https://rustup.rs), which includes the MSVC +toolchain. Then: + +``` +cargo build --release +``` + +The binary lands at `target\release\anvil.exe`. + +### Release builds (Linux + Windows from one machine) + +The `build-release.sh` script at the repo root builds optimized, stripped +binaries for both platforms and packages them into tarballs and zips: + +```bash +./build-release.sh # uses git describe for version +./build-release.sh v1.2.0 # explicit version tag +``` + +This produces a `release-artifacts/` directory with: + +``` +anvil-v1.2.0-linux-x86_64.tar.gz +anvil-v1.2.0-linux-x86_64.zip +anvil-v1.2.0-windows-x86_64.zip +SHA256SUMS +``` + +Upload these to a Gitea release. The script requires `build-essential`, +`mingw-w64`, and `zip` as described above. + +### Running the test suite ```bash cargo test