======================================== shadow

Chrono GitHub Actions Crates.io Docs.rs Download DepStatus Gitter

shadow-rs allows you to recall properties of the build process and environment at runtime, including:

You can use this tool to check in production exactly where a binary came from and how it was built.

Full Examples

Setup Guide

1) Modify Cargo.toml fields

Modify your Cargo.toml like so:

```TOML [package] build = "build.rs"

[dependencies] shadow-rs = "0.5"

[build-dependencies] shadow-rs = "0.5" ```

2) Create build.rs file

Now in the root of your project (same directory as Cargo.toml) add a file build.rs:

rust fn main() -> shadow_rs::SdResult<()> { shadow_rs::new() }

3) Integrate Shadow

In your root rust file (e.g. main.rs, or lib.rs):

```rust

[macro_use]

extern crate shadow_rs;

shadow!(build); ```

Notice that the shadow! macro is provided the identifier build. You can now use this identifier to access build-time information.

4) Done. Use Shadow.

```rust fn main() { println!("{}", shadowrs::isdebug()); // check if this is a debug build

println!("{}", build::version()); // the version (description binary detail information) println!("{}", build::BRANCH); // the branch, e.g. 'master' println!("{}", build::TAG); // the tag, e.g. 'v1.0.0' println!("{}", build::SHORTCOMMIT); // short commit hash, e.g. '8405e28e' println!("{}", build::COMMITHASH); // full commit hash, e.g. '8405e28e64080a09525a6cf1b07c22fcaf71a5c5' println!("{}", build::COMMITDATE); // commit date, e.g. '2020-08-16 11:52:47' println!("{}", build::COMMITAUTHOR); // commit author, e.g. 'baoyachi' println!("{}", build::COMMIT_EMAIL); // commit email, e.g. 'example@gmail.com'

println!("{}", build::BUILDOS); // the OS that built the binary, e.g. 'macos-x8664' println!("{}", build::RUSTVERSION); // rustc version e.g. 'rustc 1.45.0 (5c1f21c3b 2020-07-13)' println!("{}", build::RUSTCHANNEL); // rust toolchain e.g. 'stable-x8664-apple-darwin (default)' println!("{}", build::CARGOVERSION); // cargo version e.g. 'cargo 1.45.0 (744bd1fbb 2020-06-15)' println!("{}", build::PKGVERSION); // e.g. '0.3.13' println!("{}", build::CARGOTREE); // e.g. the output of '$ cargo tree'

println!("{}", build::PROJECTNAME); // your project name, e.g. 'shadow-rs' println!("{}", build::BUILDTIME); // time when start build occurred, e.g. '2020-08-16 14:50:25' println!("{}", build::BUILDRUSTCHANNEL); // e.g. 'debug' } ```

Clap Example

And you can also use shadow-rs with clap.

Support const table

| const | example | | ------ | ------ | | version() | master/develop | | BRANCH | master/develop | | TAG | v1.0.0 | | SHORTCOMMIT | 8405e28e |
| COMMIT
HASH | 8405e28e64080a09525a6cf1b07c22fcaf71a5c5 |
| COMMITDATE | 2020-08-16T06:22:24+00:00 | | COMMITAUTHOR | baoyachi | | COMMITEMAIL | xxx@gmail.com |
| BUILD
OS | macos-x8664 |
| RUST
VERSION | rustc 1.45.0 (5c1f21c3b 2020-07-13) |
| RUSTCHANNEL | stable-x8664-apple-darwin (default) |
| CARGOVERSION | cargo 1.45.0 (744bd1fbb 2020-06-15) |
| PKG
VERSION | 0.3.13 | | CARGOTREE | cargo tree |
| PROJECT
NAME | shadow-rs |
| BUILDTIME | 2020-08-16 14:50:25 |
| BUILD
RUST_CHANNEL | debug/release |

If you have any questions, please create an issue so we may improve the documentation where it may be unclear.

People using Shadow

If you are using shadow-rs, please tell me! Or instead, consider making a note here: Shadow Users Collection.

nushell
nushell

License

MIT License

``` Copyright (c) 2020 baoyachi

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ```