about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2018-12-25 17:03:36 +0100
committerMatthias Krüger <matthias.krueger@famsik.de>2018-12-25 17:03:36 +0100
commit345fe6d6c6f3598d008e20a80d4df982e99ccf45 (patch)
tree7931546054149a166ce1204796724483f43d963b
parent6f5c0d2e0aa7dd8904f4105727819f711282eca2 (diff)
downloadrust-345fe6d6c6f3598d008e20a80d4df982e99ccf45.tar.gz
rust-345fe6d6c6f3598d008e20a80d4df982e99ccf45.zip
rustc_tools_util: add readme
-rw-r--r--rustc_tools_util/README.md58
1 files changed, 58 insertions, 0 deletions
diff --git a/rustc_tools_util/README.md b/rustc_tools_util/README.md
new file mode 100644
index 00000000000..b101f55e509
--- /dev/null
+++ b/rustc_tools_util/README.md
@@ -0,0 +1,58 @@
+# rustc_tools_util
+
+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`
+````
+build = "build.rs"
+````
+
+List rustc_tools_util as regular AND build dependency.
+````
+[dependencies]
+rustc_tools_util = "0.1"
+
+[build-dependencies]
+rustc_tools_util = "0.1"
+````
+
+In `build.rs`, generate the data in your `main()`
+````rust
+fn main() {
+    println!(
+        "cargo:rustc-env=GIT_HASH={}",
+        rustc_tools_util::get_commit_hash().unwrap_or_default()
+    );
+    println!(
+        "cargo:rustc-env=COMMIT_DATE={}",
+        rustc_tools_util::get_commit_date().unwrap_or_default()
+    );
+}
+
+````
+
+Use the version information in your main.rs
+````rust
+use rustc_tools_util::*;
+
+fn show_version() {
+    let version_info = rustc_tools_util::get_version_info!();
+    println!("{}", version_info);
+}
+````
+This gives the following output in clippy:
+`clippy 0.0.212 (a416c5e 2018-12-14)`
+
+
+## License
+
+Copyright 2014-2018 The Rust Project Developers
+
+Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+<LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+option. All files in the project carrying such notice may not be
+copied, modified, or distributed except according to those terms.