Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate output towards the 1.0 strategy #547

Merged
merged 10 commits into from
Mar 15, 2019
71 changes: 18 additions & 53 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ env_logger = { version = "0.5.13", default-features = false }
failure = "0.1.2"
human-panic = "1.0.1"
glob = "0.2"
indicatif = "0.9.0"
lazy_static = "1.1.0"
log = "0.4.6"
openssl = { version = '0.10.11', optional = true }
parking_lot = "0.6"
Expand All @@ -39,6 +37,7 @@ walkdir = "2"

[dev-dependencies]
assert_cmd = "0.10.2"
lazy_static = "1.1.0"
predicates = "1.0.0"
tempfile = "3"

Expand Down
10 changes: 2 additions & 8 deletions src/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use failure::{self, ResultExt};
use log::debug;
use log::{info, warn};
use manifest::CrateData;
use progressbar::Step;
use std::env;
use std::fs;
use std::path::{Path, PathBuf};
Expand All @@ -27,7 +26,6 @@ pub fn install_wasm_bindgen(
cache: &Cache,
version: &str,
install_permitted: bool,
step: &Step,
) -> Result<Download, failure::Error> {
// If `wasm-bindgen` is installed globally and it has the right version, use
// that. Assume that other tools are installed next to it.
Expand All @@ -42,7 +40,7 @@ pub fn install_wasm_bindgen(
}

let msg = format!("{}Installing wasm-bindgen...", emoji::DOWN_ARROW);
PBAR.step(step, &msg);
PBAR.info(&msg);

let dl = download_prebuilt_wasm_bindgen(&cache, version, install_permitted);
match dl {
Expand Down Expand Up @@ -178,11 +176,7 @@ pub fn wasm_bindgen_build(
disable_dts: bool,
target: &Target,
profile: BuildProfile,
step: &Step,
) -> Result<(), failure::Error> {
let msg = format!("{}Running wasm-bindgen...", emoji::RUNNER);
PBAR.step(step, &msg);

let release_or_debug = match profile {
BuildProfile::Release | BuildProfile::Profiling => "release",
BuildProfile::Dev => "debug",
Expand Down Expand Up @@ -235,7 +229,7 @@ pub fn wasm_bindgen_build(
fn wasm_bindgen_version_check(bindgen_path: &PathBuf, dep_version: &str) -> bool {
let mut cmd = Command::new(bindgen_path);
cmd.arg("--version");
child::run(cmd, "wasm-bindgen")
child::run_capture_stdout(cmd, "wasm-bindgen")
.map(|stdout| {
stdout
.trim()
Expand Down
27 changes: 18 additions & 9 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ use child;
use command::build::BuildProfile;
use emoji;
use failure::{Error, ResultExt};
use progressbar::Step;
use std::path::Path;
use std::process::Command;
use std::str;
use PBAR;

/// Ensure that `rustc` is present and that it is >= 1.30.0
pub fn check_rustc_version(step: &Step) -> Result<String, Error> {
let msg = format!("{}Checking `rustc` version...", emoji::CRAB);
PBAR.step(step, &msg);
pub fn check_rustc_version() -> Result<String, Error> {
let local_minor_version = rustc_minor_version();
match local_minor_version {
Some(mv) => {
Expand Down Expand Up @@ -51,9 +48,22 @@ fn rustc_minor_version() -> Option<u32> {

/// Ensure that `rustup` has the `wasm32-unknown-unknown` target installed for
/// current toolchain
pub fn rustup_add_wasm_target(step: &Step) -> Result<(), Error> {
let msg = format!("{}Adding the Wasm target...", emoji::TARGET);
PBAR.step(step, &msg);
pub fn rustup_add_wasm_target() -> Result<(), Error> {
let mut cmd = Command::new("rustc");
cmd.arg("--print").arg("sysroot");
let output =
child::run_capture_stdout(cmd, "rustc").context("Learning about rustc's sysroot")?;
let sysroot = Path::new(output.trim());

// If this exists then we for sure have a wasm32 target so there's no need
// to progress further.
if sysroot.join("lib/rustlib/wasm32-unknown-unknown").exists() {
return Ok(());
}

// ... otherwise fall back to rustup to add the target
let msg = format!("{}Adding Wasm target...", emoji::TARGET);
PBAR.info(&msg);
let mut cmd = Command::new("rustup");
cmd.arg("target").arg("add").arg("wasm32-unknown-unknown");
child::run(cmd, "rustup").context("Adding the wasm32-unknown-unknown target with rustup")?;
Expand All @@ -64,11 +74,10 @@ pub fn rustup_add_wasm_target(step: &Step) -> Result<(), Error> {
pub fn cargo_build_wasm(
path: &Path,
profile: BuildProfile,
step: &Step,
extra_options: &Vec<String>,
) -> Result<(), Error> {
let msg = format!("{}Compiling to Wasm...", emoji::CYCLONE);
PBAR.step(step, &msg);
PBAR.info(&msg);
let mut cmd = Command::new("cargo");
cmd.current_dir(path).arg("build").arg("--lib");
match profile {
Expand Down
Loading