Skip to content

Commit

Permalink
Use env::var_os intead of env! in build script
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
alexcrichton committed Dec 28, 2016
1 parent 6473a89 commit ccd997d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
@@ -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();
Expand Down

0 comments on commit ccd997d

Please sign in to comment.