Skip to content

Commit

Permalink
Add features for guarding code based on the P23. (#1863)
Browse files Browse the repository at this point in the history
  • Loading branch information
fnando authored Feb 3, 2025
1 parent b29b0e6 commit c6b8b3a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/soroban-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ doctest = false

[features]
default = []
version_lt_23 = []
version_gte_23 = []
opt = ["dep:wasm-opt"]

[dependencies]
Expand Down
19 changes: 19 additions & 0 deletions cmd/soroban-cli/build.rs
Original file line number Diff line number Diff line change
@@ -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\"");
}
}

0 comments on commit c6b8b3a

Please sign in to comment.