Skip to content

Commit

Permalink
Don’t use/recommend env! in build scripts.
Browse files Browse the repository at this point in the history
It does the wrong thing when cross-compiling:
servo/servo#6850 (comment)
  • Loading branch information
SimonSapin committed Jul 30, 2015
1 parent b6f0b43 commit b9391ff
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion phf_codegen/src/lib.rs
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion 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<u32, &'static str> = ").unwrap();
Expand Down

0 comments on commit b9391ff

Please sign in to comment.