Skip to content

Commit 3995f17

Browse files
milesialrakhmets
andauthored
Fix rust build with stubs (#1001)
* Fix rust build with stubs Signed-off-by: Alexandre Milesi <[email protected]> * Add stub build test Signed-off-by: Alexandre Milesi <[email protected]> --------- Signed-off-by: Alexandre Milesi <[email protected]> Co-authored-by: Raul Akhmetshin <[email protected]>
1 parent 2de618b commit 3995f17

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

.gitlab/test_rust.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,7 @@ export NIXL_PREFIX=${INSTALL_DIR}
4646

4747
cargo test -- --test-threads=1
4848

49+
# test stubs build
50+
cargo build --features stub-api
51+
4952
cargo package

src/bindings/rust/build.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,21 @@ fn build_stubs(cc_builder: &mut cc::Build) {
201201
// Tell cargo to invalidate the built crate whenever the stubs change
202202
println!("cargo:rerun-if-changed=stubs.cpp");
203203
println!("cargo:rerun-if-changed=wrapper.h");
204+
205+
// Get the output path for bindings
206+
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
207+
208+
// Generate bindings with minimal configuration
209+
bindgen::Builder::default()
210+
.header("wrapper.h")
211+
.clang_arg("-std=c++17")
212+
.clang_arg("-x")
213+
.clang_arg("c++")
214+
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
215+
.generate()
216+
.expect("Unable to generate bindings")
217+
.write_to_file(out_path.join("bindings.rs"))
218+
.expect("Couldn't write bindings!");
204219
}
205220

206221
fn run_build(use_stub_api: bool) {

0 commit comments

Comments
 (0)