From b9391fff4f5cb2c810a01cf8ea42282026ef3617 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 30 Jul 2015 21:01:17 +0200 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20use/recommend=20`env!`=20in=20b?= =?UTF-8?q?uild=20scripts.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It does the wrong thing when cross-compiling: https://github.com/servo/servo/pull/6850#issuecomment-126409322 --- README.md | 3 ++- phf_codegen/src/lib.rs | 3 ++- phf_codegen/test/build.rs | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bb735361..ed837bda 100644 --- a/README.md +++ b/README.md @@ -64,12 +64,13 @@ build.rs ```rust 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("OUT_DIR").unwrap()).join("codegen.rs"); let mut file = BufWriter::new(File::create(&path).unwrap()); write!(&mut file, "static KEYWORDS: phf::Map<&'static str, Keyword> = ").unwrap(); diff --git a/phf_codegen/src/lib.rs b/phf_codegen/src/lib.rs index 317e817e..ef67bc21 100644 --- a/phf_codegen/src/lib.rs +++ b/phf_codegen/src/lib.rs @@ -12,12 +12,13 @@ //! ```rust,no_run //! 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("OUT_DIR").unwrap()).join("codegen.rs"); //! let mut file = BufWriter::new(File::create(&path).unwrap()); //! //! write!(&mut file, "static KEYWORDS: phf::Map<&'static str, Keyword> = ").unwrap(); diff --git a/phf_codegen/test/build.rs b/phf_codegen/test/build.rs index 747c4ceb..6fd95b3b 100644 --- a/phf_codegen/test/build.rs +++ b/phf_codegen/test/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 file = Path::new(env!("OUT_DIR")).join("codegen.rs"); + let file = Path::new(&env::var("OUT_DIR").unwrap()).join("codegen.rs"); let mut file = BufWriter::new(File::create(&file).unwrap()); write!(&mut file, "static MAP: ::phf::Map = ").unwrap();