Mercurial > crates > nonstick
comparison libpam-sys/libpam-sys-test/build.rs @ 113:178310336596
Fix up more constants, make things i32 rather than u32.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Sun, 29 Jun 2025 03:11:33 -0400 |
parents | 04105e9a7de8 |
children | 93d423b65555 |
comparison
equal
deleted
inserted
replaced
112:82995b4dccee | 113:178310336596 |
---|---|
1 use bindgen::MacroTypeVariation; | 1 use bindgen::MacroTypeVariation; |
2 use libpam_sys_impls::cfg_pam_impl; | 2 use libpam_sys_impls::cfg_pam_impl; |
3 use quote::ToTokens; | 3 use quote::{format_ident, ToTokens}; |
4 use std::path::PathBuf; | 4 use std::path::PathBuf; |
5 use std::{env, fs}; | 5 use std::{env, fs}; |
6 use syn::{Item, ItemConst}; | 6 use syn::{Ident, Item, ItemConst, Path, Type, TypePath}; |
7 | 7 |
8 fn main() { | 8 fn main() { |
9 generate_const_test(); | 9 generate_const_test(); |
10 } | 10 } |
11 | 11 |
29 "security/pam_types.h".into(), | 29 "security/pam_types.h".into(), |
30 "security/openpam.h".into(), | 30 "security/openpam.h".into(), |
31 "security/pam_appl.h".into(), | 31 "security/pam_appl.h".into(), |
32 "security/pam_constants.h".into(), | 32 "security/pam_constants.h".into(), |
33 ], | 33 ], |
34 ignore_consts: vec![], | 34 ignore_consts: vec!["OPENPAM_VERSION"], |
35 } | 35 } |
36 } | 36 } |
37 | 37 |
38 #[cfg_pam_impl(not(any("LinuxPam", "OpenPam")))] | 38 #[cfg_pam_impl(not(any("LinuxPam", "OpenPam")))] |
39 fn test_config() -> TestConfig { | 39 fn test_config() -> TestConfig { |
64 } else { | 64 } else { |
65 None | 65 None |
66 } | 66 } |
67 }) | 67 }) |
68 .filter(|item| config.should_check_const(item)) | 68 .filter(|item| config.should_check_const(item)) |
69 .map(|item| { | 69 .cloned() |
70 let tokens = item.expr.to_token_stream(); | 70 .map(|mut item| { |
71 item.ty = Box::new(Type::Path(TypePath { | |
72 qself: None, | |
73 path: format_ident!("i32").into(), | |
74 })); | |
71 format!( | 75 format!( |
72 "assert_eq!({tokens}, libpam_sys::{name});", | 76 "assert_eq!({tokens}, libpam_sys::{name});", |
77 tokens = item.expr.to_token_stream(), | |
73 name = item.ident | 78 name = item.ident |
74 ) | 79 ) |
75 }), | 80 }), |
76 ); | 81 ); |
77 tests.push("}".into()); | 82 tests.push("}".into()); |