diff --git a/Cargo.lock b/Cargo.lock index 52d72e247..368e98400 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -385,6 +385,10 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "build_utils" +version = "0.1.0" + [[package]] name = "bumpalo" version = "3.13.0" @@ -4187,6 +4191,7 @@ dependencies = [ "bech32", "bip0039", "bls12_381", + "build_utils", "byteorder", "bytes 0.4.12", "concat-idents", diff --git a/Cargo.toml b/Cargo.toml index 44e2876f7..7d2852d7b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ tempdir = "0.3" portpicker = "0.1" incrementalmerkletree = { git = "https://github.com/zcash/incrementalmerkletree", rev = "bae25ad89c0c192bee625252d2d419bd56638e48" } shardtree = { git = "https://github.com/zcash/incrementalmerkletree", rev = "bae25ad89c0c192bee625252d2d419bd56638e48" } +build_utils = { path = "./build_utils" } [profile.release] debug = false diff --git a/build_utils/Cargo.toml b/build_utils/Cargo.toml new file mode 100644 index 000000000..a89840756 --- /dev/null +++ b/build_utils/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "build_utils" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/build_utils/src/lib.rs b/build_utils/src/lib.rs new file mode 100644 index 000000000..8119b49c8 --- /dev/null +++ b/build_utils/src/lib.rs @@ -0,0 +1,22 @@ +use std::io::Write; +use std::{env, fs::File, path::Path, process::Command}; + +pub fn git_description() { + let output = Command::new("git") + .args(["describe", "--dirty"]) + .output() + .expect("Failed to execute git command"); + + let git_description = String::from_utf8(output.stdout).unwrap(); + + // Write the git description to a file which will be included in the crate + let out_dir = env::var("OUT_DIR").unwrap(); + let dest_path = Path::new(&out_dir).join("git_description.rs"); + let mut f = File::create(dest_path).unwrap(); + writeln!( + f, + "pub fn git_description() -> &'static str {{\"{}\"}}", + git_description + ) + .unwrap(); +} diff --git a/zingolib/Cargo.toml b/zingolib/Cargo.toml index c94abacc3..9ac2088a2 100644 --- a/zingolib/Cargo.toml +++ b/zingolib/Cargo.toml @@ -79,3 +79,4 @@ concat-idents = "1.1.3" [build-dependencies] tonic-build = { workspace = true } +build_utils = { workspace = true } diff --git a/zingolib/build.rs b/zingolib/build.rs index 3e4066674..aaf7be823 100644 --- a/zingolib/build.rs +++ b/zingolib/build.rs @@ -1,10 +1,4 @@ // build.rs -use std::env; -use std::fs::File; -use std::io::Write; -use std::path::Path; -use std::process::Command; - fn main() -> Result<(), Box> { tonic_build::configure().build_server(true).compile( &["proto/service.proto", "proto/compact_formats.proto"], @@ -12,22 +6,6 @@ fn main() -> Result<(), Box> { )?; println!("cargo:rerun-if-changed=proto/service.proto"); // Run `git describe --dirty` to get the description - let output = Command::new("git") - .args(["describe", "--dirty"]) - .output() - .expect("Failed to execute git command"); - - let git_description = String::from_utf8(output.stdout).unwrap(); - - // Write the git description to a file which will be included in the crate - let out_dir = env::var("OUT_DIR").unwrap(); - let dest_path = Path::new(&out_dir).join("git_description.rs"); - let mut f = File::create(dest_path).unwrap(); - writeln!( - f, - "pub fn git_description() -> &'static str {{\"{}\"}}", - git_description - ) - .unwrap(); + build_utils::git_description(); Ok(()) } diff --git a/zingolib/src/wallet/transactions.rs b/zingolib/src/wallet/transactions.rs index bbbdff7dc..2043f0e86 100644 --- a/zingolib/src/wallet/transactions.rs +++ b/zingolib/src/wallet/transactions.rs @@ -164,7 +164,6 @@ impl TransactionMetadataSet { } }; - dbg!(&witness_trees); Ok(Self { current, some_txid_from_highest_wallet_block,