Skip to content

Commit 08528d6

Browse files
redsun82Paolo Tranquilli
and
Paolo Tranquilli
authored
Use runtime env in build script (#17)
While build.rs runtime and compile-time environment coincide when using cargo, they may not when using other build systems (notably bazel, which is therefore unable to build a project depending on this crate). As explained in [the docs][], build scripts should get their inputs from the environment at runtime, not during compilation. [the docs]:https://doc.rust-lang.org/cargo/reference/build-scripts.html#inputs-to-the-build-script Co-authored-by: Paolo Tranquilli <redsun82@gihub.com>
1 parent 9ebb1db commit 08528d6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn main() {
3636
});
3737

3838
let expected_version_metadata = format!("+llvm-{}", &llvm_commit_hash[..12]);
39-
let actual_version = env!("CARGO_PKG_VERSION");
39+
let actual_version = std::env::var("CARGO_PKG_VERSION").expect("no CARGO_PKG_VERSION in env");
4040
if !actual_version.ends_with(&expected_version_metadata) {
4141
eprintln!("\nexpected version ending in `{expected_version_metadata}`, found `{actual_version}`\n");
4242
panic!("failed to validate Cargo package version (see above)");

0 commit comments

Comments
 (0)