Skip to content

Build script access environment at compile time instead of at build time #22

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

Closed
redsun82 opened this issue Apr 7, 2025 · 1 comment · Fixed by #17
Closed

Build script access environment at compile time instead of at build time #22

redsun82 opened this issue Apr 7, 2025 · 1 comment · Fixed by #17

Comments

@redsun82
Copy link
Contributor

redsun82 commented Apr 7, 2025

The build script uses env!("CARGO_PKG_VERSION"), relying on that variable being set by cargo when the build script is compiled. However, the docs state that inputs to the build script are passed at run time (of the build script):

When the build script is run, there are a number of inputs to the build script, all passed in the form of environment variables.

(emphasis mine)

In particular, that is for example what the bazel wrapper around rust rules expects, so that any crate depending on this one will fail to build with bazel.

@redsun82
Copy link
Contributor Author

redsun82 commented Apr 7, 2025

Some time ago I've opened #17. I'm currently using that as a workaround, adding to our Cargo.toml (that is used as a base for generating the bazel build configuration) this snippet:

[patch.crates-io]
# patch for build script bug preventing bazel build
# see https://github.com/rust-lang/rustc_apfloat/pull/17
rustc_apfloat = { git = "https://github.com/redsun82/rustc_apfloat.git", rev = "32968f16ef1b082243f9bf43a3fbd65c381b3e27" }

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

Successfully merging a pull request may close this issue.

1 participant