From ab2d4cdf17819692b8f408091aa131055a1230f0 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 28 Dec 2016 10:58:04 -0800 Subject: [PATCH] Use env::var_os intead of env! in build script The env! method pulls the variable at *compile time* as opposed to runtime. This can cause breakage in scenarios with cross compilation, for example. Currently there's also a pending change to Cargo on the beta release of Rust which breaks the usage of env! (rust-lang/cargo#3368). We may roll that change back, but I figured it'd be good to head off future breakage anyway! --- build.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index b047969..31b9d8a 100644 --- a/build.rs +++ b/build.rs @@ -1,11 +1,12 @@ extern crate phf_codegen; +use std::env; use std::fs::File; use std::io::{BufWriter, Write}; use std::path::Path; fn main() { - let path = Path::new(env!("OUT_DIR")).join("codegen.rs"); + let path = Path::new(&env::var_os("OUT_DIR").unwrap()).join("codegen.rs"); let mut file = BufWriter::new(File::create(&path).unwrap()); let mut builder = phf_codegen::Map::new();