Skip to content

Commit

Permalink
specify folder name
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson committed Mar 26, 2023
1 parent c153946 commit 9e1b87c
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
Expand Down
9 changes: 9 additions & 0 deletions bin/src/config/project/hemtt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
#[serde(default)]
/// Should the PBOs be signed?
/// Default: true
Expand All @@ -145,6 +149,11 @@ pub struct ReleaseOptions {
}

impl ReleaseOptions {
#[must_use]
pub fn folder(&self) -> Option<String> {
self.folder.clone()
}

#[must_use]
pub const fn sign(&self) -> bool {
if let Some(sign) = self.sign {
Expand Down
9 changes: 9 additions & 0 deletions bin/src/config/project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions bin/src/modules/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion bin/src/modules/pbo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion bin/src/modules/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 9e1b87c

Please sign in to comment.