1234567891011121314151617#[macro_export]18macro_rules! construct_runtime_impl {19 (20 select_runtime($select_runtime:ident);2122 pub enum Runtime where23 $($where_ident:ident = $where_ty:ty),* $(,)?24 {25 $(26 $(#[runtimes($($pallet_runtimes:ident),+ $(,)?)])?27 $pallet_name:ident: $pallet_mod:ident$(::{$($pallet_parts:ty),*})? = $index:literal28 ),*29 $(,)?3031 #[test_pallets]32 {33 $(34 $test_pallet_name:ident: $test_pallet_mod:ident35 ),*36 $(,)?37 }38 }39 ) => {40 $crate::construct_runtime_helper! {41 select_runtime($select_runtime),42 selected_pallets(),43 test_pallets(44 $(45 $test_pallet_name: $test_pallet_mod46 ),*47 ),4849 where_clause($($where_ident = $where_ty),*),50 pallets(51 $(52 $(#[runtimes($($pallet_runtimes),+)])?53 $pallet_name: $pallet_mod$(::{$($pallet_parts),*})? = $index54 ),*,55 )56 }57 }58}5960#[macro_export]61macro_rules! construct_runtime_helper {62 (63 select_runtime($select_runtime:ident),64 selected_pallets($($selected_pallets:tt)*),65 test_pallets($($test_pallets:tt)*),6667 where_clause($($where_clause:tt)*),68 pallets(69 #[runtimes($($pallet_runtimes:ident),+)]70 $pallet_name:ident: $pallet_mod:ident$(::{$($pallet_parts:ty),*})? = $index:literal,7172 $($pallets_tl:tt)*73 )74 ) => {75 $crate::add_runtime_specific_pallets! {76 select_runtime($select_runtime),77 runtimes($($pallet_runtimes),+,),78 selected_pallets($($selected_pallets)*),79 test_pallets($($test_pallets)*),8081 where_clause($($where_clause)*),82 pallets(83 $pallet_name: $pallet_mod$(::{$($pallet_parts),*})? = $index,84 $($pallets_tl)*85 )86 }87 };8889 (90 select_runtime($select_runtime:ident),91 selected_pallets($($selected_pallets:tt)*),92 test_pallets($($test_pallets:tt)*),9394 where_clause($($where_clause:tt)*),95 pallets(96 $pallet_name:ident: $pallet_mod:ident$(::{$($pallet_parts:ty),*})? = $index:literal,9798 $($pallets_tl:tt)*99 )100 ) => {101 $crate::construct_runtime_helper! {102 select_runtime($select_runtime),103 selected_pallets(104 $($selected_pallets)*105 $pallet_name: $pallet_mod$(::{$($pallet_parts),*})? = $index,106 ),107 test_pallets($($test_pallets)*),108109 where_clause($($where_clause)*),110 pallets($($pallets_tl)*)111 }112 };113114 (115 select_runtime($select_runtime:ident),116 selected_pallets($($selected_pallets:tt)*),117 test_pallets($($test_pallets:tt)*),118119 where_clause($($where_clause:tt)*),120 pallets()121 ) => {122 #[cfg(not(feature = "test-pallets"))]123 frame_support::construct_runtime! {124 pub enum Runtime where125 $($where_clause)*126 {127 $($selected_pallets)*128 }129 }130131 #[cfg(feature = "test-pallets")]132 frame_support::construct_runtime! {133 pub enum Runtime where134 $($where_clause)*135 {136 $($selected_pallets)*137 $($test_pallets)*138 }139 }140 };141}142143#[macro_export]144macro_rules! add_runtime_specific_pallets {145 (146 select_runtime(opal),147 runtimes(opal, $($_runtime_tl:tt)*),148 selected_pallets($($selected_pallets:tt)*),149 test_pallets($($test_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(opal),159 selected_pallets(160 $($selected_pallets)*161 $pallet_name: $pallet_mod$(::{$($pallet_parts),*})? = $index,162 ),163 test_pallets($($test_pallets)*),164165 where_clause($($where_clause)*),166 pallets($($pallets_tl)*)167 }168 };169170 (171 select_runtime(quartz),172 runtimes(quartz, $($_runtime_tl:tt)*),173 selected_pallets($($selected_pallets:tt)*),174 test_pallets($($test_pallets:tt)*),175176 where_clause($($where_clause:tt)*),177 pallets(178 $pallet_name:ident: $pallet_mod:ident$(::{$($pallet_parts:ty),*})? = $index:literal,179 $($pallets_tl:tt)*180 )181 ) => {182 $crate::construct_runtime_helper! {183 select_runtime(quartz),184 selected_pallets(185 $($selected_pallets)*186 $pallet_name: $pallet_mod$(::{$($pallet_parts),*})? = $index,187 ),188 test_pallets($($test_pallets)*),189190 where_clause($($where_clause)*),191 pallets($($pallets_tl)*)192 }193 };194195 (196 select_runtime(unique),197 runtimes(unique, $($_runtime_tl:tt)*),198 selected_pallets($($selected_pallets:tt)*),199 test_pallets($($test_pallets:tt)*),200201 where_clause($($where_clause:tt)*),202 pallets(203 $pallet_name:ident: $pallet_mod:ident$(::{$($pallet_parts:ty),*})? = $index:literal,204 $($pallets_tl:tt)*205 )206 ) => {207 $crate::construct_runtime_helper! {208 select_runtime(unique),209 selected_pallets(210 $($selected_pallets)*211 $pallet_name: $pallet_mod$(::{$($pallet_parts),*})? = $index,212 ),213 test_pallets($($test_pallets)*),214215 where_clause($($where_clause)*),216 pallets($($pallets_tl)*)217 }218 };219220 (221 select_runtime($select_runtime:ident),222 runtimes($_current_runtime:ident, $($runtime_tl:tt)*),223 selected_pallets($($selected_pallets:tt)*),224 test_pallets($($test_pallets:tt)*),225226 where_clause($($where_clause:tt)*),227 pallets($($pallets:tt)*)228 ) => {229 $crate::add_runtime_specific_pallets! {230 select_runtime($select_runtime),231 runtimes($($runtime_tl)*),232 selected_pallets($($selected_pallets)*),233 test_pallets($($test_pallets)*),234235 where_clause($($where_clause)*),236 pallets($($pallets)*)237 }238 };239240 (241 select_runtime($select_runtime:ident),242 runtimes(),243 selected_pallets($($selected_pallets:tt)*),244 test_pallets($($test_pallets:tt)*),245246 where_clause($($where_clause:tt)*),247 pallets(248 $_pallet_name:ident: $_pallet_mod:ident$(::{$($_pallet_parts:ty),*})? = $_index:literal,249 $($pallets_tl:tt)*250 )251 ) => {252 $crate::construct_runtime_helper! {253 select_runtime($select_runtime),254 selected_pallets($($selected_pallets)*),255 test_pallets($($test_pallets)*),256257 where_clause($($where_clause)*),258 pallets($($pallets_tl)*)259 }260 };261}