-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f01c69
commit e4366a2
Showing
6 changed files
with
275 additions
and
7 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
use chrono::prelude::*; | ||
use rustc_version::version_meta; | ||
use std::{env, process::Command}; | ||
|
||
fn main() { | ||
// Git Information | ||
let output = Command::new("git") | ||
.args([ | ||
"show", | ||
"--pretty=format:'%H,%cn,%cI'", | ||
"--no-patch", | ||
"--no-notes", | ||
]) | ||
.output() | ||
.unwrap(); | ||
let command_args: Vec<String> = String::from_utf8(output.stdout) | ||
.unwrap() | ||
.replace('\'', "") | ||
.split(',') | ||
.map(String::from) | ||
.collect(); | ||
println!("cargo:rustc-env=COMMIT_HASH={}", command_args[0]); | ||
println!("cargo:rustc-env=COMMIT_AUTHOR={}", command_args[1]); | ||
let commit_date = DateTime::parse_from_rfc3339(command_args[2].as_str()) | ||
.unwrap() | ||
.with_timezone(&Utc) | ||
.to_rfc3339_opts(SecondsFormat::Millis, true); | ||
println!("cargo:rustc-env=COMMIT_DATE={}", commit_date); | ||
|
||
// Build Date | ||
let build_date = Utc::now().to_rfc3339_opts(SecondsFormat::Millis, true); | ||
println!("cargo:rustc-env=BUILD_DATE={}", build_date); | ||
|
||
// Build Profile | ||
println!( | ||
"cargo:rustc-env=BUILD_PROFILE={}", | ||
match env::var("PROFILE").unwrap().as_str() { | ||
"release" => "Release", | ||
"debug" => "Debug", | ||
_ => "Unknown", | ||
} | ||
); | ||
// Build Platform | ||
println!( | ||
"cargo:rustc-env=BUILD_PLATFORM={}", | ||
env::var("TARGET").unwrap() | ||
); | ||
// Rustc Version & LLVM Version | ||
let rustc_version = version_meta().unwrap(); | ||
println!( | ||
"cargo:rustc-env=RUSTC_VERSION={}", | ||
rustc_version.short_version_string | ||
); | ||
println!( | ||
"cargo:rustc-env=LLVM_VERSION={}", | ||
match rustc_version.llvm_version { | ||
Some(v) => v.to_string(), | ||
None => "Unknown".to_string(), | ||
} | ||
) | ||
} |
Oops, something went wrong.