malcontent-dns-parental-con.../build.rs

31 lines
1.0 KiB
Rust
Raw Normal View History

2022-08-13 10:44:46 +02:00
// SPDX-FileCopyrightText: 2022 Matteo Settenvini <matteo.settenvini@montecristosoftware.eu>
// SPDX-License-Identifier: GPL-3.0-or-later
2022-08-13 10:32:40 +02:00
use {std::env, std::path::PathBuf};
fn main() {
println!("cargo:rerun-if-changed=wrapper.hpp");
2022-08-13 17:04:22 +02:00
// Required by NSS 2
2022-08-14 23:03:59 +02:00
println!("cargo:rustc-cdylib-link-arg=-Wl,-soname,libnss_malcontent.so.2");
2022-08-13 10:32:40 +02:00
let bindings = bindgen::Builder::default()
.header("wrapper.hpp")
2022-08-13 10:32:40 +02:00
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.newtype_enum("nss_status")
.allowlist_type("nss_status")
.newtype_enum("HErrno")
.allowlist_type("HErrno")
.newtype_enum("EaiRetcode")
.allowlist_type("EaiRetcode")
2022-08-13 10:32:40 +02:00
.allowlist_type("gaih_addrtuple")
2022-08-13 17:04:22 +02:00
.allowlist_function("__nss_configure_lookup")
2022-08-13 10:32:40 +02:00
.generate()
.expect("Unable to generate bindings");
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
}