windows fix process windows for solvers

This commit is contained in:
Jess 2026-05-23 09:58:57 -07:00
parent 8e01eff876
commit 54f2b93aca
1 changed files with 15 additions and 4 deletions

View File

@ -2068,7 +2068,7 @@ fn compute_frame(base: FemmDoc, tracks: Vec<kinematic::Track>, frame_idx: i64, d
title: String::from("frame save .pbc failed"), title: String::from("frame save .pbc failed"),
body: format!("{pbc_path:?}\n\n{e}"), body: format!("{pbc_path:?}\n\n{e}"),
})?; })?;
let tri_out = std::process::Command::new(&triangle) let tri_out = quiet_command(&triangle)
.args([ .args([
"-p", "-P", "-e", "-A", "-a", "-z", "-Q", "-I", "-p", "-P", "-e", "-A", "-a", "-z", "-Q", "-I",
&format!("-q{min_angle}"), &format!("-q{min_angle}"),
@ -2107,7 +2107,7 @@ fn compute_frame(base: FemmDoc, tracks: Vec<kinematic::Track>, frame_idx: i64, d
title: String::from("femm-mag-solve binary missing"), title: String::from("femm-mag-solve binary missing"),
body: String::from("run `cargo xtask install`"), body: String::from("run `cargo xtask install`"),
})?; })?;
let solver_out = std::process::Command::new(&helper) let solver_out = quiet_command(&helper)
.arg(&stem_str) .arg(&stem_str)
.output() .output()
.map_err(|e| ErrorReport { .map_err(|e| ErrorReport {
@ -2449,7 +2449,7 @@ fn run_mesh(doc: &FemmDoc) -> Result<Mesh, ErrorReport> {
body: format!("{stem:?}"), body: format!("{stem:?}"),
})?; })?;
let min_angle = if doc.min_angle > 0.0 { doc.min_angle } else { MIN_ANGLE_DEG }; let min_angle = if doc.min_angle > 0.0 { doc.min_angle } else { MIN_ANGLE_DEG };
let output = std::process::Command::new(&triangle) let output = quiet_command(&triangle)
.args([ .args([
"-p", "-P", "-e", "-A", "-a", "-z", "-Q", "-I", "-p", "-P", "-e", "-A", "-a", "-z", "-Q", "-I",
&format!("-q{min_angle}"), &format!("-q{min_angle}"),
@ -2489,7 +2489,7 @@ fn run_solve(stem: &Path) -> Result<(), ErrorReport> {
body: String::from("run `cargo xtask install` (or set $FEMM_MAG_SOLVE to the femm-mag-solve executable)"), body: String::from("run `cargo xtask install` (or set $FEMM_MAG_SOLVE to the femm-mag-solve executable)"),
})?; })?;
let output = std::process::Command::new(&helper) let output = quiet_command(&helper)
.arg(stem_str) .arg(stem_str)
.output() .output()
.map_err(|e| ErrorReport { .map_err(|e| ErrorReport {
@ -2547,6 +2547,17 @@ fn unix_signal(status: &std::process::ExitStatus) -> Option<i32> {
#[cfg(not(unix))] #[cfg(not(unix))]
fn unix_signal(_status: &std::process::ExitStatus) -> Option<i32> { None } fn unix_signal(_status: &std::process::ExitStatus) -> Option<i32> { None }
fn quiet_command(program: &std::path::Path) -> std::process::Command {
let mut cmd = std::process::Command::new(program);
#[cfg(windows)]
{
use std::os::windows::process::CommandExt;
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
cmd.creation_flags(CREATE_NO_WINDOW);
}
cmd
}
/// resolves the femm-mag-solve helper path from the bundled app, the dev target dir, or $FEMM_MAG_SOLVE. /// resolves the femm-mag-solve helper path from the bundled app, the dev target dir, or $FEMM_MAG_SOLVE.
fn locate_mag_solver() -> Option<std::path::PathBuf> { fn locate_mag_solver() -> Option<std::path::PathBuf> {
let exe_name = format!("femm-mag-solve{}", std::env::consts::EXE_SUFFIX); let exe_name = format!("femm-mag-solve{}", std::env::consts::EXE_SUFFIX);