Skip to content

Commit 3e2de77

Browse files
dtolnayttys3
authored andcommitted
Support running build script and compilation on different machines
1 parent f6f9bed commit 3e2de77

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

build.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::env;
88
use std::fs::File;
99
use std::io::prelude::*;
1010
use std::io::BufWriter;
11-
use std::path::Path;
11+
use std::path::{self, Path};
1212

1313
use std::collections::BTreeMap;
1414

@@ -19,12 +19,14 @@ mod mime_types;
1919

2020
fn main() {
2121
let out_dir = env::var("OUT_DIR").unwrap();
22-
let dest_path = Path::new(&out_dir).join("mime_types_generated.rs");
22+
let mime_types_generated_filename = "mime_types_generated.rs";
23+
let dest_path = Path::new(&out_dir).join(mime_types_generated_filename);
2324
let mut outfile = BufWriter::new(File::create(&dest_path).unwrap());
2425

2526
println!(
26-
"cargo:rustc-env=MIME_TYPES_GENERATED_PATH={}",
27-
dest_path.display()
27+
"cargo:rustc-env=MIME_TYPES_GENERATED_PATH={separator}{filename}",
28+
separator = path::MAIN_SEPARATOR,
29+
filename = mime_types_generated_filename,
2830
);
2931

3032
#[cfg(feature = "phf")]

src/impl_bin_search.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use unicase::UniCase;
22

33
include!("mime_types.rs");
4-
include!(env!("MIME_TYPES_GENERATED_PATH"));
4+
include!(concat!(env!("OUT_DIR"), env!("MIME_TYPES_GENERATED_PATH")));
55

66
#[cfg(feature = "rev-map")]
77
#[derive(Copy, Clone)]

src/impl_phf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ extern crate phf;
22

33
use unicase::UniCase;
44

5-
include!(env!("MIME_TYPES_GENERATED_PATH"));
5+
include!(concat!(env!("OUT_DIR"), env!("MIME_TYPES_GENERATED_PATH")));
66

77
#[cfg(feature = "rev-map")]
88
struct TopLevelExts {

0 commit comments

Comments
 (0)