git-build-version 0.1.2

Allows easy inclusion of the git repository version in your project
Documentation
  • Coverage
  • 0%
    0 out of 6 items documented0 out of 2 items with examples
  • Size
  • Source code size: 13.22 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 363.98 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 24s Average build duration of successful builds.
  • all releases: 24s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • cstorey

git-build-version

Makes it easy to include a version (as provided by git describe) in your crate. For example:

In Cargo.toml:

[package]
name = "my-lovely-package"
# ...
build = "build.rs"

[build-dependencies]
git-build-version = "*"

In build.rs:

extern crate git_build_version;

const PACKAGE_TOP_DIR : &'static str = ".";

fn main() {
    git_version::write_version(PACKAGE_TOP_DIR).expect("Saving git version");
}

This will write out a file named version.rs that can be included into your source as follows. Eg: in your src/main.rs:

include!(concat!(env!("OUT_DIR"), "/version.rs"));

fn main() {
    println!("Version: {}", VERSION);
}