diff --git a/cmd/soroban-cli/Cargo.toml b/cmd/soroban-cli/Cargo.toml index 2b667b0b1..3d6a027c1 100644 --- a/cmd/soroban-cli/Cargo.toml +++ b/cmd/soroban-cli/Cargo.toml @@ -36,6 +36,8 @@ doctest = false [features] default = [] +version_lt_23 = [] +version_gte_23 = [] opt = ["dep:wasm-opt"] [dependencies] diff --git a/cmd/soroban-cli/build.rs b/cmd/soroban-cli/build.rs index b6e6dd92a..edd29d714 100644 --- a/cmd/soroban-cli/build.rs +++ b/cmd/soroban-cli/build.rs @@ -1,3 +1,22 @@ fn main() { crate_git_revision::init(); + set_protocol_features(); +} + +fn set_protocol_features() { + let version = env!("CARGO_PKG_VERSION"); + let major_version: u32 = version + .split('.') + .next() + .unwrap_or("0") + .parse() + .unwrap_or(0); + + if major_version < 23 { + println!("cargo:rustc-cfg=feature=\"version_lt_23\""); + } + + if major_version >= 23 { + println!("cargo:rustc-cfg=feature=\"version_gte_23\""); + } }