Mercurial > crates > nonstick
diff libpam-sys/libpam-sys-test/build.rs @ 136:efbc235f01d3
Separate libpam-sys-helpers from libpam-sys.
This separates the parts of libpam-sys that don't need linking against libpam
from the parts that do need to link against libpam.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Thu, 03 Jul 2025 14:28:04 -0400 |
parents | 6c1e1bdb4164 |
children | 88627c057709 |
line wrap: on
line diff
--- a/libpam-sys/libpam-sys-test/build.rs Thu Jul 03 11:14:49 2025 -0400 +++ b/libpam-sys/libpam-sys-test/build.rs Thu Jul 03 14:28:04 2025 -0400 @@ -1,5 +1,6 @@ use bindgen::MacroTypeVariation; -use libpam_sys::pam_impl::PamImpl; +use libpam_sys_helpers::pam_impl::PamImpl; +use libpam_sys_helpers::{pam_impl, pam_impl_name}; use proc_macro2::{Group, Ident, TokenStream, TokenTree}; use quote::{format_ident, ToTokens}; use std::path::Path; @@ -11,6 +12,7 @@ const REDIR_FD: &str = "pam_modutil_redirect_fd"; fn main() { + pam_impl::enable_pam_impl_cfg(); let config = match PamImpl::CURRENT { PamImpl::LinuxPam => TestConfig { headers: vec![ @@ -67,8 +69,7 @@ let generated = builder.generate().unwrap(); generated.write_to_file(test_file("bindgen.rs")).unwrap(); let file = syn::parse_file(&generated.to_string()).unwrap(); - let mut tests = vec![ - "\ + let mut tests = vec!["\ #[allow(dead_code, non_camel_case_types, non_upper_case_globals)] mod generated { include!(\"bindgen.rs\"); @@ -78,7 +79,7 @@ " .into(), format!( - "assert_eq!(libpam_sys::PamImpl::CURRENT, libpam_sys::PamImpl::{:?});", + "assert_eq!(libpam_sys::pam_impl::PamImpl::CURRENT, libpam_sys::pam_impl::PamImpl::{:?});", PamImpl::CURRENT ), ]; @@ -110,7 +111,7 @@ fn generate_ctest(config: &TestConfig) { let mut test = ctest::TestGenerator::new(); - test.cfg("_hack_impl", Some(&format!("{:?}", PamImpl::CURRENT))); + test.cfg("pam_impl", Some(pam_impl_name!())); for &header in config.headers.iter() { if header.starts_with('"') { @@ -143,7 +144,7 @@ test.define("const", Some("")); // Also replace all the `const`s with `mut`s in the ffi.rs file. - let file_contents = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../src/ffi.rs")); + let file_contents = include_str!("../src/lib.rs"); let deconsted_file = test_file("ffi.rs"); remove_consts(file_contents, &deconsted_file);