Skip to content

Commit 399332f

Browse files
committed
feat(codspeed): add instrument-hooks
1 parent 33c4117 commit 399332f

10 files changed

Lines changed: 346 additions & 250 deletions

File tree

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
[submodule "crates/divan_compat/examples/src/the_algorithms/Rust"]
33
path = crates/divan_compat/examples/src/the_algorithms/Rust
44
url = https://github.com/TheAlgorithms/Rust.git
5+
[submodule "crates/codspeed/instrument-hooks"]
6+
path = crates/codspeed/instrument-hooks
7+
url = https://github.com/CodSpeedHQ/instrument-hooks

Cargo.lock

Lines changed: 108 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/codspeed/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,7 @@ harness = false
3535

3636
[dev-dependencies]
3737
tempfile = { workspace = true }
38+
39+
[build-dependencies]
40+
bindgen = "0.72.1"
41+
cc = "1.0"

crates/codspeed/build.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use std::{env, path::PathBuf};
2+
3+
fn main() {
4+
// Compile the C library
5+
cc::Build::new()
6+
.file("instrument-hooks/dist/core.c")
7+
.include("instrument-hooks/includes")
8+
.compile("instrument_hooks");
9+
10+
let bindings = bindgen::Builder::default()
11+
.header("instrument-hooks/includes/core.h")
12+
// Tell cargo to invalidate the built crate whenever any of the
13+
// included header files changed.
14+
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
15+
.generate()
16+
.expect("Unable to generate bindings");
17+
18+
// Write the bindings to the $OUT_DIR/bindings.rs file.
19+
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
20+
bindings
21+
.write_to_file(out_path.join("bindings.rs"))
22+
.expect("Couldn't write bindings!");
23+
}

crates/codspeed/instrument-hooks

Submodule instrument-hooks added at 202ff68

0 commit comments

Comments
 (0)