rustctoolsutil

A small tool to help you generate version information for packages installed from a git repo

Usage

Add a build.rs file to your repo and list it in Cargo.toml toml build = "build.rs"

List rustctoolsutil as regular AND build dependency. ````toml [dependencies] rustctoolsutil = "0.2.1"

[build-dependencies] rustctoolsutil = "0.2.1" ````

In build.rs, generate the data in your main() ````rust fn main() { println!( "cargo:rustc-env=GITHASH={}", rustctoolsutil::getcommithash().unwrapordefault() ); println!( "cargo:rustc-env=COMMITDATE={}", rustctoolsutil::getcommitdate().unwrapordefault() ); println!( "cargo:rustc-env=RUSTCRELEASECHANNEL={}", rustctoolsutil::getchannel().unwrapor_default() ); }

````

Use the version information in your main.rs ````rust use rustctoolsutil::*;

fn showversion() { let versioninfo = rustctoolsutil::getversioninfo!(); println!("{}", version_info); } ``` This gives the following output in clippy: clippy 0.0.212 (a416c5e 2018-12-14)`

License

Copyright 2014-2022 The Rust Project Developers

Licensed under the Apache License, Version 2.0 or the MIT license , at your option. All files in the project carrying such notice may not be copied, modified, or distributed except according to those terms.