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

Function build_cpp_target

crates/memtrack/tests/cpp_tests.rs:27–62  ·  view source on GitHub ↗
(project_dir: &Path, target: &str)

Source from the content-addressed store, hash-verified

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();
29 if !build_exists {
30 // Configure with cmake -B build
31 let config = Command::new("cmake")
32 .current_dir(project_dir)
33 .args(["-B", "build", "-DCMAKE_BUILD_TYPE=Release"])
34 .output()?;
35
36 if !config.status.success() {
37 eprintln!(
38 "cmake configure failed: {}",
39 String::from_utf8_lossy(&config.stderr)
40 );
41 return Err(anyhow::anyhow!("Failed to configure C++ project"));
42 }
43 }
44
45 // Build specific target
46 let build = Command::new("cmake")
47 .current_dir(project_dir)
48 .args(["--build", "build", "--target", target, "-j"])
49 .output()?;
50
51 if !build.status.success() {
52 eprintln!(
53 "cmake build failed: {}",
54 String::from_utf8_lossy(&build.stderr)
55 );
56 eprintln!("cmake stdout: {}", String::from_utf8_lossy(&build.stdout));
57 return Err(anyhow::anyhow!("Failed to build target: {target}"));
58 }
59
60 let binary_path = project_dir.join(format!("build/{target}"));
61 Ok(binary_path)
62}
63
64#[test_with::env(GITHUB_ACTIONS)]
65#[rstest]

Callers 1

compile_cpp_projectFunction · 0.85

Calls 2

argsMethod · 0.80
current_dirMethod · 0.80

Tested by

no test coverage detected