Mercurial > crates > nonstick
comparison libpam-sys/libpam-sys-test/build.rs @ 134:6c1e1bdb4164
Use standard #[cfg] directives rather than custom proc macros.
Instead of having to do a bunch of custom parsing and other logic
that tools often choke on, this change introduces an easy way
to depend upon custom #[cfg]s provided by the libpam-sys crate.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Thu, 03 Jul 2025 11:03:36 -0400 |
parents | 0b6a17f8c894 |
children | efbc235f01d3 |
comparison
equal
deleted
inserted
replaced
133:32b2a545ca3e | 134:6c1e1bdb4164 |
---|---|
1 use bindgen::MacroTypeVariation; | 1 use bindgen::MacroTypeVariation; |
2 use libpam_sys_impls::__pam_impl_enum__; | 2 use libpam_sys::pam_impl::PamImpl; |
3 use proc_macro2::{Group, Ident, TokenStream, TokenTree}; | 3 use proc_macro2::{Group, Ident, TokenStream, TokenTree}; |
4 use quote::{format_ident, ToTokens}; | 4 use quote::{format_ident, ToTokens}; |
5 use std::path::Path; | 5 use std::path::Path; |
6 use std::process::Command; | 6 use std::process::Command; |
7 use std::str::FromStr; | 7 use std::str::FromStr; |
8 use std::{env, fs}; | 8 use std::{env, fs}; |
9 use syn::{Item, ItemConst}; | 9 use syn::{Item, ItemConst}; |
10 | |
11 // We're using the macro directly so we can match exhaustively. | |
12 __pam_impl_enum__!(); | |
13 | 10 |
14 const REDIR_FD: &str = "pam_modutil_redirect_fd"; | 11 const REDIR_FD: &str = "pam_modutil_redirect_fd"; |
15 | 12 |
16 fn main() { | 13 fn main() { |
17 let config = match PamImpl::CURRENT { | 14 let config = match PamImpl::CURRENT { |
47 }, | 44 }, |
48 PamImpl::XSso => TestConfig { | 45 PamImpl::XSso => TestConfig { |
49 headers: vec!["\"xsso_pam_appl.h\""], | 46 headers: vec!["\"xsso_pam_appl.h\""], |
50 ..Default::default() | 47 ..Default::default() |
51 }, | 48 }, |
49 other => panic!("PAM implementation {other:?} is not yet tested"), | |
52 }; | 50 }; |
53 generate_const_test(&config); | 51 generate_const_test(&config); |
54 generate_ctest(&config); | 52 generate_ctest(&config); |
55 } | 53 } |
56 | 54 |