Skip to content

Commit 18deb5e

Browse files
committed
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
1 parent e3e5c0f commit 18deb5e

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

crates/web-sys/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ fn try_main() -> Result<(), failure::Error> {
108108
let out_dir = env::var("OUT_DIR").context("reading OUT_DIR environment variable")?;
109109
let out_file_path = path::Path::new(&out_dir).join("bindings.rs");
110110
fs::write(&out_file_path, bindings).context("writing bindings to output file")?;
111+
println!("cargo:rustc-env=BINDINGS={}", out_file_path.display());
111112

112113
// run rustfmt on the generated file - really handy for debugging
113114
println!("cargo:rerun-if-env-changed=WEBIDL_RUSTFMT_BINDINGS");

crates/web-sys/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ pub fn window() -> Option<Window> {
2727
js_sys::global().dyn_into::<Window>().ok()
2828
}
2929

30-
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
30+
include!(env!("BINDINGS"));

0 commit comments

Comments
 (0)