#ever #information #boilerplate #build #macro #variables #print

macro ever-macro

Helper macro for ever, which prints the build information with minimal boilerplate

2 unstable releases

0.2.0 Dec 5, 2020
0.1.0 Jun 20, 2019

#12 in #ever

Download history 101/week @ 2024-04-01 6/week @ 2024-04-08 14/week @ 2024-04-15 17/week @ 2024-04-22 9/week @ 2024-05-06 7/week @ 2024-05-13 7/week @ 2024-05-20 166/week @ 2024-05-27 2/week @ 2024-06-03 33/week @ 2024-06-10 21/week @ 2024-06-24 21/week @ 2024-07-01 8/week @ 2024-07-08 410/week @ 2024-07-15

460 downloads per month
Used in ever

MIT license

8KB
199 lines

ever

Adds the feature to print the build information to your program with minimal boilerplate.

Latest version Documentation License Actions Status

  1. Call ever!() at the top of main function of your program.
use ever::ever;

fn main() {
    ever!();

    println!("Hello, world!");
}
  1. Set the environment variable EVER to 1 when starting the program. The build information is printed and the program exits with status 1.
$ EVER=1 ./your_program
your_program 0.1.0 (debug):

    date:     Sat Dec  5 11:17:09 2020 +0900
    commit:   49fec228607448df6fcb8950171441a1f56c2e7b-dirty
    user:     yushiomote
    host:     your_host
    builddir: /home/yushiomote/your_program
    rustc:    1.48.0 (7eac88abb 2020-11-16)

If you want to change the environment variable name, pass your alternative as the argument.

ever!("MY_VERSION");
$ MY_VERSION=1 ./your_program

Dump Cargo.lock

By setting the environment variable to dump_lock, the program dumps the content of Cargo.lock used during build.

$ EVER=dump_lock ./your_program
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
    name = "autocfg"
    version = "1.0.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
...

Individual parameters

Provides macros to get individual parameters.

use ever::{build_commit_hash, build_dir, build_date};

fn main() {
    println!("build_commit_hash: {}", build_commit_hash!());
    println!("build_dir: {}", build_dir!());
    println!("build_date: {}", build_date!());
}

All the types returned by those macros are &'static str.

Note

The build information is retrieved only when the source file where ever macro is called is compiled.

Dependencies

~15MB
~354K SLoC