the big refactor

This commit is contained in:
ryan 2020-12-31 14:41:52 +13:00
parent 5fd78341c8
commit a6c70b41e2
3 changed files with 90 additions and 52 deletions

View file

@ -14,10 +14,10 @@ pub use drivers::*;
pub const TARGET: &'static str = env!("TARGET");
/// Default package path template (may be overridden in package Cargo.toml)
pub const DEFAULT_PKG_URL: &'static str = "{ repo }/releases/download/v{ version }/{ name }-{ target }-v{ version }.{ format }";
pub const DEFAULT_PKG_URL: &'static str = "{ repo }/releases/download/v{ version }/{ name }-{ target }-v{ version }.tgz";
/// Default binary name template (may be overridden in package Cargo.toml)
pub const DEFAULT_BIN_PATH: &'static str = "{ name }-{ target }-v{ version }/{ name }{ format }";
pub const DEFAULT_BIN_PATH: &'static str = "{ name }-{ target }-v{ version }/{ bin }{ format }";
/// Binary format enumeration
@ -96,6 +96,7 @@ pub struct Context {
pub target: String,
pub version: String,
pub format: String,
pub bin: Option<String>,
}
impl Context {

View file

@ -110,6 +110,7 @@ async fn main() -> Result<(), anyhow::Error> {
target: opts.target.clone(),
version: package.version.clone(),
format: meta.pkg_fmt.to_string(),
bin: None,
};
debug!("Using context: {:?}", ctx);
@ -181,7 +182,7 @@ async fn main() -> Result<(), anyhow::Error> {
// Generate binary path via interpolation
let mut bin_ctx = ctx.clone();
bin_ctx.name = base_name.clone();
bin_ctx.bin = Some(base_name.clone());
// Append .exe to windows binaries
bin_ctx.format = match &opts.target.clone().contains("windows") {
@ -195,7 +196,7 @@ async fn main() -> Result<(), anyhow::Error> {
let source = bin_path.join(&source_file_path);
// Destination path is the install dir + base-name-version{.format}
let dest_file_path = bin_ctx.render("{ name }-v{ version }{ format }")?;
let dest_file_path = bin_ctx.render("{ bin }-v{ version }{ format }")?;
let dest = install_path.join(dest_file_path);
// Link at install dir + base name