make polkadot-runtime optional feature (#3820)

* make polkadot-runtime optional feature

* sprinkle some cfg statements

* ok

* ok, ok

* add CI check

* set -e

* chmod +x

* fixes

* fmt

* nicer compile errors

* Update outdated comments
This commit is contained in:
Andronik Ordian
2021-09-13 12:28:33 +02:00
committed by GitHub
parent 3d2c4db477
commit 33d7f9dd7b
10 changed files with 152 additions and 52 deletions
+3 -1
View File
@@ -32,7 +32,7 @@ pallet-mmr-primitives = { git = "https://github.com/paritytech/substrate", branc
beefy-primitives = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master" }
# Polkadot Runtimes
polkadot-runtime = { path = "../../runtime/polkadot" }
polkadot-runtime = { path = "../../runtime/polkadot", optional = true }
kusama-runtime = { path = "../../runtime/kusama", optional = true }
westend-runtime = { path = "../../runtime/westend", optional = true }
rococo-runtime = { path = "../../runtime/rococo", optional = true }
@@ -40,6 +40,8 @@ rococo-runtime = { path = "../../runtime/rococo", optional = true }
polkadot-primitives = { path = "../../primitives" }
[features]
default = ["polkadot"]
polkadot = ["polkadot-runtime"]
kusama = ["kusama-runtime"]
rococo = ["rococo-runtime"]
westend = ["westend-runtime"]
+12
View File
@@ -40,9 +40,19 @@ pub type FullBackend = sc_service::TFullBackend<Block>;
pub type FullClient<RuntimeApi, ExecutorDispatch> =
sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<ExecutorDispatch>>;
#[cfg(not(any(
feature = "rococo",
feature = "kusama",
feature = "westend",
feature = "polkadot"
)))]
compile_error!("at least one runtime feature must be enabled");
/// The native executor instance for Polkadot.
#[cfg(feature = "polkadot")]
pub struct PolkadotExecutorDispatch;
#[cfg(feature = "polkadot")]
impl sc_executor::NativeExecutionDispatch for PolkadotExecutorDispatch {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
@@ -233,6 +243,7 @@ macro_rules! with_client {
}
} => {
match $self {
#[cfg(feature = "polkadot")]
Self::Polkadot($client) => { $( $code )* },
#[cfg(feature = "westend")]
Self::Westend($client) => { $( $code )* },
@@ -249,6 +260,7 @@ macro_rules! with_client {
/// See [`ExecuteWithClient`] for more information.
#[derive(Clone)]
pub enum Client {
#[cfg(feature = "polkadot")]
Polkadot(Arc<FullClient<polkadot_runtime::RuntimeApi, PolkadotExecutorDispatch>>),
#[cfg(feature = "westend")]
Westend(Arc<FullClient<westend_runtime::RuntimeApi, WestendExecutorDispatch>>),