diff options
| author | Folkert de Vries <folkert@folkertdev.nl> | 2025-07-10 20:30:36 +0200 |
|---|---|---|
| committer | Folkert de Vries <folkert@folkertdev.nl> | 2025-07-18 11:38:18 +0200 |
| commit | 75887cf99557c84ebb64077a1b3f96ad8a597c22 (patch) | |
| tree | 046ae9431659451833bf6e6c1b7fd4c77a95250a /library/stdarch/crates/intrinsic-test/src/common/gen_c.rs | |
| parent | 668fdbe41edba8bda2100a71fe412ab62322b8d5 (diff) | |
| download | rust-75887cf99557c84ebb64077a1b3f96ad8a597c22.tar.gz rust-75887cf99557c84ebb64077a1b3f96ad8a597c22.zip | |
improve cpp compiler execution
Diffstat (limited to 'library/stdarch/crates/intrinsic-test/src/common/gen_c.rs')
| -rw-r--r-- | library/stdarch/crates/intrinsic-test/src/common/gen_c.rs | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/library/stdarch/crates/intrinsic-test/src/common/gen_c.rs b/library/stdarch/crates/intrinsic-test/src/common/gen_c.rs index 1cfb66c39b9..84167f2f4ae 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/gen_c.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/gen_c.rs @@ -1,7 +1,8 @@ use itertools::Itertools; use rayon::prelude::*; use std::collections::BTreeMap; -use std::process::Command; + +use crate::common::compile_c::CppCompilation; use super::argument::Argument; use super::indentation::Indentation; @@ -62,29 +63,30 @@ int main(int argc, char **argv) {{ ) } -pub fn compile_c_programs(compiler_commands: &[String]) -> bool { - compiler_commands +pub fn compile_c_programs(pipeline: &CppCompilation, intrinsics: &[String]) -> bool { + intrinsics .par_iter() - .map(|compiler_command| { - let output = Command::new("sh").arg("-c").arg(compiler_command).output(); - if let Ok(output) = output { - if output.status.success() { - true - } else { - error!( - "Failed to compile code for intrinsics: \n\nstdout:\n{}\n\nstderr:\n{}", + .map( + |intrinsic| match pipeline.run(&[format!("{intrinsic}.cpp")], intrinsic) { + Ok(output) if output.status.success() => Ok(()), + Ok(output) => { + let msg = format!( + "Failed to compile code for intrinsic `{intrinsic}`: \n\nstdout:\n{}\n\nstderr:\n{}", std::str::from_utf8(&output.stdout).unwrap_or(""), std::str::from_utf8(&output.stderr).unwrap_or("") ); - false + error!("{msg}"); + + Err(msg) } - } else { - error!("Command failed: {output:#?}"); - false - } - }) - .find_any(|x| !x) - .is_none() + Err(e) => { + error!("command for `{intrinsic}` failed with IO error: {e:?}"); + Err(e.to_string()) + } + }, + ) + .collect::<Result<(), String>>() + .is_ok() } // Creates directory structure and file path mappings |
