more cleaning for build.rs
This commit is contained in:
parent
4ab010e781
commit
43d8f3a101
2 changed files with 24 additions and 15 deletions
|
|
@ -30,6 +30,7 @@ nix-main-c = []
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
bindgen = { default-features = false, features = [ "logging", "runtime" ], version = "0.72.1" }
|
bindgen = { default-features = false, features = [ "logging", "runtime" ], version = "0.72.1" }
|
||||||
doxygen-bindgen = "0.1.3"
|
doxygen-bindgen = "0.1.3"
|
||||||
|
itertools = "0.14.0"
|
||||||
pkg-config.workspace = true
|
pkg-config.workspace = true
|
||||||
cc.workspace = true
|
cc.workspace = true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ use std::path::PathBuf;
|
||||||
use std::{env, fs};
|
use std::{env, fs};
|
||||||
|
|
||||||
use bindgen::callbacks::ParseCallbacks;
|
use bindgen::callbacks::ParseCallbacks;
|
||||||
|
use itertools::Itertools;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct DoxygenCallbacks;
|
struct DoxygenCallbacks;
|
||||||
|
|
@ -18,6 +19,7 @@ impl ParseCallbacks for DoxygenCallbacks {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WARNING: NOTE: the random panic occurs when you're missing imports!!
|
||||||
const LIBS: &[&'static str] = &[
|
const LIBS: &[&'static str] = &[
|
||||||
#[cfg(feature = "nix-util-c")]
|
#[cfg(feature = "nix-util-c")]
|
||||||
"nix-util-c",
|
"nix-util-c",
|
||||||
|
|
@ -37,26 +39,32 @@ fn main() {
|
||||||
// Invalidate the built crate if the binding headers change
|
// Invalidate the built crate if the binding headers change
|
||||||
// println!("cargo::rerun-if-changed=include");
|
// println!("cargo::rerun-if-changed=include");
|
||||||
|
|
||||||
let lib_args: Vec<String> = LIBS
|
let lib_args: Vec<String> = vec![ /* EXTRA ARGS */ ]
|
||||||
.iter()
|
.into_iter()
|
||||||
.map(|&name| {
|
.map(|s: &str| s.to_owned())
|
||||||
let lib = pkg_config::probe_library(name)
|
.chain(
|
||||||
.expect(&format!("Unable to find .pc file for {}", name));
|
LIBS.iter()
|
||||||
|
.map(|&name| {
|
||||||
|
let lib = pkg_config::probe_library(name)
|
||||||
|
.expect(&format!("Unable to find .pc file for {}", name));
|
||||||
|
|
||||||
for p in lib.link_files {
|
for p in lib.link_files {
|
||||||
println!("cargo::rustc-link-lib={}", p.display());
|
println!("cargo::rustc-link-lib={}", p.display());
|
||||||
}
|
}
|
||||||
|
|
||||||
lib.include_paths
|
lib.include_paths
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|p| format!("-I{}", p.display()))
|
.map(|p| format!("-I{}", p.display()))
|
||||||
})
|
})
|
||||||
.flatten()
|
.flatten(),
|
||||||
.chain(vec!["-Wall".to_owned(), "-xc++".to_owned()])
|
)
|
||||||
|
.unique()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
dbg!(&lib_args);
|
||||||
|
|
||||||
let mut builder = bindgen::Builder::default()
|
let mut builder = bindgen::Builder::default()
|
||||||
// .clang_arg("") // libnix uses c++23
|
// .enable_cxx_namespaces()
|
||||||
.clang_args(lib_args)
|
.clang_args(lib_args)
|
||||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
|
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
|
||||||
// Add `doxygen_bindgen` callbacks
|
// Add `doxygen_bindgen` callbacks
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue