Skip to content

Commit

Permalink
fix binarize on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson committed Oct 18, 2024
1 parent 41876bd commit 246d1c2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 27 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ jobs:
HEMTT_BI_TOOLS: /tmp/arma3tools
run: |
cd mod && hemtt build
- name: Tree
if: always()
run: |
tree /tmp/hemtt/runner/runner_work_HEMTT_HEMTT_mod
release:
name: Release
Expand Down
31 changes: 14 additions & 17 deletions bin/src/modules/binarize/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ impl Module for Binarize {
};

let mut report = Report::new();
let tmp_source = ctx.tmp().join("source");
let tmp_out = tmp_source.join("hemtt_binarize_output");
let tmp_out = ctx.tmp().join("hemtt_binarize_output");
let search_cache = SearchCache::new();
if let Some(pdrive) = ctx.workspace().pdrive() {
info!("P Drive at {}", pdrive.link().display());
Expand Down Expand Up @@ -201,7 +200,7 @@ impl Module for Binarize {
}
}

let tmp_sourced = tmp_source.join(addon.prefix().as_pathbuf()).join(
let tmp_sourced = ctx.tmp().join(addon.prefix().as_pathbuf()).join(
entry
.as_str()
.trim_start_matches('/')
Expand Down Expand Up @@ -245,7 +244,6 @@ impl Module for Binarize {
}
let mut report = Report::new();
let counter = AtomicU16::new(0);
let tmp_source = ctx.tmp().join("source");
self.prechecked
.read()
.expect("can read in pre_build")
Expand Down Expand Up @@ -275,17 +273,17 @@ impl Module for Binarize {
"-maxProcesses=0",
&target
.source
.trim_start_matches(tmp_source.to_str().expect("path is valid utf-8"))
.trim_start_matches(ctx.tmp().to_str().expect("path is valid utf-8"))
.trim_start_matches('/')
.replace('/', "\\"),
&target
.output
.trim_start_matches(tmp_source.to_str().expect("path is valid utf-8"))
.trim_start_matches(ctx.tmp().to_str().expect("path is valid utf-8"))
.trim_start_matches('/')
.replace('/', "\\"),
&target.entry.replace('/', "\\"),
])
.current_dir(&tmp_source);
.current_dir(ctx.tmp());
trace!("{:?}", cmd);
let output = cmd.output().expect("should be able to run binarize");
assert!(
Expand Down Expand Up @@ -329,15 +327,12 @@ fn check_signature(buf: [u8; 4]) -> bool {
}

fn setup_tmp(ctx: &Context) -> Result<(), Error> {
let tmp = ctx.tmp().join("source");
create_dir_all(&tmp)?;
create_dir_all(tmp.join("hemtt_binarize_output"))?;
create_dir_all(ctx.tmp())?;
create_dir_all(ctx.tmp().join("hemtt_binarize_output"))?;
for addon in ctx.all_addons() {
let tmp_addon = tmp.join(addon.prefix().as_pathbuf());
let tmp_addon = ctx.tmp().join(addon.prefix().as_pathbuf());
create_dir_all(tmp_addon.parent().expect("tmp addon should have a parent"))?;
let target = ctx
.project_folder()
.join(addon.folder().as_str().trim_start_matches('/'));
let target = ctx.project_folder().join(addon.folder_pathbuf());
create_link(&tmp_addon, &target)?;
}
// maybe replace with config or rhai in the future?
Expand All @@ -347,7 +342,9 @@ fn setup_tmp(ctx: &Context) -> Result<(), Error> {
if file.is_dir() {
continue;
}
let tmp_file = tmp.join(file.file_name().expect("file should have a name"));
let tmp_file = ctx
.tmp()
.join(file.file_name().expect("file should have a name"));
if file.metadata()?.len() > 1024 * 1024 * 10 {
warn!(
"File `{}` is larger than 10MB, this will slow builds.",
Expand Down Expand Up @@ -375,7 +372,7 @@ fn setup_tmp(ctx: &Context) -> Result<(), Error> {
continue;
}
if outer_prefix.is_dir() {
let tmp_outer_prefix = tmp.join(
let tmp_outer_prefix = ctx.tmp().join(
outer_prefix
.file_name()
.expect("outer prefix should have a name"),
Expand All @@ -399,6 +396,6 @@ fn setup_tmp(ctx: &Context) -> Result<(), Error> {
let Some(pdrive) = ctx.workspace().pdrive() else {
return Ok(());
};
create_link(&tmp.join("a3"), &pdrive.link())?;
create_link(&ctx.tmp().join("a3"), &pdrive.link())?;
Ok(())
}
6 changes: 1 addition & 5 deletions bin/src/modules/file_patching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ impl Module for FilePatching {
.expect("build folder exists")
.join("addons")
.join(addon.name().replace('/', "\\")),
&ctx.project_folder().join(if cfg!(windows) {
addon.folder().replace('/', "\\")
} else {
addon.folder()
}),
&ctx.project_folder().join(addon.folder_pathbuf()),
)
})
.collect::<Result<(), Error>>()?;
Expand Down
9 changes: 8 additions & 1 deletion libs/workspace/src/addons.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::fmt::Display;
use std::ops::Range;
use std::path::Path;
use std::path::{Path, PathBuf};
use std::sync::{Arc, RwLock};
use std::{fs::DirEntry, str::FromStr};

Expand Down Expand Up @@ -103,12 +103,19 @@ impl Addon {
}

#[must_use]
/// The addon's path from the root
/// addons/foobar
/// optionals/foobar
pub fn folder(&self) -> String {
format!("{}/{}", self.location, self.name)
}

#[must_use]
/// The addon's path from the root, as a `PathBuf`
pub fn folder_pathbuf(&self) -> PathBuf {
PathBuf::from(self.location.to_string()).join(&self.name)
}

#[must_use]
pub const fn config(&self) -> Option<&AddonConfig> {
self.config.as_ref()
Expand Down

0 comments on commit 246d1c2

Please sign in to comment.