1#[macro_export]2macro_rules! construct_runtime_impl {3 (4 select_runtime($select_runtime:ident);56 pub enum Runtime where7 $($where_ident:ident = $where_ty:ty),* $(,)?8 {9 $(10 $(#[runtimes($($pallet_runtimes:ident),+ $(,)?)])?11 $pallet_name:ident: $pallet_mod:ident::{$($pallet_parts:ty),*} = $index:literal12 ),*13 $(,)?14 }15 ) => {16 $crate::construct_runtime_helper! {17 select_runtime($select_runtime),18 selected_pallets(),1920 where_clause($($where_ident = $where_ty),*),21 pallets(22 $(23 $(#[runtimes($($pallet_runtimes),+)])?24 $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index25 ),*,26 )27 }28 }29}3031#[macro_export]32macro_rules! construct_runtime_helper {33 (34 select_runtime($select_runtime:ident),35 selected_pallets($($selected_pallets:tt)*),3637 where_clause($($where_clause:tt)*),38 pallets(39 #[runtimes($($pallet_runtimes:ident),+)]40 $pallet_name:ident: $pallet_mod:ident::{$($pallet_parts:ty),*} = $index:literal,4142 $($pallets_tl:tt)*43 )44 ) => {45 $crate::add_runtime_specific_pallets! {46 select_runtime($select_runtime),47 runtimes($($pallet_runtimes),+,),48 selected_pallets($($selected_pallets)*),4950 where_clause($($where_clause)*),51 pallets(52 $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index,53 $($pallets_tl)*54 )55 }56 };5758 (59 select_runtime($select_runtime:ident),60 selected_pallets($($selected_pallets:tt)*),6162 where_clause($($where_clause:tt)*),63 pallets(64 $pallet_name:ident: $pallet_mod:ident::{$($pallet_parts:ty),*} = $index:literal,6566 $($pallets_tl:tt)*67 )68 ) => {69 $crate::construct_runtime_helper! {70 select_runtime($select_runtime),71 selected_pallets(72 $($selected_pallets)*73 $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index,74 ),7576 where_clause($($where_clause)*),77 pallets($($pallets_tl)*)78 }79 };8081 (82 select_runtime($select_runtime:ident),83 selected_pallets($($selected_pallets:tt)*),8485 where_clause($($where_clause:tt)*),86 pallets()87 ) => {88 frame_support::construct_runtime! {89 pub enum Runtime where90 $($where_clause)*91 {92 $($selected_pallets)*93 }94 }95 };96}9798#[macro_export]99macro_rules! add_runtime_specific_pallets {100 (101 select_runtime(opal),102 runtimes(opal, $($_runtime_tl:tt)*),103 selected_pallets($($selected_pallets:tt)*),104105 where_clause($($where_clause:tt)*),106 pallets(107 $pallet_name:ident: $pallet_mod:ident::{$($pallet_parts:ty),*} = $index:literal,108 $($pallets_tl:tt)*109 )110 ) => {111 $crate::construct_runtime_helper! {112 select_runtime(opal),113 selected_pallets(114 $($selected_pallets)*115 $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index,116 ),117118 where_clause($($where_clause)*),119 pallets($($pallets_tl)*)120 }121 };122123 (124 select_runtime(quartz),125 runtimes(quartz, $($_runtime_tl:tt)*),126 selected_pallets($($selected_pallets:tt)*),127128 where_clause($($where_clause:tt)*),129 pallets(130 $pallet_name:ident: $pallet_mod:ident::{$($pallet_parts:ty),*} = $index:literal,131 $($pallets_tl:tt)*132 )133 ) => {134 $crate::construct_runtime_helper! {135 select_runtime(quartz),136 selected_pallets(137 $($selected_pallets)*138 $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index,139 ),140141 where_clause($($where_clause)*),142 pallets($($pallets_tl)*)143 }144 };145146 (147 select_runtime(unique),148 runtimes(unique, $($_runtime_tl:tt)*),149 selected_pallets($($selected_pallets:tt)*),150151 where_clause($($where_clause:tt)*),152 pallets(153 $pallet_name:ident: $pallet_mod:ident::{$($pallet_parts:ty),*} = $index:literal,154 $($pallets_tl:tt)*155 )156 ) => {157 $crate::construct_runtime_helper! {158 select_runtime(unique),159 selected_pallets(160 $($selected_pallets)*161 $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index,162 ),163164 where_clause($($where_clause)*),165 pallets($($pallets_tl)*)166 }167 };168169 (170 select_runtime($select_runtime:ident),171 runtimes($_current_runtime:ident, $($runtime_tl:tt)*),172 selected_pallets($($selected_pallets:tt)*),173174 where_clause($($where_clause:tt)*),175 pallets($($pallets:tt)*)176 ) => {177 $crate::add_runtime_specific_pallets! {178 select_runtime($select_runtime),179 runtimes($($runtime_tl)*),180 selected_pallets($($selected_pallets)*),181182 where_clause($($where_clause)*),183 pallets($($pallets)*)184 }185 };186187 (188 select_runtime($select_runtime:ident),189 runtimes(),190 selected_pallets($($selected_pallets:tt)*),191192 where_clause($($where_clause:tt)*),193 pallets(194 $_pallet_name:ident: $_pallet_mod:ident::{$($_pallet_parts:ty),*} = $_index:literal,195 $($pallets_tl:tt)*196 )197 ) => {198 $crate::construct_runtime_helper! {199 select_runtime($select_runtime),200 selected_pallets($($selected_pallets)*),201202 where_clause($($where_clause)*),203 pallets($($pallets_tl)*)204 }205 };206}