Skip to main content

anodizer_core/config/
binstall.rs

1use std::collections::BTreeMap;
2
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6// ---------------------------------------------------------------------------
7// BinstallConfig
8// ---------------------------------------------------------------------------
9
10#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
11#[serde(default, deny_unknown_fields)]
12pub struct BinstallConfig {
13    /// When true, write `[package.metadata.binstall]` into the crate's
14    /// Cargo.toml so `cargo binstall` can install prebuilt release archives.
15    ///
16    /// # Auto-derivation
17    ///
18    /// With `enabled: true` and **no** `pkg_url` and **no** `overrides`,
19    /// anodize fills in correct per-target metadata automatically: for every
20    /// configured build target it emits an
21    /// `overrides.<rust-triple>` whose `pkg_url` is the GitHub release download
22    /// URL for that target's archive, with the asset name rendered through the
23    /// *same* `archive.name_template` the archive stage uses (so the URL can
24    /// never drift from the asset the release uploads) and the version
25    /// positions expressed as cargo-binstall's own `{ version }` token. The
26    /// matching `pkg_fmt` (`tar.gz`→`tgz`, `zip`→`zip`, …) is set per target.
27    ///
28    /// ```yaml
29    /// binstall:
30    ///   enabled: true   # nothing else required
31    /// ```
32    pub enabled: Option<bool>,
33    /// Custom download URL template for cargo-binstall (supports templates).
34    ///
35    /// Setting this (or any [`overrides`](Self::overrides) entry) **disables
36    /// auto-derivation** — anodize writes your value verbatim and computes
37    /// nothing. Use it only when the auto-derived per-target URLs don't fit
38    /// (manual values always win).
39    pub pkg_url: Option<String>,
40    /// Directory within the archive where binaries are located.
41    pub bin_dir: Option<String>,
42    /// Package format hint for cargo-binstall: tgz, tar.gz, tar.xz, zip, bin, etc.
43    pub pkg_fmt: Option<String>,
44    /// Per-target overrides keyed by Rust target triple
45    /// (e.g. `x86_64-unknown-linux-gnu`). Each entry overrides
46    /// `pkg_url`/`pkg_fmt`/`bin_dir` for the matching triple, emitted as a
47    /// `[package.metadata.binstall.overrides.<triple>]` sub-table.
48    ///
49    /// You rarely need to set this by hand: with `enabled: true` and no
50    /// `pkg_url`/`overrides`, anodize auto-derives a correct per-target
51    /// override for every build target (see [`enabled`](Self::enabled)).
52    /// Supplying any override here (like supplying [`pkg_url`](Self::pkg_url))
53    /// **disables auto-derivation** and takes full manual control of the table.
54    pub overrides: Option<BTreeMap<String, BinstallOverride>>,
55}
56
57// ---------------------------------------------------------------------------
58// BinstallOverride
59// ---------------------------------------------------------------------------
60
61#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
62#[serde(default, deny_unknown_fields)]
63pub struct BinstallOverride {
64    /// Custom download URL template for this target triple (supports templates).
65    /// Lets you point cargo-binstall at a per-target asset name such as
66    /// `myapp-{{ Version }}-linux-amd64.tar.gz`.
67    pub pkg_url: Option<String>,
68    /// Package format hint for this target triple: tgz, tar.gz, tar.xz, zip, bin, etc.
69    pub pkg_fmt: Option<String>,
70    /// Directory within the archive where binaries are located for this target triple.
71    pub bin_dir: Option<String>,
72}