timechain_runtime/
variants.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
///! Helpers to handle runtime variants

/// Mainnet runtime variant string
#[cfg(not(any(feature = "testnet", feature = "develop")))]
pub const RUNTIME_VARIANT: &str = "mainnet";

/// Staging runtime variant string
#[cfg(all(not(feature = "testnet"), feature = "develop"))]
pub const RUNTIME_VARIANT: &str = "staging";

/// Testnet runtime variant string
#[cfg(all(feature = "testnet", not(feature = "develop")))]
pub const RUNTIME_VARIANT: &str = "testnet";

/// Develop runtime variant string
#[cfg(all(feature = "testnet", feature = "develop"))]
pub const RUNTIME_VARIANT: &str = "develop";

/// Macro to set a value (e.g. when using the `parameter_types` macro) based on
/// the current runtime variant being build.
#[macro_export]
macro_rules! main_test_or_dev {
	($main:expr, $test:expr, $dev:expr) => {
		if cfg!(feature = "develop") {
			$dev
		} else if cfg!(feature = "testnet") {
			$test
		} else {
			$main
		}
	};
}

/// Macro to set value based on testnet feature flag
#[macro_export]
macro_rules! main_or_test {
	($main:expr, $test:expr) => {
		if cfg!(feature = "testnet") {
			$test
		} else {
			$main
		}
	};
}

/// Macro to set value based on develop feature flag
#[macro_export]
macro_rules! prod_or_dev {
	($prod:expr, $dev:expr) => {
		if cfg!(feature = "develop") {
			$dev
		} else {
			$prod
		}
	};
}