diff --git a/Cargo.toml b/Cargo.toml index 9464a0df..c865216a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,11 @@ [package] name = "casper-client" version = "2.0.0" # when updating, also update 'html_root_url' in lib.rs -authors = ["Marc Brinkmann ", "Fraser Hutchison ", "Zachary Showalter "] +authors = [ + "Marc Brinkmann ", + "Fraser Hutchison ", + "Zachary Showalter ", +] edition = "2021" description = "A client library and binary for interacting with the Casper network" documentation = "https://docs.rs/casper-client" @@ -19,27 +23,18 @@ path = "lib/lib.rs" name = "casper-client" path = "src/main.rs" doc = false -required-features = [ - "async-trait", - "clap", - "clap_complete", - "tokio", - "std-fs-io", -] +required-features = ["async-trait", "clap", "clap_complete", "std-fs-io"] [features] -default = ["async-trait", "clap", "clap_complete", "tokio", "std-fs-io"] +default = ["async-trait", "clap", "clap_complete", "std-fs-io"] std-fs-io = ["casper-types/std-fs-io"] [dependencies] async-trait = { version = "0.1.74", optional = true } base16 = "0.2.1" casper-types = { version = "5.0.0", features = ["std"] } -clap = { version = "4.4.10", optional = true, features = [ - "cargo", - "deprecated", -] } -clap_complete = { version = "4.4.4", optional = true } +clap = { version = "~4.4", features = ["cargo", "deprecated"], optional = true } +clap_complete = { version = "~4.4", default-features = false, optional = true } hex-buffer-serde = "0.4.0" humantime = "2.1.0" itertools = "0.12.0" @@ -47,33 +42,25 @@ jsonrpc-lite = "0.6.0" num-traits = "0.2.15" once_cell = "1.18.0" rand = "0.8.5" -reqwest = { version = "0.12.4", features = ["json"] } +reqwest = { version = "0.12.5", features = ["json"] } schemars = "0.8.18" serde = { version = "1.0.193", default-features = false, features = ["derive"] } serde-map-to-array = "1.1.1" serde_json = { version = "1.0.108", features = ["preserve_order"] } -thiserror = "1.0.50" -tokio = { version = "1.34.0", optional = true, features = [ - "macros", - "rt", - "sync", - "time", -] } +thiserror = "1" +tokio = { version = "1.34.0", features = ["macros", "rt", "sync", "time"] } uint = "0.9.5" [dev-dependencies] tempfile = "3.8.1" -[build-dependencies] -vergen = { version = "7", default-features = false, features = ["git"] } - [patch.crates-io] casper-types = { version = "5.0.0", git = "https://github.com/casper-network/casper-node", branch = "rustSDK-feat-2.0" } [package.metadata.deb] features = ["vendored-openssl"] revision = "0" -assets = [["./target/release/casper-client", "/usr/bin/casper-client", "755"], ] +assets = [["./target/release/casper-client", "/usr/bin/casper-client", "755"]] extended-description = """ Package for Casper Client to connect to Casper Node. diff --git a/build.rs b/build.rs index c8dd712c..bc0d703b 100644 --- a/build.rs +++ b/build.rs @@ -1,7 +1,35 @@ -use vergen::{Config, ShaKind}; +use std::io; +use std::process::Command; + +const GIT_HASH_ENV_VAR: &str = "GIT_SHA_SHORT"; fn main() { - let mut config = Config::default(); - *config.git_mut().sha_kind_mut() = ShaKind::Short; - let _ = vergen::vergen(config); + match get_git_commit_hash() { + // If the git commit hash is retrieved successfully, set the environment variable + Ok(git_hash) => { + println!("cargo:rustc-env={GIT_HASH_ENV_VAR}={git_hash}"); + } + // If there's an error retrieving the git commit hash, print a note and set the environment variable to "unknown" + Err(e) => { + println!("cargo:warning=Note: Failed to get git commit hash: {}", e); + println!("cargo:rustc-env={GIT_HASH_ENV_VAR}=unknown"); + } + } +} + +fn get_git_commit_hash() -> Result { + // Build the command to retrieve the short git commit hash + let output = Command::new("git") + .arg("rev-parse") + .arg("--short") + .arg("HEAD") + .output()?; + + if output.status.success() { + // Parse the raw output into a string and trim the newline character + Ok(String::from_utf8_lossy(&output.stdout).trim().to_string()) + } else { + // Return an error if the command failed + Err(io::Error::new(io::ErrorKind::Other, "Git command failed")) + } } diff --git a/src/main.rs b/src/main.rs index 4bf4d8cc..7ce0a05d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -63,7 +63,7 @@ const APP_NAME: &str = "Casper client"; static VERSION: Lazy = Lazy::new( - || match option_env!("VERGEN_GIT_SHA_SHORT").map(|sha| sha.to_lowercase()) { + || match option_env!("GIT_SHA_SHORT").map(|sha| sha.to_lowercase()) { None => crate_version!().to_string(), Some(git_sha_short) => { if git_sha_short.to_lowercase() == "unknown" {