From 264b81abe854646b4f98f34b711deb0cf96f1ea3 Mon Sep 17 00:00:00 2001 From: Bernhard Schuster Date: Wed, 20 Jul 2022 13:53:11 +0200 Subject: [PATCH] allow re-use and avoid compiling kusama parachain code (#5792) * allow re-use and avoid compiling kusama parachain code * fixup removed trailing ; * make it compat with rustfmt +nightly --- cli/Cargo.toml | 4 ++-- cli/src/command.rs | 13 ++++++++++--- cli/src/lib.rs | 2 +- node/test/performance-test/src/lib.rs | 3 +++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 68c297f7eeda..b1066167e4fb 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -43,7 +43,7 @@ sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master", substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "master" } [features] -default = ["wasmtime", "db", "cli", "full-node", "trie-memory-tracker", "polkadot-native"] +default = ["wasmtime", "db", "cli", "hostperfcheck", "full-node", "trie-memory-tracker", "polkadot-native"] wasmtime = ["sc-cli/wasmtime"] db = ["service/db"] cli = [ @@ -55,7 +55,6 @@ cli = [ "try-runtime-cli", "polkadot-client", "polkadot-node-core-pvf", - "polkadot-performance-test", ] runtime-benchmarks = ["service/runtime-benchmarks", "polkadot-node-metrics/runtime-benchmarks"] trie-memory-tracker = ["sp-trie/memory-tracker"] @@ -63,6 +62,7 @@ full-node = ["service/full-node"] try-runtime = ["service/try-runtime"] fast-runtime = ["service/fast-runtime"] pyroscope = ["pyro"] +hostperfcheck = ["polkadot-performance-test"] # Configure the native runtimes to use. Polkadot is enabled by default. # diff --git a/cli/src/command.rs b/cli/src/command.rs index dfa4c05c2147..de9cdbf2b8cd 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -248,12 +248,19 @@ macro_rules! unwrap_client { fn host_perf_check() -> Result<()> { #[cfg(not(build_type = "release"))] { - Err(PerfCheckError::WrongBuildType.into()) + return Err(PerfCheckError::WrongBuildType.into()) } #[cfg(build_type = "release")] { - crate::host_perf_check::host_perf_check()?; - Ok(()) + #[cfg(not(feature = "hostperfcheck"))] + { + return Err(PerfCheckError::FeatureNotEnabled { feature: "hostperfcheck" }.into()) + } + #[cfg(feature = "hostperfcheck")] + { + crate::host_perf_check::host_perf_check()?; + return Ok(()) + } } } diff --git a/cli/src/lib.rs b/cli/src/lib.rs index b4ee9f868b2e..b31cf5dca8dc 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -24,7 +24,7 @@ mod cli; mod command; #[cfg(feature = "cli")] mod error; -#[cfg(all(feature = "cli", build_type = "release"))] +#[cfg(all(feature = "hostperfcheck", build_type = "release"))] mod host_perf_check; #[cfg(feature = "full-node")] diff --git a/node/test/performance-test/src/lib.rs b/node/test/performance-test/src/lib.rs index e80b5e7589f2..762c530e5d20 100644 --- a/node/test/performance-test/src/lib.rs +++ b/node/test/performance-test/src/lib.rs @@ -36,6 +36,9 @@ pub enum PerfCheckError { #[error("This subcommand is only available in release mode")] WrongBuildType, + #[error("This subcommand is only available when compiled with `{feature}`")] + FeatureNotEnabled { feature: &'static str }, + #[error("No wasm code found for running the performance test")] WasmBinaryMissing,