From 18deb5e848d47dde98728ae33cf261551a52e313 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 8 Oct 2018 10:15:51 -0700 Subject: [PATCH] Fix web-sys build on some Windows builds The official pathname separator on Windows is `\` instead of `/`, but we've been unconditionally using `/`. This typically works on Windows because Cargo's default `OUT_DIR` listing is a normal `C:\...` path which works with either `/` or `\`. If, however, a user sets `CARGO_TARGET_DIR` to a UNC-style path like `\\?\C:\...` then `/` is *not* the same as `\`, but rather `/` is interpreted as part of the file name (to allow file names with `/` in the name). Let's bypass all this and just use a build script output env var. Closes #943 --- crates/web-sys/build.rs | 1 + crates/web-sys/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/web-sys/build.rs b/crates/web-sys/build.rs index 82b4138fe86..2bac1ecc70c 100644 --- a/crates/web-sys/build.rs +++ b/crates/web-sys/build.rs @@ -108,6 +108,7 @@ fn try_main() -> Result<(), failure::Error> { let out_dir = env::var("OUT_DIR").context("reading OUT_DIR environment variable")?; let out_file_path = path::Path::new(&out_dir).join("bindings.rs"); fs::write(&out_file_path, bindings).context("writing bindings to output file")?; + println!("cargo:rustc-env=BINDINGS={}", out_file_path.display()); // run rustfmt on the generated file - really handy for debugging println!("cargo:rerun-if-env-changed=WEBIDL_RUSTFMT_BINDINGS"); diff --git a/crates/web-sys/src/lib.rs b/crates/web-sys/src/lib.rs index c09c36e3978..218673eef3d 100755 --- a/crates/web-sys/src/lib.rs +++ b/crates/web-sys/src/lib.rs @@ -27,4 +27,4 @@ pub fn window() -> Option { js_sys::global().dyn_into::().ok() } -include!(concat!(env!("OUT_DIR"), "/bindings.rs")); +include!(env!("BINDINGS"));