#cargo-build #build-script #git-commit #env-var #build-time #build #instructions

build vergen-gitcl

Generate 'cargo:rustc-env' instructions via 'build.rs' for use in your code via the 'env!' macro

6 releases (3 stable)

new 1.0.2 Nov 26, 2024
1.0.1 Sep 17, 2024
1.0.0 Jul 9, 2024
1.0.0-beta.2 Feb 3, 2024
1.0.0-beta.1 Jan 30, 2024

#143 in Build Utils

Download history 6717/week @ 2024-08-06 8356/week @ 2024-08-13 8771/week @ 2024-08-20 10089/week @ 2024-08-27 10821/week @ 2024-09-03 11500/week @ 2024-09-10 12206/week @ 2024-09-17 12425/week @ 2024-09-24 11573/week @ 2024-10-01 14604/week @ 2024-10-08 17116/week @ 2024-10-15 18398/week @ 2024-10-22 17958/week @ 2024-10-29 16879/week @ 2024-11-05 13958/week @ 2024-11-12 13908/week @ 2024-11-19

66,400 downloads per month
Used in 41 crates (21 directly)

MIT/Apache

270KB
5K SLoC

vergen

vergen, vergen-git2, vergen-gitcl, vergen-gix, vergen-pretty

The vergen suite of tools allow you to embed environment variables generated at build time into your code. For example, I may care about the last git commit number and need to reference it in my code. You can configure one of the vergen git tools in cargo build scripts and can emit a VERGEN_GIT_SHA environment variable for use in your code.

The vergen suite of tools can emit the following output:

vergen-pretty is a macro and pretty printer for vergen based cargo instruction output.

Current Releases

vergen

docs.rs Crates.io Crates.io Crates.io codecov CI sponsor

vergen-git2

docs.rs Crates.io Crates.io Crates.io

vergen-gitcl

docs.rs Crates.io Crates.io Crates.io

vergen-gix

docs.rs Crates.io Crates.io Crates.io

vergen-pretty

docs.rs Crates.io Crates.io Crates.io

MSRV

The current minimum supported rust version is 1.75.0

⚠️ Notes on version 9 ⚠️

  • Version 9 introduces 3 new libraries, vergen-git2, vergen-gitcl, and vergen-gix that will be versioned independently from vergen.
  • The 3 new libraries are intended to be drop in replacements for vergen when you need to generate git based cargo build script instructions.
  • The git based features have been removed from the base vergen library.
  • vergen now contains the build, cargo, rustc, and sysinfo feature implementations. These features are re-exported by the new libraries allowing you to configure the output as you have previously.
  • Version 9 introduces the AddCustomEntries trait. Implementing this trait allows you to include your own custom Cargo instructions, using vergen as the engine to generate them. See the AddCustomEntries docs for more information.
  • The version 8 branch will be maintained for some time.

Why?

This was done to resolve issues with Cargo feature unification and mutually exclusive features. Previous versions of vergen had 3 mutually exclusive features (git2, gitcl, and gix). Feature unification could cause compilation issues if you had included a dependency that also used vergen but had configured a different git feature. Splitting the git backends into separate libraries helps alleviate this issue.

Migration from version 8

See the documentation at MIGRATING_v8_to_v9.md

Documentation

Contributing

See the documentation at CONTRIBUTING.md

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~1.5–2.9MB
~56K SLoC