bindgen strip nix_ prefix

(cherry picked from commit d07ec1990015f5d12b39da40ad0cb1ef0e798642)
This commit is contained in:
Taeer Bar-Yam 2024-05-09 12:29:32 -04:00 committed by Robert Hensing
parent 1edaffcc09
commit c2159c8834
6 changed files with 32 additions and 23 deletions

View file

@ -2,6 +2,14 @@ use bindgen;
use std::env;
use std::path::PathBuf;
#[derive(Debug)]
struct StripNixPrefix {}
impl bindgen::callbacks::ParseCallbacks for StripNixPrefix {
fn item_name(&self, name: &str) -> Option<String> {
name.strip_prefix("nix_").map(String::from)
}
}
fn main() {
// Tell cargo to invalidate the built crate whenever the wrapper changes
println!("cargo:rerun-if-changed=include/nix-c-raw.h");
@ -14,6 +22,7 @@ fn main() {
// Tell cargo to invalidate the built crate whenever any of the
// included header files changed.
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.parse_callbacks(Box::new(StripNixPrefix {}))
// Finish the builder and generate the bindings.
.generate()
// Unwrap the Result and panic on failure.