Mercurial > crates > nonstick
comparison libpam-sys/libpam-sys-impls/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 | 2346fd501b7a |
children |
comparison
equal
deleted
inserted
replaced
112:82995b4dccee | 113:178310336596 |
---|---|
4 //! output to the `OUT_DIR/pam_impl_enum.rs` file for parsing/inclusion | 4 //! output to the `OUT_DIR/pam_impl_enum.rs` file for parsing/inclusion |
5 //! into the `__pam_impl_enum__` macro. | 5 //! into the `__pam_impl_enum__` macro. |
6 //! 2. It detects the current PAM implementation and sets an env var for | 6 //! 2. It detects the current PAM implementation and sets an env var for |
7 //! the macros in `libpam-sys-impl`. | 7 //! the macros in `libpam-sys-impl`. |
8 | 8 |
9 use proc_macro2::TokenStream; | |
10 use quote::quote; | |
9 use std::{env, fs}; | 11 use std::{env, fs}; |
10 use strum::EnumString; | 12 use strum::EnumString; |
11 use proc_macro2::TokenStream; | |
12 use quote::quote; | |
13 | 13 |
14 fn main() { | 14 fn main() { |
15 let pam_impl = match option_env!("LIBPAMSYS_IMPL") { | 15 let pam_impl = match option_env!("LIBPAMSYS_IMPL") { |
16 // The default option: Guess what PAM impl we're using based on OS. | 16 // The default option: Guess what PAM impl we're using based on OS. |
17 None => { | 17 None => { |
23 target_os = "netbsd", | 23 target_os = "netbsd", |
24 target_os = "dragonfly", | 24 target_os = "dragonfly", |
25 target_os = "openbsd" | 25 target_os = "openbsd" |
26 )) { | 26 )) { |
27 PamImpl::OpenPam | 27 PamImpl::OpenPam |
28 } else if cfg!(any( | 28 } else if cfg!(any(target_os = "illumos", target_os = "solaris",)) { |
29 target_os = "illumos", | |
30 target_os = "solaris", | |
31 )) { | |
32 PamImpl::Sun | 29 PamImpl::Sun |
33 } else { | 30 } else { |
34 PamImpl::MinimalOpenPam | 31 PamImpl::MinimalOpenPam |
35 } | 32 } |
36 } | 33 } |
51 Some(other) => match PamImpl::try_from(other) { | 48 Some(other) => match PamImpl::try_from(other) { |
52 Ok(i) => i, | 49 Ok(i) => i, |
53 Err(_) => panic!("unknown PAM implementation {other:?}"), | 50 Err(_) => panic!("unknown PAM implementation {other:?}"), |
54 }, | 51 }, |
55 }; | 52 }; |
56 fs::write(format!("{}/pam_impl_enum.rs", env::var("OUT_DIR").unwrap()), PamImpl::enum_tokens().to_string()).unwrap(); | 53 fs::write( |
54 format!("{}/pam_impl_enum.rs", env::var("OUT_DIR").unwrap()), | |
55 PamImpl::enum_tokens().to_string(), | |
56 ) | |
57 .unwrap(); | |
57 println!("cargo:rustc-env=LIBPAMSYS_IMPL={pam_impl:?}"); | 58 println!("cargo:rustc-env=LIBPAMSYS_IMPL={pam_impl:?}"); |
58 } | 59 } |
59 | 60 |
60 /// This defines a local enum with an `enum_tokens()` method that can spit out | 61 /// This defines a local enum with an `enum_tokens()` method that can spit out |
61 /// its own contents. | 62 /// its own contents. |