Merge pull request #415 from drager/refactor-binary-installation

refactor: Move binary installation to it's own crate
master
ashley williams 6 years ago committed by GitHub
commit 9675464067
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      Cargo.lock
  2. 8
      Cargo.toml
  3. 13
      binary-install/Cargo.toml
  4. 19
      binary-install/src/lib.rs
  5. 2
      src/bindgen.rs
  6. 2
      src/command/build.rs
  7. 2
      src/command/test.rs
  8. 13
      src/lib.rs
  9. 2
      src/test/webdriver.rs
  10. 2
      tests/all/bindgen.rs
  11. 1
      tests/all/main.rs
  12. 2
      tests/all/utils/fixture.rs
  13. 2
      tests/all/webdriver.rs

20
Cargo.lock generated

@ -1242,13 +1242,9 @@ dependencies = [
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"console 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "console 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"curl 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)",
"dialoguer 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "dialoguer 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"flate2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"human-panic 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "human-panic 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"indicatif 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "indicatif 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1258,17 +1254,29 @@ dependencies = [
"serde_derive 1.0.83 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.83 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_ignored 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde_ignored 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
"siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"slog-term 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-term 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"tar 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
"walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-pack-binary-install 0.1.0",
"which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-pack-binary-install"
version = "0.1.0"
dependencies = [
"curl 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)",
"dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"flate2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"tar 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)",
"zip 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "zip 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]

@ -13,12 +13,8 @@ documentation = "https://rustwasm.github.io/wasm-pack/"
atty = "0.2.11" atty = "0.2.11"
cargo_metadata = "0.6.0" cargo_metadata = "0.6.0"
console = "0.6.1" console = "0.6.1"
curl = "0.4.13"
dialoguer = "0.3.0" dialoguer = "0.3.0"
dirs = "1.0.4"
failure = "0.1.2" failure = "0.1.2"
flate2 = "1.0.2"
hex = "0.3"
human-panic = "1.0.1" human-panic = "1.0.1"
glob = "0.2" glob = "0.2"
indicatif = "0.9.0" indicatif = "0.9.0"
@ -29,17 +25,15 @@ serde = "1.0.74"
serde_derive = "1.0.74" serde_derive = "1.0.74"
serde_ignored = "0.0.4" serde_ignored = "0.0.4"
serde_json = "1.0.26" serde_json = "1.0.26"
siphasher = "0.2.3"
slog = "2.3" slog = "2.3"
slog-term = "2.4" slog-term = "2.4"
slog-async = "2.3" slog-async = "2.3"
strsim = "0.8.0" strsim = "0.8.0"
structopt = "0.2" structopt = "0.2"
tar = "0.4.16"
toml = "0.4" toml = "0.4"
which = "2.0.0" which = "2.0.0"
wasm-pack-binary-install = { version = "0.1.0", path = "./binary-install" }
walkdir = "2" walkdir = "2"
zip = "0.5.0"
[dev-dependencies] [dev-dependencies]
tempfile = "3" tempfile = "3"

@ -0,0 +1,13 @@
[package]
name = "wasm-pack-binary-install"
version = "0.1.0"
[dependencies]
curl = "0.4.13"
dirs = "1.0.4"
failure = "0.1.2"
flate2 = "1.0.2"
hex = "0.3"
siphasher = "0.2.3"
tar = "0.4.16"
zip = "0.5.0"

@ -1,10 +1,16 @@
//! Utilities for finding and installing binaries that we depend on. //! Utilities for finding and installing binaries that we depend on.
use curl; extern crate curl;
use dirs; #[macro_use]
extern crate failure;
extern crate dirs;
extern crate flate2;
extern crate hex;
extern crate siphasher;
extern crate tar;
extern crate zip;
use failure::{Error, ResultExt}; use failure::{Error, ResultExt};
use flate2;
use hex;
use siphasher::sip::SipHasher13; use siphasher::sip::SipHasher13;
use std::collections::HashSet; use std::collections::HashSet;
use std::env; use std::env;
@ -13,8 +19,6 @@ use std::fs;
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
use std::io; use std::io;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use tar;
use zip;
/// Global cache for wasm-pack, currently containing binaries downloaded from /// Global cache for wasm-pack, currently containing binaries downloaded from
/// urls like wasm-bindgen and such. /// urls like wasm-bindgen and such.
@ -38,8 +42,7 @@ impl Cache {
.or_else(|| { .or_else(|| {
let home = dirs::home_dir()?; let home = dirs::home_dir()?;
Some(home.join(".wasm-pack")) Some(home.join(".wasm-pack"))
}) }).ok_or_else(|| format_err!("couldn't find your home directory, is $HOME not set?"))?;
.ok_or_else(|| format_err!("couldn't find your home directory, is $HOME not set?"))?;
Ok(Cache::at(&destination)) Ok(Cache::at(&destination))
} }

@ -1,6 +1,5 @@
//! Functionality related to installing and running `wasm-bindgen`. //! Functionality related to installing and running `wasm-bindgen`.
use binaries::{Cache, Download};
use child; use child;
use command::build::BuildProfile; use command::build::BuildProfile;
use emoji; use emoji;
@ -12,6 +11,7 @@ use std::fs;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::process::Command; use std::process::Command;
use target; use target;
use wasm_pack_binary_install::{Cache, Download};
use which::which; use which::which;
use PBAR; use PBAR;

@ -1,6 +1,5 @@
//! Implementation of the `wasm-pack build` command. //! Implementation of the `wasm-pack build` command.
use binaries::{Cache, Download};
use bindgen; use bindgen;
use build; use build;
use command::utils::{create_pkg_dir, set_crate_path}; use command::utils::{create_pkg_dir, set_crate_path};
@ -16,6 +15,7 @@ use slog::Logger;
use std::path::PathBuf; use std::path::PathBuf;
use std::str::FromStr; use std::str::FromStr;
use std::time::Instant; use std::time::Instant;
use wasm_pack_binary_install::{Cache, Download};
use PBAR; use PBAR;
/// Everything required to configure and run the `wasm-pack init` command. /// Everything required to configure and run the `wasm-pack init` command.

@ -1,7 +1,6 @@
//! Implementation of the `wasm-pack test` command. //! Implementation of the `wasm-pack test` command.
use super::build::BuildMode; use super::build::BuildMode;
use binaries::Cache;
use bindgen; use bindgen;
use build; use build;
use command::utils::set_crate_path; use command::utils::set_crate_path;
@ -16,6 +15,7 @@ use slog::Logger;
use std::path::PathBuf; use std::path::PathBuf;
use std::time::Instant; use std::time::Instant;
use test::{self, webdriver}; use test::{self, webdriver};
use wasm_pack_binary_install::Cache;
use PBAR; use PBAR;
#[derive(Debug, Default, StructOpt)] #[derive(Debug, Default, StructOpt)]

@ -4,16 +4,12 @@
extern crate cargo_metadata; extern crate cargo_metadata;
extern crate console; extern crate console;
extern crate curl;
extern crate dialoguer;
extern crate dirs;
extern crate strsim; extern crate strsim;
#[macro_use] #[macro_use]
extern crate failure; extern crate failure;
extern crate flate2;
extern crate glob; extern crate glob;
extern crate hex;
extern crate indicatif; extern crate indicatif;
extern crate which;
#[macro_use] #[macro_use]
extern crate lazy_static; extern crate lazy_static;
extern crate parking_lot; extern crate parking_lot;
@ -22,20 +18,17 @@ extern crate serde;
extern crate serde_derive; extern crate serde_derive;
extern crate serde_ignored; extern crate serde_ignored;
extern crate serde_json; extern crate serde_json;
extern crate siphasher;
#[macro_use] #[macro_use]
extern crate structopt; extern crate structopt;
#[macro_use] #[macro_use]
extern crate slog; extern crate slog;
extern crate dialoguer;
extern crate slog_async; extern crate slog_async;
extern crate slog_term; extern crate slog_term;
extern crate tar;
extern crate toml; extern crate toml;
extern crate walkdir; extern crate walkdir;
extern crate which; extern crate wasm_pack_binary_install;
extern crate zip;
pub mod binaries;
pub mod bindgen; pub mod bindgen;
pub mod build; pub mod build;
pub mod child; pub mod child;

@ -1,10 +1,10 @@
//! Getting WebDriver client binaries. //! Getting WebDriver client binaries.
use binaries::Cache;
use command::build::BuildMode; use command::build::BuildMode;
use failure; use failure;
use std::path::PathBuf; use std::path::PathBuf;
use target; use target;
use wasm_pack_binary_install::Cache;
/// Get the path to an existing `chromedriver`, or install it if no existing /// Get the path to an existing `chromedriver`, or install it if no existing
/// binary is found. /// binary is found.

@ -1,6 +1,6 @@
use tempfile; use tempfile;
use wasm_pack::binaries::Cache;
use wasm_pack::bindgen; use wasm_pack::bindgen;
use wasm_pack_binary_install::Cache;
#[test] #[test]
#[cfg(any( #[cfg(any(

@ -9,6 +9,7 @@ extern crate slog;
extern crate structopt; extern crate structopt;
extern crate tempfile; extern crate tempfile;
extern crate wasm_pack; extern crate wasm_pack;
extern crate wasm_pack_binary_install;
mod bindgen; mod bindgen;
mod build; mod build;

@ -8,7 +8,7 @@ use std::sync::{MutexGuard, Once, ONCE_INIT};
use std::thread; use std::thread;
use tempfile::TempDir; use tempfile::TempDir;
use wasm_pack; use wasm_pack;
use wasm_pack::binaries::Cache; use wasm_pack_binary_install::Cache;
/// A test fixture in a temporary directory. /// A test fixture in a temporary directory.
pub struct Fixture { pub struct Fixture {

@ -1,6 +1,6 @@
use utils::fixture; use utils::fixture;
use wasm_pack::binaries::Cache;
use wasm_pack::test::webdriver; use wasm_pack::test::webdriver;
use wasm_pack_binary_install::Cache;
#[test] #[test]
#[cfg(any( #[cfg(any(

Loading…
Cancel
Save