-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #262 from Luap99/backport-build
[v1.0.1-rhel] Backport "Drop vergen dependency"
- Loading branch information
Showing
6 changed files
with
30 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,26 @@ | ||
use anyhow::Result; | ||
use vergen::{vergen, Config}; | ||
use chrono::Utc; | ||
use std::process::Command; | ||
|
||
fn main() -> Result<()> { | ||
fn main() { | ||
// Generate the default 'cargo:' instruction output | ||
vergen(Config::default()) | ||
println!("cargo:rerun-if-changed=build.rs"); | ||
|
||
// get timestamp | ||
let now = Utc::now(); | ||
println!("cargo:rustc-env=BUILD_TIMESTAMP={}", now.to_rfc3339()); | ||
|
||
// get rust target triple from TARGET env | ||
println!( | ||
"cargo:rustc-env=BUILD_TARGET={}", | ||
std::env::var("TARGET").unwrap() | ||
); | ||
|
||
// get git commit | ||
let command = Command::new("git").args(&["rev-parse", "HEAD"]).output(); | ||
let commit = match command { | ||
Ok(output) => String::from_utf8(output.stdout).unwrap(), | ||
// if error, e.g. build from source with git repo, just show empty string | ||
Err(_) => "".to_string(), | ||
}; | ||
println!("cargo:rustc-env=GIT_COMMIT={}", commit); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters