feat(toolchain): add automatic bundled Rust toolchain fallback and integrate with CLI/CargoRunner

This commit is contained in:
2026-02-09 20:57:52 +00:00
parent 18dc4c3a79
commit 85273e2933
10 changed files with 218 additions and 43 deletions

View File

@@ -20,7 +20,7 @@ Or as a project-level dev dependency:
pnpm install --save-dev @git.zone/tsrust
```
> ⚡ **Prerequisite:** You need a working Rust toolchain. Install via [rustup.rs](https://rustup.rs/) if you haven't already.
> ⚡ **No Rust required!** If `cargo` isn't found on your system, `tsrust` automatically downloads and installs a minimal Rust toolchain to `/tmp/tsrust_toolchain/`. This gives a zero-setup experience. If you already have Rust installed, `tsrust` uses your system toolchain.
## The Convention
@@ -44,7 +44,7 @@ tsrust
```
This will:
1. Verify that `cargo` is available
1. Detect the Rust toolchain (system `cargo`, or auto-install to `/tmp/tsrust_toolchain/`)
2. Locate your `rust/` directory (containing `Cargo.toml`)
3. Parse the workspace to discover all `[[bin]]` targets
4. Run `cargo build --release` with full streaming output
@@ -65,6 +65,18 @@ Copied rustproxy (13.4 MB) -> dist_rust/rustproxy
Done in 29.2s
```
### Automatic Rust Toolchain
`tsrust` provides a zero-setup experience through automatic toolchain management:
1. **System toolchain detected** → uses it as-is (no download, no overhead)
2. **No system toolchain** → checks `/tmp/tsrust_toolchain/` for a previously installed bundled toolchain
3. **No bundled toolchain** → downloads `rustup-init` and installs a minimal Rust toolchain (~70-90 MB download) to `/tmp/tsrust_toolchain/`
The bundled toolchain is stored in `/tmp/`, so it's cleaned up on reboot. Subsequent runs reuse the existing installation. This is ideal for CI environments and quick starts where you don't want to manage a system-wide Rust install.
Supported platforms for automatic install: Linux (x64, arm64) and macOS (x64, arm64).
### 🐛 Debug Build
Build with the debug profile instead of release: