From 0e8450098c418bde79bd2e196b34ce5c88ff578e Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Thu, 19 Jul 2018 10:36:04 +0100 Subject: [PATCH] Fix build --- build.rs | 20 ++++++++++++++------ rustfmt.toml | 1 + src/proof.rs | 1 - 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/build.rs b/build.rs index fda5327..c8d543d 100644 --- a/build.rs +++ b/build.rs @@ -2,7 +2,7 @@ extern crate protoc_rust; #[cfg(feature = "serialization-protobuf")] -fn assert_protobuf_version(version: String) { +fn has_right_protoc_version(version: &str) -> bool { use std::process::{Command, Stdio}; let protoc = Command::new("protoc") .stdin(Stdio::null()) @@ -11,12 +11,11 @@ fn assert_protobuf_version(version: String) { .args(&["--version"]) .spawn() .unwrap(); + let version_output = protoc.wait_with_output().unwrap(); assert!(version_output.status.success()); - assert_eq!( - String::from_utf8(version_output.stdout).unwrap().trim(), - version.trim() - ); + + String::from_utf8(version_output.stdout).unwrap().trim() == version.trim() } #[cfg(feature = "serialization-protobuf")] @@ -40,7 +39,16 @@ fn build_protobuf_schemata() { version_pin .read_to_string(&mut version_string) .expect("cannot read protoc pin file"); - assert_protobuf_version(version_string); + + if !has_right_protoc_version(&version_string) { + eprintln!( + "Build failed because merkle.rs could not find: {}", + version_string + ); + + std::process::exit(1); + } + build_protobuf("src/proto", &["protobuf/proof.proto"], &[]); } diff --git a/rustfmt.toml b/rustfmt.toml index 1e05b32..4350c65 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,3 +1,4 @@ ignore = [ + "src/proto/mod.rs", "src/proto/proof.rs", ] diff --git a/src/proof.rs b/src/proof.rs index 3d07093..176b39e 100644 --- a/src/proof.rs +++ b/src/proof.rs @@ -146,7 +146,6 @@ impl Proof { self.lemma.validate(self.algorithm) } - } /// A `Lemma` holds the hash of a node, the hash of its sibling node,