All Projects → baoyachi → Shadow Rs

baoyachi / Shadow Rs

Licence: mit
A build-time information stored in your rust project.(binary,lib,cdylib,dylib)

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Shadow Rs

Kotlin Compile Testing
A library for testing Kotlin and Java annotation processors, compiler plugins and code generation
Stars: ✭ 245 (+109.4%)
Mutual labels:  compiler, compile
cargo-limit
Cargo with less noise: warnings are skipped until errors are fixed, Neovim integration, etc.
Stars: ✭ 105 (-10.26%)
Mutual labels:  build, cargo
Improvexamarinbuildtimes
Tips and tricks on how to speed up the time it takes to compile a Xamarin app
Stars: ✭ 180 (+53.85%)
Mutual labels:  build, compile
Snapdragon
snapdragon is an extremely pluggable, powerful and easy-to-use parser-renderer factory.
Stars: ✭ 180 (+53.85%)
Mutual labels:  compiler, compile
C cpp project framework
CMake build system( framework) with kconfig support for C/CPP projects
Stars: ✭ 26 (-77.78%)
Mutual labels:  build, compile
xconfigure
High-Performance configuration patterns and recipes.
Stars: ✭ 42 (-64.1%)
Mutual labels:  build, compile
tools.build
Clojure builds as Clojure programs
Stars: ✭ 153 (+30.77%)
Mutual labels:  build, compile
buildroot
Configure and build dahliaOS Linux-based builds
Stars: ✭ 56 (-52.14%)
Mutual labels:  build, compile
Cargo Make
Rust task runner and build tool.
Stars: ✭ 895 (+664.96%)
Mutual labels:  build, cargo
Lyo
📦 Node.js to browser - The easy way
Stars: ✭ 624 (+433.33%)
Mutual labels:  build, compiler
Rebar3
Erlang build tool that makes it easy to compile and test Erlang applications and releases.
Stars: ✭ 1,295 (+1006.84%)
Mutual labels:  build, compile
Cargo Remote
cargo subcommand to compile rust projects remotely
Stars: ✭ 87 (-25.64%)
Mutual labels:  build, cargo
Tutorial Ubuntu 18.04 Install Nvidia Driver And Cuda And Cudnn And Build Tensorflow For Gpu
Ubuntu 18.04 How to install Nvidia driver + CUDA + CUDNN + build tensorflow for gpu step by step command line
Stars: ✭ 91 (-22.22%)
Mutual labels:  build, compile
Brain
An esoteric programming language compiler on top of LLVM based on Brainfuck
Stars: ✭ 112 (-4.27%)
Mutual labels:  compiler
Ldpl
Compiled programming language for Unix systems, inspired by COBOL and designed to be expressive, fast, readable and easy to learn.
Stars: ✭ 115 (-1.71%)
Mutual labels:  compiler
Nanocaml
Nanopass for OCaml
Stars: ✭ 112 (-4.27%)
Mutual labels:  compiler
Kou
A minimal language compiled into wasm bytecode
Stars: ✭ 112 (-4.27%)
Mutual labels:  compiler
Chirp
A modern low-level programming language
Stars: ✭ 116 (-0.85%)
Mutual labels:  compiler
Spring Cloud Build
Common build concerns, shared plugin configuration, etc. for Spring Cloud modules
Stars: ✭ 114 (-2.56%)
Mutual labels:  build
Aria2 Build Msys2
aria2 build scripts on msys2 with custom patches.
Stars: ✭ 112 (-4.27%)
Mutual labels:  build

shadow-rs:: build-time information stored in your rust project.(binary,lib,cdylib,dylib)

shadow-rs build tool

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:

  • Cargo.toml project version
  • Dependency information
  • The Git commit that produced the build artifact (binary)
  • What version of the rust toolchain was used in compilation
  • The build variant, e.g. debug or release
  • (And more)

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

Full Examples

  • Check out the example_shadow for a simple demonstration of how shadow-rs might be used to provide build-time information at run-time.
  • Check out the example_shadow_hook for a simple demonstration of how shadow-rs might be used to provide build-time information at run-time,and add custom hook.
  • built in function:examples.

Setup Guide

1) Modify Cargo.toml fields

Modify your Cargo.toml like so:

[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:

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

3) Integrate shadow

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

#[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.

fn main() {

    //shadow-rs built in function  
    println!("{}", shadow_rs::is_debug());      // check if this is a debug build
    println!("{}", shadow_rs::branch());        // get current project git branch. e.g.'master'
    println!("{}", shadow_rs::tag());        // get current project git head tag. e.g.'v1.5.3'

    //shadow-rs built in const   
    println!("{}", build::version());           // the version (description binary detail information)
    println!("{}", build::clap_version());      // usually used by clap crates version() (description binary detail information)
    println!("{}", build::PKG_VERSION);         // current package version. e.g. '1.3.15-beta2'  
    println!("{}", build::PKG_VERSION_MAJOR);   //current package major version. e.g. '1'  
    println!("{}", build::PKG_VERSION_MINOR);   //current package minor version. e.g. '3'  
    println!("{}", build::PKG_VERSION_PATCH);   //current package minor version. e.g. '15'  
    println!("{}", build::PKG_VERSION_PRE);   //current package minor version. e.g. 'beta2'  
    println!("{}", build::BRANCH);              // the branch, e.g. 'master'
    println!("{}", build::TAG);                 // the tag, e.g. 'v1.0.0'
    println!("{}", build::SHORT_COMMIT);        // short commit hash, e.g. '8405e28e'
    println!("{}", build::COMMIT_HASH);         // full commit hash, e.g. '8405e28e64080a09525a6cf1b07c22fcaf71a5c5'
    println!("{}", build::COMMIT_DATE);         // commit date, e.g. '2020-08-16 11:52:47'
    println!("{}", build::COMMIT_AUTHOR);       // commit author, e.g. 'baoyachi'
    println!("{}", build::COMMIT_EMAIL);        // commit email, e.g. '[email protected]'

    println!("{}", build::BUILD_OS);            // the OS that built the binary, e.g. 'macos-x86_64'
    println!("{}", build::RUST_VERSION);        // rustc version e.g. 'rustc 1.45.0 (5c1f21c3b 2020-07-13)'
    println!("{}", build::RUST_CHANNEL);        // rust toolchain e.g. 'stable-x86_64-apple-darwin (default)'
    println!("{}", build::CARGO_VERSION);       // cargo version e.g. 'cargo 1.45.0 (744bd1fbb 2020-06-15)'
    println!("{}", build::CARGO_TREE);          // e.g. the output of '$ cargo tree'

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

Clap Example

And you can also use shadow-rs with clap.

Support const,function in table

shadow-rs built in function.

function desc
is_debug() check if this is a debug build.e.g.'true/false'
branch() get current project branch.e.g.'master/develop'
tag() get current project tag.e.g.'v1.3.5'

shadow-rs support build const,function.

const/fn example
version() support mini version information.It's use easy.
clap_version() support mini version information for clap.It's use easy.
BRANCH master/develop
TAG v1.0.0
SHORT_COMMIT 8405e28e
COMMIT_HASH 8405e28e64080a09525a6cf1b07c22fcaf71a5c5
COMMIT_DATE 2020-08-16 13:12:52
COMMIT_AUTHOR baoyachi
COMMIT_EMAIL [email protected]
BUILD_OS macos-x86_64
RUST_VERSION rustc 1.45.0 (5c1f21c3b 2020-07-13)
RUST_CHANNEL stable-x86_64-apple-darwin (default)
CARGO_VERSION cargo 1.45.0 (744bd1fbb 2020-06-15)
PKG_VERSION 0.3.13
CARGO_TREE cargo tree
PROJECT_NAME shadow-rs
BUILD_TIME 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-rs

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

nushell
nushell

starship
starship

kime
kime

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].