|
1 | 1 | //! Constants associated with each target.
|
2 | 2 |
|
| 3 | +// Collect all #[cfg(…)] gates, so that the #[else] fallback entry is |
| 4 | +// #[cfg(not(any(…)))] of all of them. This ensures that they are mutually |
| 5 | +// exclusive and do not have precedence like cfg_if!. |
| 6 | +macro_rules! cfg_unordered { |
| 7 | + ([$($cfgs:meta,)*] #[cfg($cfg:meta)] $os:item $($rest:tt)*) => { |
| 8 | + #[cfg($cfg)] $os |
| 9 | + cfg_unordered!([$($cfgs,)* $cfg,] $($rest)*); |
| 10 | + }; |
| 11 | + ([$($cfgs:meta,)*] #[else] $last:item) => { |
| 12 | + #[cfg(not(any($($cfgs),*)))] $last |
| 13 | + }; |
| 14 | +} |
| 15 | + |
3 | 16 | // Keep entries sorted alphabetically.
|
4 | 17 |
|
| 18 | +cfg_unordered! { [] |
| 19 | + |
5 | 20 | #[cfg(target_os = "aix")]
|
6 | 21 | pub mod os {
|
7 | 22 | pub const FAMILY: &str = "unix";
|
@@ -376,4 +391,16 @@ pub mod os {
|
376 | 391 | pub const EXE_EXTENSION: &str = "exe";
|
377 | 392 | }
|
378 | 393 |
|
379 |
| -// Keep entries sorted alphabetically. |
| 394 | +// Fallback when unsupported: |
| 395 | +#[else] |
| 396 | +pub mod os { |
| 397 | + pub const FAMILY: &str = ""; |
| 398 | + pub const OS: &str = ""; |
| 399 | + pub const DLL_PREFIX: &str = ""; |
| 400 | + pub const DLL_SUFFIX: &str = ""; |
| 401 | + pub const DLL_EXTENSION: &str = ""; |
| 402 | + pub const EXE_SUFFIX: &str = ""; |
| 403 | + pub const EXE_EXTENSION: &str = ""; |
| 404 | +} |
| 405 | + |
| 406 | +} |
0 commit comments