MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / compile_cpp_project

Function compile_cpp_project

crates/memtrack/tests/cpp_tests.rs:14–25  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

12/// Builds are serialized: parallel test cases share the build dir, and the
13/// retry path deletes it.
14fn 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
27fn build_cpp_target(project_dir: &Path, target: &str) -> anyhow::Result<std::path::PathBuf> {
28 let build_exists = project_dir.join("build").exists();

Callers 1

test_cpp_alloc_trackingFunction · 0.85

Calls 1

build_cpp_targetFunction · 0.85

Tested by

no test coverage detected