|
1 | 1 | //! Constants associated with each target.
|
2 | 2 |
|
3 |
| -// Keep entries sorted alphabetically. |
| 3 | +// Collect all #[cfg(…)] gates, so that the #[else] fallback entry is |
| 4 | +// #[cfg(not(any(…)))] of all of them. This ensures that they must be 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 | + |
| 16 | +// Keep entries sorted alphabetically and mutually exclusive. |
| 17 | + |
| 18 | +cfg_unordered! { [] |
4 | 19 |
|
5 | 20 | #[cfg(target_os = "aix")]
|
6 | 21 | pub mod os {
|
@@ -375,3 +390,17 @@ pub mod os {
|
375 | 390 | pub const EXE_SUFFIX: &str = ".exe";
|
376 | 391 | pub const EXE_EXTENSION: &str = "exe";
|
377 | 392 | }
|
| 393 | + |
| 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