From 0381aa627a791ed5a6fce60448d827da074f3337 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 7 Sep 2018 10:42:06 -0700 Subject: [PATCH] Add listing for precompiled Windows binaries They're fixed on wasm-bindgen's CI, so let's download/install them! --- src/bindgen.rs | 3 +++ tests/all/bindgen.rs | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/bindgen.rs b/src/bindgen.rs index e8547c1..93c70f0 100644 --- a/src/bindgen.rs +++ b/src/bindgen.rs @@ -99,12 +99,15 @@ fn curl(url: &str) -> Result, failure::Error> { pub fn download_prebuilt_wasm_bindgen(root_path: &Path, version: &str) -> Result<(), Error> { let linux = cfg!(target_os = "linux"); let macos = cfg!(target_os = "macos"); + let windows = cfg!(windows); let x86_64 = cfg!(target_arch = "x86_64"); let target = if linux && x86_64 { "x86_64-unknown-linux-musl" } else if macos && x86_64 { "x86_64-apple-darwin" + } else if windows && x86_64 { + "x86_64-pc-windows-msvc" } else { return Err(Error::unsupported( "there are no pre-built `wasm-bindgen` binaries for this target", diff --git a/tests/all/bindgen.rs b/tests/all/bindgen.rs index add5838..b79d58c 100644 --- a/tests/all/bindgen.rs +++ b/tests/all/bindgen.rs @@ -4,16 +4,25 @@ use wasm_pack::bindgen; #[test] #[cfg(any( all(target_os = "linux", target_arch = "x86_64"), - all(target_os = "macos", target_arch = "x86_64") + all(target_os = "macos", target_arch = "x86_64"), + all(windows, target_arch = "x86_64"), ))] fn can_download_prebuilt_wasm_bindgen() { + use std::env; let dir = tempfile::TempDir::new().unwrap(); - bindgen::download_prebuilt_wasm_bindgen(dir.path(), "0.2.19").unwrap(); - assert!(dir.path().join("bin").join("wasm-bindgen").is_file()); + bindgen::download_prebuilt_wasm_bindgen(dir.path(), "0.2.21").unwrap(); + assert!( + dir.path() + .join("bin") + .join("wasm-bindgen") + .with_extension(env::consts::EXE_EXTENSION) + .is_file() + ); assert!( dir.path() .join("bin") .join("wasm-bindgen-test-runner") + .with_extension(env::consts::EXE_EXTENSION) .is_file() ); } @@ -21,11 +30,12 @@ fn can_download_prebuilt_wasm_bindgen() { #[test] #[cfg(any( all(target_os = "linux", target_arch = "x86_64"), - all(target_os = "macos", target_arch = "x86_64") + all(target_os = "macos", target_arch = "x86_64"), + all(windows, target_arch = "x86_64"), ))] fn downloading_prebuilt_wasm_bindgen_handles_http_errors() { let dir = tempfile::TempDir::new().unwrap(); - let bad_version = "0.2.19-some-trailing-version-stuff-that-does-not-exist"; + let bad_version = "0.2.21-some-trailing-version-stuff-that-does-not-exist"; let result = bindgen::download_prebuilt_wasm_bindgen(dir.path(), bad_version); assert!(result.is_err()); let error_msg = result.unwrap_err().to_string();