clean sys/build.rs
This commit is contained in:
parent
eb3f19f4d2
commit
50aec26a39
2 changed files with 35 additions and 47 deletions
|
|
@ -92,36 +92,39 @@ const LIBS: &[&'static str] = &[
|
||||||
];
|
];
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let include_paths: Vec<PathBuf> = LIBS
|
let libs: Vec<pkg_config::Library> = LIBS
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&name| {
|
.map(|&name| {
|
||||||
let lib = pkg_config::probe_library(name)
|
pkg_config::probe_library(name).expect(&format!("Unable to find .pc file for {}", name))
|
||||||
.expect(&format!("Unable to find .pc file for {}", name));
|
|
||||||
|
|
||||||
for p in lib.link_files {
|
|
||||||
println!("cargo::rustc-link-lib={}", p.display());
|
|
||||||
}
|
|
||||||
|
|
||||||
lib.include_paths
|
|
||||||
})
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let include_paths: Vec<PathBuf> = libs
|
||||||
|
.clone()
|
||||||
|
.into_iter()
|
||||||
|
.map(|lib| lib.include_paths)
|
||||||
|
.flatten()
|
||||||
|
.unique()
|
||||||
|
.collect();
|
||||||
|
let link_paths: Vec<PathBuf> = libs
|
||||||
|
.clone()
|
||||||
|
.into_iter()
|
||||||
|
.map(|lib| lib.link_files)
|
||||||
.flatten()
|
.flatten()
|
||||||
.unique()
|
.unique()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
// let clang_target = format!(
|
// ::DEBUG:DEBUG::
|
||||||
// "--target={}",
|
// for path in link_paths {
|
||||||
// env::var("CARGO_BUILD_TARGET")
|
// println!("cargo::rustc-link-lib={}", path.display());
|
||||||
// .expect("Environment variable `CARGO_BUILD_TARGET` not set! nixide/build.rs won't be able to set pointer sizes correctly!"));
|
// }
|
||||||
let clang_args: Vec<String> = vec![
|
// ::DEBUG:DEBUG::
|
||||||
"-x",
|
|
||||||
"c++",
|
let clang_args: Vec<String> = vec!["-x", "c++", "-std=c++23"]
|
||||||
"-std=c++23",
|
.into_iter()
|
||||||
"--target=x86_64-unknown-linux-gnu", // DEBUG
|
.map(|s: &str| s.to_owned())
|
||||||
]
|
.chain(include_paths.iter().map(|p| format!("-I{}", p.display())))
|
||||||
.into_iter()
|
.collect();
|
||||||
.map(|s: &str| s.to_owned())
|
|
||||||
.chain(include_paths.iter().map(|p| format!("-I{}", p.display())))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
dbg!(&clang_args);
|
dbg!(&clang_args);
|
||||||
|
|
||||||
|
|
@ -139,7 +142,7 @@ fn main() {
|
||||||
// .files(LIBS.iter().map(|s| (*s).strip_prefix("nix-").unwrap().strip_suffix("-c").unwrap()))
|
// .files(LIBS.iter().map(|s| (*s).strip_prefix("nix-").unwrap().strip_suffix("-c").unwrap()))
|
||||||
.opt_level((!cfg!(debug_assertions)) as u32 * 3)
|
.opt_level((!cfg!(debug_assertions)) as u32 * 3)
|
||||||
.includes(&include_paths)
|
.includes(&include_paths)
|
||||||
.compile("libnixide");
|
.compile("nixide");
|
||||||
|
|
||||||
let mut builder = bindgen::Builder::default()
|
let mut builder = bindgen::Builder::default()
|
||||||
.rust_edition(RustEdition::Edition2024)
|
.rust_edition(RustEdition::Edition2024)
|
||||||
|
|
@ -152,26 +155,11 @@ fn main() {
|
||||||
.formatter(bindgen::Formatter::Rustfmt)
|
.formatter(bindgen::Formatter::Rustfmt)
|
||||||
.rustfmt_configuration_file(std::fs::canonicalize("rustfmt.toml").ok())
|
.rustfmt_configuration_file(std::fs::canonicalize("rustfmt.toml").ok())
|
||||||
// Control allow/block listing
|
// Control allow/block listing
|
||||||
.allowlist_recursively(true) // DEBUG(TEMP): should remain `false`
|
.allowlist_recursively(true)
|
||||||
// .allowlist_file(r".*nix_api_[a-z]+(_internal)?\.h")
|
// .allowlist_file(r".*nix_api_[a-z]+(_internal)?\.h")
|
||||||
.allowlist_file(r".*nix_api_[a-z]+\.h")
|
.allowlist_file(r".*nix_api_[a-z]+(/[a-z_]+)?\.h")
|
||||||
|
|
||||||
// .allowlist_type("nix_.*")
|
// .layout_tests(false) // DEBUG
|
||||||
// .allowlist_function("nix_.*")
|
|
||||||
// DEBUG
|
|
||||||
// .allowlist_type(r"nix_locked_flake")
|
|
||||||
// .allowlist_type(r"nix_flake_settings")
|
|
||||||
// .allowlist_type(r"nix_flake_reference")
|
|
||||||
// .allowlist_type(r"nix_flake_reference_parse_flags")
|
|
||||||
// .allowlist_type(r"nix_flake_lock_flags")
|
|
||||||
// DEBUG
|
|
||||||
|
|
||||||
// .allowlist_file(r".+-gcc-14\.3\.0/include/c\+\+/14\.3\.0/optional") // allow optional type
|
|
||||||
// .blocklist_file(r".*-gcc-[^/]+/include/c++/[0-9\.]+/^(optional).*") // allow optional type
|
|
||||||
// .blocklist_file(r".*-(glibc|clang-wrapper|boost)-.*") // block stdlib (gcc|glibc|clang-wrapper|boost)
|
|
||||||
// .blocklist_type(r".*Optional.*")
|
|
||||||
|
|
||||||
.layout_tests(false) // DEBUG
|
|
||||||
.use_core() // use ::core instead of ::std
|
.use_core() // use ::core instead of ::std
|
||||||
.ctypes_prefix("::core::ffi") // use ::core::ffi instead of ::std::os::raw
|
.ctypes_prefix("::core::ffi") // use ::core::ffi instead of ::std::os::raw
|
||||||
.time_phases(true)
|
.time_phases(true)
|
||||||
|
|
@ -182,13 +170,13 @@ fn main() {
|
||||||
.default_enum_style(bindgen::EnumVariation::Rust { non_exhaustive: false })
|
.default_enum_style(bindgen::EnumVariation::Rust { non_exhaustive: false })
|
||||||
// .translate_enum_integer_types(false)
|
// .translate_enum_integer_types(false)
|
||||||
.size_t_is_usize(true)
|
.size_t_is_usize(true)
|
||||||
.use_distinct_char16_t(false) // DEBUG (comment this)
|
// .use_distinct_char16_t(false) // DEBUG
|
||||||
.generate_comments(false)
|
.generate_comments(false)
|
||||||
.generate_cstr(true) // use &CStr instead of &[u8]
|
.generate_cstr(true) // use &CStr instead of &[u8]
|
||||||
.fit_macro_constants(true) // DEBUG (comment this)
|
.fit_macro_constants(false)
|
||||||
.explicit_padding(true)
|
.explicit_padding(true)
|
||||||
.enable_cxx_namespaces()
|
// .enable_cxx_namespaces()
|
||||||
.represent_cxx_operators(false) // DEBUG (comment this)
|
// .represent_cxx_operators(false) // DEBUG
|
||||||
.enable_function_attribute_detection()
|
.enable_function_attribute_detection()
|
||||||
.raw_line("/** These bindings were auto-generated for the Nixide project (https://github.com/cry128/nixide) */");
|
.raw_line("/** These bindings were auto-generated for the Nixide project (https://github.com/cry128/nixide) */");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ mod bindings {
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||||
}
|
}
|
||||||
pub use bindings::root::*;
|
pub use bindings::*;
|
||||||
|
|
||||||
mod exts;
|
mod exts;
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue