A cached cmake configure pins absolute library paths from a previous environment (e.g. garbage-collected nix store entries). On failure, wipe the build dir and retry once from a fresh configure. Builds are serialized: parallel test cases share the build dir, and the retry path deletes it.
(project_dir: &Path, target: &str)
| 12 | /// Builds are serialized: parallel test cases share the build dir, and the |
| 13 | /// retry path deletes it. |
| 14 | fn compile_cpp_project(project_dir: &Path, target: &str) -> anyhow::Result<std::path::PathBuf> { |
| 15 | static BUILD_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(()); |
| 16 | let _guard = BUILD_LOCK.lock().unwrap(); |
| 17 | |
| 18 | match build_cpp_target(project_dir, target) { |
| 19 | Ok(path) => Ok(path), |
| 20 | Err(_) => { |
| 21 | std::fs::remove_dir_all(project_dir.join("build"))?; |
| 22 | build_cpp_target(project_dir, target) |
| 23 | } |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | fn build_cpp_target(project_dir: &Path, target: &str) -> anyhow::Result<std::path::PathBuf> { |
| 28 | let build_exists = project_dir.join("build").exists(); |
no test coverage detected