comparison libpam-sys/libpam-sys-test/build.rs @ 190:995aca290452

Restructure the way libpam-sys-impls works to fix cross-compilation. The previous structure of libpam-sys-impls meant that things got confusing (including for me) between what constants were build-time and what constants were run-time. This broke cross-compilation. This simplifies the way that works so that `libpam-sys-impls` has *no* build script itself and is intended mostly as a library to be included in other libraries' build scripts (while also exporting the PamImpl enum).
author Paul Fisher <paul@pfish.zone>
date Sat, 02 Aug 2025 18:47:46 -0400
parents 0730f5f2ee2a
children
comparison
equal deleted inserted replaced
189:b2456d274576 190:995aca290452
1 use bindgen::MacroTypeVariation; 1 use bindgen::MacroTypeVariation;
2 use libpam_sys_impls::pam_impl_name; 2 use libpam_sys::pam_impl_name;
3 use libpam_sys_impls::PamImpl; 3 use libpam_sys_impls::PamImpl;
4 use proc_macro2::{Group, Ident, TokenStream, TokenTree}; 4 use proc_macro2::{Group, Ident, TokenStream, TokenTree};
5 use quote::{format_ident, ToTokens}; 5 use quote::{format_ident, ToTokens};
6 use std::path::Path; 6 use std::path::Path;
7 use std::process::Command; 7 use std::process::Command;
11 11
12 const REDIR_FD: &str = "pam_modutil_redirect_fd"; 12 const REDIR_FD: &str = "pam_modutil_redirect_fd";
13 13
14 fn main() { 14 fn main() {
15 libpam_sys_impls::enable_pam_impl_cfg(); 15 libpam_sys_impls::enable_pam_impl_cfg();
16 let config = match PamImpl::CURRENT { 16 let config = match libpam_sys::pam_impl::CURRENT {
17 PamImpl::LinuxPam => TestConfig { 17 PamImpl::LinuxPam => TestConfig {
18 headers: vec![ 18 headers: vec![
19 "<security/_pam_types.h>", 19 "<security/_pam_types.h>",
20 "<security/pam_appl.h>", 20 "<security/pam_appl.h>",
21 "<security/pam_ext.h>", 21 "<security/pam_ext.h>",
74 let file = syn::parse_file(&generated.to_string()).unwrap(); 74 let file = syn::parse_file(&generated.to_string()).unwrap();
75 let mut tests = vec![ 75 let mut tests = vec![
76 "#[allow(deprecated, overflowing_literals)]".into(), 76 "#[allow(deprecated, overflowing_literals)]".into(),
77 "fn main() {".into(), 77 "fn main() {".into(),
78 format!( 78 format!(
79 "assert_eq!(libpam_sys::pam_impl::PamImpl::CURRENT, libpam_sys::pam_impl::PamImpl::{:?});", 79 "assert_eq!(libpam_sys::pam_impl::CURRENT, libpam_sys::pam_impl::PamImpl::{:?});",
80 PamImpl::CURRENT 80 libpam_sys::pam_impl::CURRENT
81 ), 81 ),
82 ]; 82 ];
83 tests.extend( 83 tests.extend(
84 file.items 84 file.items
85 .iter() 85 .iter()