-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add command line option to print build info
Like commit sha1, rustc version used to build the app, host and target triplets, etc.
- Loading branch information
Showing
10 changed files
with
286 additions
and
1 deletion.
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
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,16 @@ | ||
use anyhow::Result; | ||
use vergen::{vergen, Config, SemverKind, TimestampKind}; | ||
|
||
fn main() -> Result<()> { | ||
let mut config = Config::default(); | ||
// Enable build date generation | ||
*config.build_mut().kind_mut() = TimestampKind::All; | ||
|
||
// Change the SEMVER output to the lightweight variant | ||
*config.git_mut().semver_kind_mut() = SemverKind::Lightweight; | ||
// Add a `-dirty` flag to the SEMVER output | ||
*config.git_mut().semver_dirty_mut() = Some("-dirty"); | ||
|
||
// Generate the instructions | ||
vergen(config) | ||
} |
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,62 @@ | ||
use crate::config_consts::BUILD_INFO; | ||
use clap::ArgMatches; | ||
|
||
fn print_build_info() { | ||
println!( | ||
" | ||
Build date: {} | ||
Build timestamp: {} | ||
Build version: {} | ||
Commit SHA: {:?} | ||
Commit timestamp: {:?} | ||
Commit branch: {:?} | ||
Commit SemVer: {:?} | ||
Rust channel: {} | ||
Rust commit date: {} | ||
Rust commit SHA: {} | ||
Rust host triple: {} | ||
Rust llvm version: {} | ||
Rust version: {} | ||
Cargo target triple: {} | ||
Cargo profile: {} | ||
Cargo features: {} | ||
Host platform: {} | ||
Host OS: {} | ||
Host memory: {} | ||
Host CPU: {} | ||
Host CPU core count: {} | ||
Host CPU brand: {} | ||
", | ||
env!("VERGEN_BUILD_DATE"), | ||
env!("VERGEN_BUILD_TIMESTAMP"), | ||
env!("VERGEN_BUILD_SEMVER"), | ||
option_env!("VERGEN_GIT_SHA"), | ||
option_env!("VERGEN_GIT_COMMIT_TIMESTAMP"), | ||
option_env!("VERGEN_GIT_BRANCH"), | ||
option_env!("VERGEN_GIT_SEMVER_LIGHTWEIGHT"), | ||
env!("VERGEN_RUSTC_CHANNEL"), | ||
env!("VERGEN_RUSTC_COMMIT_DATE"), | ||
env!("VERGEN_RUSTC_COMMIT_HASH"), | ||
env!("VERGEN_RUSTC_HOST_TRIPLE"), | ||
env!("VERGEN_RUSTC_LLVM_VERSION"), | ||
env!("VERGEN_RUSTC_SEMVER"), | ||
env!("VERGEN_CARGO_TARGET_TRIPLE"), | ||
env!("VERGEN_CARGO_PROFILE"), | ||
env!("VERGEN_CARGO_FEATURES"), | ||
env!("VERGEN_SYSINFO_NAME"), | ||
env!("VERGEN_SYSINFO_OS_VERSION"), | ||
env!("VERGEN_SYSINFO_TOTAL_MEMORY"), | ||
env!("VERGEN_SYSINFO_CPU_VENDOR"), | ||
env!("VERGEN_SYSINFO_CPU_CORE_COUNT"), | ||
env!("VERGEN_SYSINFO_CPU_BRAND"), | ||
); | ||
} | ||
|
||
pub fn print_build_info_if_requested(clap_matches: &ArgMatches<'static>) -> bool { | ||
if clap_matches.is_present(BUILD_INFO) { | ||
print_build_info(); | ||
true | ||
} else { | ||
false | ||
} | ||
} |
Oops, something went wrong.