Skip to content

Commit

Permalink
added a bunch of assertions and debug comments to track down where th…
Browse files Browse the repository at this point in the history
…e OS error in CI is comming from precicely
  • Loading branch information
CommanderStorm committed Feb 23, 2025
1 parent 58a70b4 commit 3769c02
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
Binary file modified logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 27 additions & 7 deletions martin/build.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
#[cfg(feature = "webui")]
/// copies a directory and its contents to a new location recursively
fn copy_dir_all(
src: impl AsRef<std::path::Path>,
dst: impl AsRef<std::path::Path>,
exclude_dirs: &[std::path::PathBuf],
) -> std::io::Result<()> {
assert!(!exclude_dirs.contains(&src.as_ref().to_path_buf()));
assert!(src.as_ref().is_dir(), "source for the copy operation is not an existing directory");
assert!(!dst.as_ref().exists(), "destination for the copy operation must not exist");
std::fs::create_dir_all(&dst)?;

for entry in std::fs::read_dir(src)? {
let entry = entry?;
let ty = entry.file_type()?;
let src_path = entry.path();
let dst_path = dst.as_ref().join(entry.file_name());
if ty.is_dir() {
copy_dir_all(entry.path(), dst.as_ref().join(entry.file_name()))?;
if exclude_dirs.contains(&src_path) {
continue;
}
copy_dir_all(src_path, &dst_path, exclude_dirs)?;
} else {
std::fs::copy(entry.path(), dst.as_ref().join(entry.file_name()))?;
std::fs::copy(src_path, dst_path)?;
}
}
Ok(())
Expand All @@ -25,15 +36,23 @@ fn main() -> std::io::Result<()> {
// - move the frontend code to the OUT_DIR,
// - install npm dependencies and
// - build the frontend
let martin_ui_dir = std::path::PathBuf::from("martin-ui");
assert!(martin_ui_dir.is_dir(), "martin-ui directory does not exist");
let out_dir = std::env::var("OUT_DIR")
.unwrap()
.parse::<std::path::PathBuf>()
.unwrap();
let new_dir = out_dir.join("martin-ui");
let target_to_keep = std::path::PathBuf::from("martin-ui").join("dist");
copy_dir_all("martin-ui", &new_dir)?;
let out_martin_ui_dir = out_dir.join("martin-ui");
if out_martin_ui_dir.exists() {
std::fs::remove_dir_all(&out_martin_ui_dir)?;
}
copy_dir_all(&martin_ui_dir, &out_martin_ui_dir, &[martin_ui_dir.join("dist"), martin_ui_dir.join("node_modules")])?;

let target_to_keep = martin_ui_dir.join("dist");
assert!(!target_to_keep.exists() || target_to_keep.is_dir(), "the martin-ui/dist must either not exist or have been produced by previous builds");

static_files::NpmBuild::new(&new_dir)
println!("installing and building in {out_martin_ui_dir:?}");
static_files::NpmBuild::new(&out_martin_ui_dir)
.install()?
.run("build")?
.target(&target_to_keep)
Expand All @@ -43,7 +62,8 @@ fn main() -> std::io::Result<()> {
//
// `copy_dir_all` was never anticipated by the crate we use
// => we need to do this with different arguments.
static_files::NpmBuild::new("martin-ui")
println!("success -> change_detection");
static_files::NpmBuild::new(martin_ui_dir)
.target(&target_to_keep)
.change_detection();
}
Expand Down

0 comments on commit 3769c02

Please sign in to comment.