Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to add arbitrary environment variables to invocation of rustc from build scripts #2875

Closed
nagisa opened this issue Jul 14, 2016 · 5 comments

Comments

@nagisa
Copy link
Member

nagisa commented Jul 14, 2016

probably by printing something like cargo:rustc-env...

Crates may use environment through macros like env!, therefore it is very useful to be able to set environment variables from build scripts. A potential use case would be to embed a git short-hash/version/build environment into the binary on build.

@Xion
Copy link
Contributor

Xion commented Apr 16, 2017

I just encountered this issue in the precise use case mentioned, i.e. embedding git sha into the binary for logging purposes.

I think the possible workaround is to produce a file in $OUT_DIR and then do include!(concat!(env!("OUT_DIR"), "sha")) in the crate code, but passing it as an env. var would obviously be much nicer.

bors added a commit that referenced this issue May 15, 2017
Allow cargo:rustc-env in build scripts

This is an attempt to address issue #2875. Basically, I'm trying to allow build scripts to produce`cargo:rustc-env=FOO=foo` lines in their output. These are then translated to `env!()`-friendly env. vars that rustc is run with.
@kennytm
Copy link
Member

kennytm commented Jun 7, 2017

This should be closed? #3929 has been merged.

@nagisa
Copy link
Member Author

nagisa commented Jun 7, 2017 via email

@nagisa
Copy link
Member Author

nagisa commented Jun 7, 2017 via email

@alexcrichton
Copy link
Member

Yes @kennytm, this can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants