mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-23 19:16:37 +00:00

From @passcod : * Make bin-dir an Option * Use cargo-release as a test case * WIP: Try multiple default bin dirs * Update bins.rs * Update cargo_toml_binstall.rs From @NobodyXu : * Optimize & Prepare for support multi `bin-path`s * Ensure quickinstall bin_dir work as usual. * Rm dup entries in `FULL_FILENAMES` * Add second version of `NOVERSION_FILENAMES` * Impl multiple default `bin-dir`s * Improve doc for `BinFile::from_product` * Fix tests.sh Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> Co-authored-by: Félix Saparelli <felix@passcod.name>
93 lines
2.6 KiB
Rust
93 lines
2.6 KiB
Rust
//! The format of the `[package.metadata.binstall]` manifest.
|
|
//!
|
|
//! This manifest defines how a particular binary crate may be installed by Binstall.
|
|
|
|
use std::collections::BTreeMap;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[doc(inline)]
|
|
pub use package_formats::*;
|
|
|
|
mod package_formats;
|
|
|
|
/// `binstall` metadata container
|
|
///
|
|
/// Required to nest metadata under `package.metadata.binstall`
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
#[serde(rename_all = "kebab-case")]
|
|
pub struct Meta {
|
|
pub binstall: Option<PkgMeta>,
|
|
}
|
|
|
|
/// Metadata for binary installation use.
|
|
///
|
|
/// Exposed via `[package.metadata]` in `Cargo.toml`
|
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "kebab-case", default)]
|
|
pub struct PkgMeta {
|
|
/// URL template for package downloads
|
|
pub pkg_url: Option<String>,
|
|
|
|
/// Format for package downloads
|
|
pub pkg_fmt: Option<PkgFmt>,
|
|
|
|
/// Path template for binary files in packages
|
|
pub bin_dir: Option<String>,
|
|
|
|
/// Public key for package verification (base64 encoded)
|
|
pub pub_key: Option<String>,
|
|
|
|
/// Target specific overrides
|
|
pub overrides: BTreeMap<String, PkgOverride>,
|
|
}
|
|
|
|
impl PkgMeta {
|
|
pub fn clone_without_overrides(&self) -> Self {
|
|
Self {
|
|
pkg_url: self.pkg_url.clone(),
|
|
pkg_fmt: self.pkg_fmt,
|
|
bin_dir: self.bin_dir.clone(),
|
|
pub_key: self.pub_key.clone(),
|
|
overrides: BTreeMap::new(),
|
|
}
|
|
}
|
|
|
|
/// Merge configuration overrides into object
|
|
pub fn merge(&mut self, pkg_override: &PkgOverride) {
|
|
if let Some(o) = &pkg_override.pkg_url {
|
|
self.pkg_url = Some(o.clone());
|
|
}
|
|
if let Some(o) = &pkg_override.pkg_fmt {
|
|
self.pkg_fmt = Some(*o);
|
|
}
|
|
if let Some(o) = &pkg_override.bin_dir {
|
|
self.bin_dir = Some(o.clone());
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Target specific overrides for binary installation
|
|
///
|
|
/// Exposed via `[package.metadata.TARGET]` in `Cargo.toml`
|
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "kebab-case", default)]
|
|
pub struct PkgOverride {
|
|
/// URL template override for package downloads
|
|
pub pkg_url: Option<String>,
|
|
|
|
/// Format override for package downloads
|
|
pub pkg_fmt: Option<PkgFmt>,
|
|
|
|
/// Path template override for binary files in packages
|
|
pub bin_dir: Option<String>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "kebab-case")]
|
|
pub struct BinMeta {
|
|
/// Binary name
|
|
pub name: String,
|
|
/// Binary template path (within package)
|
|
pub path: String,
|
|
}
|