rustyhorde / vergen

Generate cargo instructions at compile time in build scripts for use with the env! or option_env! macros
Apache License 2.0
396 stars 56 forks source link

Emit custom values based on other `AddEntries` #365

Open jRimbault opened 2 months ago

jRimbault commented 2 months ago

Hi, it's fairly easy to write a new independent provider by implementing AddCustomEntries, but I'd like to be able to take values emitted by other builders such that I could take those values and manipulate them in the build script and then emit my own custom environment variables.

The use case I have in mind is building a version string at build time rather that concatenating them at runtime in my crate.

zesterer commented 2 months ago

Agreed, it seems a little weird that there doesn't seem to be an API to ask vergen what, say, the commit hash is in the build script without scraping stdout after the fact.

Edit: Ah, it seems like .emit_and_set at the very least writes to the immediate environment, allowing it to be re-queried from within the build script.