diff libpam-sys/src/lib.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 c77846f3a979
children
line wrap: on
line diff
--- a/libpam-sys/src/lib.rs	Wed Jul 02 03:33:09 2025 -0400
+++ b/libpam-sys/src/lib.rs	Thu Jul 03 11:03:36 2025 -0400
@@ -2,54 +2,12 @@
 //!
 //! ## PAM implementation
 //!
-#![doc = concat!("This documentation was built for the **", __pam_impl_name__!(), "** implementation.")]
-
-use libpam_sys_impls::{__pam_impl_enum__, __pam_impl_name__};
-
-/// A `cfg`-like attribute macro for code specific to one PAM implementation.
-///
-/// Different versions of PAM export different functions and have some
-/// meaningful internal implementation differences, like the way `pam_conv`
-/// is handled (see [the Linux-PAM man page for details][man7]).
-///
-/// This macro will let you figure out which PAM you're compiling
-/// (and eventually running) against so you can make those critical changes.
-///
-/// The implementation names are the same as those in the [`PamImpl`] enum.
-///
-/// ```
-/// use libpam_sys::cfg_pam_impl;
-///
-/// #[cfg_pam_impl("Sun")]
-/// fn do_something() { /* Illumos/Solaris-only code */ }
-///
-/// #[cfg_pam_impl(not("Sun"))]
-/// fn do_something() { /* non-Illumos code */ }
-///
-/// #[cfg_pam_impl(any("LinuxPam", "XSso"))]
-/// fn do_something_else() { /* Linux-PAM or X/SSO-spec PAM */ }
-///
-/// #[cfg_pam_impl(not(any("Sun", "OpenPam")))]
-/// fn do_a_third_thing() { /* Neither Sun nor OpenPAM */ }
-///
-/// #[cfg_pam_impl(any())]
-/// fn this_will_never_build() { /* why would you do this? */ }
-///
-/// #[cfg_pam_impl(not(any()))]
-/// fn this_will_always_build() { /* I, sure, whatever, you do you. */ }
-/// ```
-///
-/// [man7]: https://man7.org/linux/man-pages/man3/pam_conv.3.html
-#[doc(inline)]
-pub use libpam_sys_impls::cfg_pam_impl;
+#![doc = concat!("This documentation was built for the **", env!("LIBPAMSYS_IMPL"), "** implementation.")]
 
 mod constants;
 mod ffi;
 pub mod helpers;
+pub mod pam_impl;
 
 #[doc(inline)]
-pub use crate::{constants::*, ffi::*};
-
-// Looking for the actual code defining this enum?
-// It's in the build.rs file for libpam_sys_impls.
-__pam_impl_enum__!(#[non_exhaustive]);
+pub use crate::{constants::*, ffi::*, pam_impl::*};