diff --git a/Cargo.lock b/Cargo.lock index 3b2f7c27..8c60d24f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -721,7 +721,7 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hemtt" -version = "1.3.0" +version = "1.3.0-rc1" dependencies = [ "ansi_term", "anyhow", diff --git a/bin/Cargo.toml b/bin/Cargo.toml index d635c3f9..86a450e6 100644 --- a/bin/Cargo.toml +++ b/bin/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "hemtt" description = "HEMTT - Arma 3 Build Tool" -version = "1.3.0" +version = "1.3.0-rc1" edition = "2021" license = "GPL-2.0" authors = ["Brett Mayson "] diff --git a/bin/src/config/project/hemtt.rs b/bin/src/config/project/hemtt.rs index f833ff42..9cb60869 100644 --- a/bin/src/config/project/hemtt.rs +++ b/bin/src/config/project/hemtt.rs @@ -134,6 +134,10 @@ impl BuildOptions { #[derive(Debug, Default, Clone, Serialize, Deserialize)] pub struct ReleaseOptions { + #[serde(default)] + /// The folder name of the project + /// Default: `prefix` + folder: Option, #[serde(default)] /// Should the PBOs be signed? /// Default: true @@ -145,6 +149,11 @@ pub struct ReleaseOptions { } impl ReleaseOptions { + #[must_use] + pub fn folder(&self) -> Option { + self.folder.clone() + } + #[must_use] pub const fn sign(&self) -> bool { if let Some(sign) = self.sign { diff --git a/bin/src/config/project/mod.rs b/bin/src/config/project/mod.rs index 264ed2b5..a9084862 100644 --- a/bin/src/config/project/mod.rs +++ b/bin/src/config/project/mod.rs @@ -98,6 +98,15 @@ impl Configuration { &self.lint } + /// The folder name to use for the release + /// Default: `@{prefix}` + pub fn folder_name(&self) -> String { + self.hemtt() + .release() + .folder() + .map_or_else(|| self.prefix().to_string(), |folder| folder) + } + /// Load a configuration from a file. /// /// # Errors diff --git a/bin/src/modules/archive.rs b/bin/src/modules/archive.rs index 9d8ac96f..ee5678ee 100644 --- a/bin/src/modules/archive.rs +++ b/bin/src/modules/archive.rs @@ -29,7 +29,11 @@ pub fn release(ctx: &Context) -> Result<(), Error> { if path.is_empty() { continue; } - let dir = format!("@{}/{}", ctx.config().prefix(), path.replace('\\', "/")); + let dir = format!( + "@{}/{}", + ctx.config().folder_name(), + path.replace('\\', "/") + ); debug!("zip: creating directory {:?}", dir); zip.add_directory(dir, options)?; continue; @@ -39,7 +43,7 @@ pub fn release(ctx: &Context) -> Result<(), Error> { .expect("We are in the HEMTT folder, the prefix should always exist"); let file = format!( "@{}/{}", - ctx.config().prefix(), + ctx.config().folder_name(), name.display().to_string().replace('\\', "/") ); debug!("zip: adding file {:?}", file); diff --git a/bin/src/modules/pbo.rs b/bin/src/modules/pbo.rs index e133a36a..72e98079 100644 --- a/bin/src/modules/pbo.rs +++ b/bin/src/modules/pbo.rs @@ -59,7 +59,7 @@ fn _build( let mut pbo = WritablePbo::new(); let target = ctx.out_folder(); - let pbo_name = addon.pbo_name(ctx.config().prefix()); + let pbo_name = addon.pbo_name(&ctx.config().folder_name()); let target_pbo = { let mut path = match collapse { diff --git a/bin/src/modules/sign.rs b/bin/src/modules/sign.rs index 3e0e6120..a7682a01 100644 --- a/bin/src/modules/sign.rs +++ b/bin/src/modules/sign.rs @@ -37,7 +37,7 @@ impl Module for Sign { .join(format!("{authority}.bikey")), )?)?; ctx.addons().to_vec().iter().try_for_each(|addon| { - let pbo_name = addon.pbo_name(ctx.config().prefix()); + let pbo_name = addon.pbo_name(&ctx.config().folder_name()); let (mut pbo, sig_location, key) = match addon.location() { Location::Addons => { let target_pbo = {