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

35 lines
1.2 KiB
Rust

// SPDX-FileCopyrightText: 2022 Matteo Settenvini <matteo.settenvini@montecristosoftware.eu>
// SPDX-License-Identifier: GPL-3.0-or-later
extern crate bindgen;
use {std::env, std::path::PathBuf};
fn main() {
let out_dir = std::env::var("OUT_DIR").unwrap();
println!("cargo:rerun-if-changed=wrapper.h");
// Required by NSS 2
println!("cargo:rustc-cdylib-link-arg=-Wl,-soname,libnss_malcontent.so.2");
// Enable dynamic loading of NSS module from OUT_DIR
// (see https://doc.rust-lang.org/cargo/reference/environment-variables.html#dynamic-library-paths)
println!("cargo:rustc-link-search={}", &out_dir);
let bindings = bindgen::Builder::default()
.header("wrapper.h")
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.newtype_enum("nss_status")
.allowlist_type("nss_status")
.allowlist_type("gaih_addrtuple")
.allowlist_function("__nss_configure_lookup")
.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!");
}