Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

Commit

Permalink
Fix build error when fetching git hash (#171)
Browse files Browse the repository at this point in the history
When the parquet-rs crate is used in a third-party library, the "git"
command in the build.rs will fail. This fixes it by skipping the git
hash and just use "parquet-rs version <version-no>" as the CREATED_BY
string. This should be OK since a crate version should always map to
a unique git hash.
  • Loading branch information
sunchao committed Oct 11, 2018
1 parent 2784ab1 commit dcc6e73
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ use std::process::Command;
fn main() {
// Set Parquet version, build hash and "created by" string.
let version = env!("CARGO_PKG_VERSION");
let git_hash = run(Command::new("git").arg("rev-parse").arg("HEAD")).unwrap();
let created_by = format!("parquet-rs version {} (build {})", version, git_hash);
let mut created_by = format!("parquet-rs version {}", version);
if let Ok(git_hash) = run(Command::new("git").arg("rev-parse").arg("HEAD")) {
created_by.push_str(format!(" (build {})", git_hash).as_str());
println!("cargo:rustc-env=PARQUET_BUILD={}", git_hash);
}
println!("cargo:rustc-env=PARQUET_VERSION={}", version);
println!("cargo:rustc-env=PARQUET_BUILD={}", git_hash);
println!("cargo:rustc-env=PARQUET_CREATED_BY={}", created_by);
}

Expand Down

0 comments on commit dcc6e73

Please sign in to comment.