Mercurial > crates > nonstick
annotate libpam-sys/build.rs @ 197:705d633e4966 default tip
Added tag libpam-sys/v0.2.0 for changeset 568faf823f34
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Sun, 03 Aug 2025 01:10:19 -0400 |
parents | e915c54097d6 |
children |
rev | line source |
---|---|
190
995aca290452
Restructure the way libpam-sys-impls works to fix cross-compilation.
Paul Fisher <paul@pfish.zone>
parents:
176
diff
changeset
|
1 use std::{env, fs}; |
995aca290452
Restructure the way libpam-sys-impls works to fix cross-compilation.
Paul Fisher <paul@pfish.zone>
parents:
176
diff
changeset
|
2 |
106
49d9e2b5c189
An irresponsible mix of implementing libpam-sys and other stuff.
Paul Fisher <paul@pfish.zone>
parents:
diff
changeset
|
3 fn main() { |
49d9e2b5c189
An irresponsible mix of implementing libpam-sys and other stuff.
Paul Fisher <paul@pfish.zone>
parents:
diff
changeset
|
4 println!("cargo:rustc-link-lib=pam"); |
176
0730f5f2ee2a
Turn `libpam-sys-consts` back into `libpam-sys-impls`.
Paul Fisher <paul@pfish.zone>
parents:
148
diff
changeset
|
5 libpam_sys_impls::enable_pam_impl_cfg(); |
190
995aca290452
Restructure the way libpam-sys-impls works to fix cross-compilation.
Paul Fisher <paul@pfish.zone>
parents:
176
diff
changeset
|
6 |
995aca290452
Restructure the way libpam-sys-impls works to fix cross-compilation.
Paul Fisher <paul@pfish.zone>
parents:
176
diff
changeset
|
7 let pam_impl = libpam_sys_impls::build_target_impl(); |
191
e915c54097d6
Clean up docs and link versions to the right place.
Paul Fisher <paul@pfish.zone>
parents:
190
diff
changeset
|
8 let impl_str = pam_impl |
e915c54097d6
Clean up docs and link versions to the right place.
Paul Fisher <paul@pfish.zone>
parents:
190
diff
changeset
|
9 .map(|i| format!("{i:?}")) |
e915c54097d6
Clean up docs and link versions to the right place.
Paul Fisher <paul@pfish.zone>
parents:
190
diff
changeset
|
10 .unwrap_or("[undefined]".into()); |
190
995aca290452
Restructure the way libpam-sys-impls works to fix cross-compilation.
Paul Fisher <paul@pfish.zone>
parents:
176
diff
changeset
|
11 println!("cargo:rustc-env=LIBPAMSYS_IMPL={impl_str}"); |
995aca290452
Restructure the way libpam-sys-impls works to fix cross-compilation.
Paul Fisher <paul@pfish.zone>
parents:
176
diff
changeset
|
12 let output = match pam_impl { |
995aca290452
Restructure the way libpam-sys-impls works to fix cross-compilation.
Paul Fisher <paul@pfish.zone>
parents:
176
diff
changeset
|
13 None => "".into(), |
995aca290452
Restructure the way libpam-sys-impls works to fix cross-compilation.
Paul Fisher <paul@pfish.zone>
parents:
176
diff
changeset
|
14 Some(pam_impl) => { |
191
e915c54097d6
Clean up docs and link versions to the right place.
Paul Fisher <paul@pfish.zone>
parents:
190
diff
changeset
|
15 format!( |
e915c54097d6
Clean up docs and link versions to the right place.
Paul Fisher <paul@pfish.zone>
parents:
190
diff
changeset
|
16 "\ |
190
995aca290452
Restructure the way libpam-sys-impls works to fix cross-compilation.
Paul Fisher <paul@pfish.zone>
parents:
176
diff
changeset
|
17 /// The implementation of PAM this library was built against. |
995aca290452
Restructure the way libpam-sys-impls works to fix cross-compilation.
Paul Fisher <paul@pfish.zone>
parents:
176
diff
changeset
|
18 pub const CURRENT: PamImpl = PamImpl::{pam_impl:?}; |
995aca290452
Restructure the way libpam-sys-impls works to fix cross-compilation.
Paul Fisher <paul@pfish.zone>
parents:
176
diff
changeset
|
19 /// The name of the PAM implementation this library was built |
995aca290452
Restructure the way libpam-sys-impls works to fix cross-compilation.
Paul Fisher <paul@pfish.zone>
parents:
176
diff
changeset
|
20 /// against, as a string. |
995aca290452
Restructure the way libpam-sys-impls works to fix cross-compilation.
Paul Fisher <paul@pfish.zone>
parents:
176
diff
changeset
|
21 #[macro_export] |
995aca290452
Restructure the way libpam-sys-impls works to fix cross-compilation.
Paul Fisher <paul@pfish.zone>
parents:
176
diff
changeset
|
22 macro_rules! pam_impl_name {{ () => {{ \"{pam_impl:?}\" }} }} |
995aca290452
Restructure the way libpam-sys-impls works to fix cross-compilation.
Paul Fisher <paul@pfish.zone>
parents:
176
diff
changeset
|
23 pub(crate) use pam_impl_name; |
191
e915c54097d6
Clean up docs and link versions to the right place.
Paul Fisher <paul@pfish.zone>
parents:
190
diff
changeset
|
24 " |
e915c54097d6
Clean up docs and link versions to the right place.
Paul Fisher <paul@pfish.zone>
parents:
190
diff
changeset
|
25 ) |
190
995aca290452
Restructure the way libpam-sys-impls works to fix cross-compilation.
Paul Fisher <paul@pfish.zone>
parents:
176
diff
changeset
|
26 } |
995aca290452
Restructure the way libpam-sys-impls works to fix cross-compilation.
Paul Fisher <paul@pfish.zone>
parents:
176
diff
changeset
|
27 }; |
191
e915c54097d6
Clean up docs and link versions to the right place.
Paul Fisher <paul@pfish.zone>
parents:
190
diff
changeset
|
28 let outfile = format!( |
e915c54097d6
Clean up docs and link versions to the right place.
Paul Fisher <paul@pfish.zone>
parents:
190
diff
changeset
|
29 "{out}/pam_impl_consts.rs", |
e915c54097d6
Clean up docs and link versions to the right place.
Paul Fisher <paul@pfish.zone>
parents:
190
diff
changeset
|
30 out = env::var("OUT_DIR").expect("missing OUT_DIR env var") |
e915c54097d6
Clean up docs and link versions to the right place.
Paul Fisher <paul@pfish.zone>
parents:
190
diff
changeset
|
31 ); |
190
995aca290452
Restructure the way libpam-sys-impls works to fix cross-compilation.
Paul Fisher <paul@pfish.zone>
parents:
176
diff
changeset
|
32 fs::write(outfile, output).expect("couldn't write output file"); |
106
49d9e2b5c189
An irresponsible mix of implementing libpam-sys and other stuff.
Paul Fisher <paul@pfish.zone>
parents:
diff
changeset
|
33 } |