add pkg-url and pkg-fmt overrides

This commit is contained in:
ryan 2021-04-08 21:26:44 +12:00
parent 612d19d0fb
commit 76a7fb00c9
2 changed files with 18 additions and 4 deletions

View file

@ -80,7 +80,7 @@ Template variables use the format `{ VAR }` where `VAR` is the name of the varia
- `bin` is the name of a specific binary, inferred from the crate configuration - `bin` is the name of a specific binary, inferred from the crate configuration
- `target` is the rust target name (defaults to your architecture, but can be overridden using the `--target` command line option if required(). - `target` is the rust target name (defaults to your architecture, but can be overridden using the `--target` command line option if required().
Package format can be overridden on a per-target basis, for example, if your `x86_64-pc-windows-msvc` builds use `zip` archives this can be set via: `pkg-url`, `pkg-fmt` and `bin-path` can be overridden on a per-target basis if required, for example, if your `x86_64-pc-windows-msvc` builds use `zip` archives this could be set via:
``` ```
[package.metadata.binstall.overrides.x86_64-pc-windows-msvc] [package.metadata.binstall.overrides.x86_64-pc-windows-msvc]

View file

@ -93,8 +93,14 @@ impl Default for PkgMeta {
impl PkgMeta { impl PkgMeta {
/// Merge configuration overrides into object /// Merge configuration overrides into object
pub fn merge(&mut self, pkg_override: &PkgOverride) { pub fn merge(&mut self, pkg_override: &PkgOverride) {
if let Some(o) = pkg_override.pkg_fmt { if let Some(o) = &pkg_override.pkg_url {
self.pkg_fmt = o; self.pkg_url = o.clone();
}
if let Some(o) = &pkg_override.pkg_fmt {
self.pkg_fmt = *o;
}
if let Some(o) = &pkg_override.bin_dir {
self.bin_dir = o.clone();
} }
} }
} }
@ -105,14 +111,22 @@ impl PkgMeta {
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case", default)] #[serde(rename_all = "kebab-case", default)]
pub struct PkgOverride { pub struct PkgOverride {
/// Format for package downloads /// URL template override for package downloads
pub pkg_url: Option<String>,
/// Format override for package downloads
pub pkg_fmt: Option<PkgFmt>, pub pkg_fmt: Option<PkgFmt>,
/// Path template override for binary files in packages
pub bin_dir: Option<String>,
} }
impl Default for PkgOverride { impl Default for PkgOverride {
fn default() -> Self { fn default() -> Self {
Self { Self {
pkg_url: None,
pkg_fmt: None, pkg_fmt: None,
bin_dir: None,
} }
} }
} }