Skip to content

Commit cff3c9a

Browse files
authored
Add manifest metadata for cargo binstall (#1562)
I've seen this recommended a number of times for installing precompiled binaries and this enables `cargo binstall` to pull from the precompiled artifacts produced on CI rather than needing a third-party source.
1 parent 962aaa5 commit cff3c9a

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,21 @@ readme = "README.md"
1313
exclude = ['tests/wabt', 'tests/testsuite', 'tests/snapshots', 'ci']
1414
rust-version.workspace = true
1515

16+
[package.metadata.binstall]
17+
pkg-url = "{repo}/releases/download/v{version}/{name}-{version}-{target-arch}-{target-family}{archive-suffix}"
18+
bin-dir = "{name}-{version}-{target-arch}-{target-family}/{bin}{binary-ext}"
19+
pkg-fmt = "tgz"
20+
[package.metadata.binstall.overrides.x86_64-apple-darwin]
21+
pkg-url = "{repo}/releases/download/v{version}/{name}-{version}-{target-arch}-macos{archive-suffix}"
22+
bin-dir = "{name}-{version}-{target-arch}-macos/{bin}{binary-ext}"
23+
[package.metadata.binstall.overrides.aarch64-apple-darwin]
24+
pkg-url = "{repo}/releases/download/v{version}/{name}-{version}-{target-arch}-macos{archive-suffix}"
25+
bin-dir = "{name}-{version}-{target-arch}-macos/{bin}{binary-ext}"
26+
[package.metadata.binstall.overrides.x86_64-pc-windows-msvc]
27+
pkg-fmt = "zip"
28+
[package.metadata.binstall.overrides.x86_64-pc-windows-gnu]
29+
pkg-fmt = "zip"
30+
1631
[lints]
1732
workspace = true
1833

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,23 @@
1313
[Precompiled artifacts built on CI][artifacts] are available for download for
1414
each release.
1515

16-
If you'd prefer to build from source then first [install Rust for your
16+
[artifacts]: https://github.com/bytecodealliance/wasm-tools/releases
17+
18+
To build from source first [install Rust for your
1719
platform](https://www.rust-lang.org/tools/install) and then use the included
1820
Cargo package manager to install:
1921

2022
```
2123
$ cargo install wasm-tools
2224
```
2325

24-
[artifacts]: https://github.com/bytecodealliance/wasm-tools/releases
26+
Alternatively if you use [`cargo
27+
binstall`](https://github.com/cargo-bins/cargo-binstall) then that can be used
28+
to install [the precompiled artifacts][artifacts] instead:
29+
30+
```
31+
$ cargo binstall wasm-tools
32+
```
2533

2634
Installation can be confirmed with:
2735

0 commit comments

Comments
 (0)