Skip to content

Commit

Permalink
Merge pull request #367 from rustwasm/i-hope-u-know-what-ur-doing
Browse files Browse the repository at this point in the history
feat(buildmode): allow --mode force to skip rustc check
  • Loading branch information
ashleygwilliams authored Sep 25, 2018
2 parents d5d3358 + 66ffe1d commit 6ed5b00
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/command/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ pub enum BuildMode {
/// Don't install tools like `wasm-bindgen`, just use the global
/// environment's existing versions to do builds.
Noinstall,
/// Skip the rustc version check
Force,
}

impl Default for BuildMode {
Expand All @@ -52,6 +54,7 @@ impl FromStr for BuildMode {
match s {
"no-install" => Ok(BuildMode::Noinstall),
"normal" => Ok(BuildMode::Normal),
"force" => Ok(BuildMode::Force),
_ => Error::crate_config(&format!("Unknown build mode: {}", s)).map(|_| unreachable!()),
}
}
Expand Down Expand Up @@ -175,6 +178,13 @@ impl Build {
step_copy_readme,
step_run_wasm_bindgen
],
BuildMode::Force => steps![
step_build_wasm,
step_create_dir,
step_create_json,
step_copy_readme,
step_run_wasm_bindgen
],
}
}

Expand Down Expand Up @@ -255,6 +265,7 @@ impl Build {
info!(&log, "Installing wasm-bindgen-cli...");
let install_permitted = match self.mode {
BuildMode::Normal => true,
BuildMode::Force => true,
BuildMode::Noinstall => false,
};
bindgen::install_wasm_bindgen(
Expand Down
24 changes: 24 additions & 0 deletions src/command/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ impl Test {
}
match self.mode {
BuildMode::Normal => steps![
step_check_rustc_version,
step_check_crate_config,
step_add_wasm_target,
step_build_tests,
Expand All @@ -197,6 +198,18 @@ impl Test {
step_get_safaridriver if self.safari && self.safaridriver.is_none(),
step_test_safari if self.safari,
],
BuildMode::Force => steps![
step_add_wasm_target,
step_build_tests,
step_install_wasm_bindgen,
step_test_node if self.node,
step_get_chromedriver if self.chrome && self.chromedriver.is_none(),
step_test_chrome if self.chrome,
step_get_geckodriver if self.firefox && self.geckodriver.is_none(),
step_test_firefox if self.firefox,
step_get_safaridriver if self.safari && self.safaridriver.is_none(),
step_test_safari if self.safari,
],
BuildMode::Noinstall => steps![
step_check_crate_config,
step_build_tests,
Expand All @@ -212,6 +225,13 @@ impl Test {
}
}

fn step_check_rustc_version(&mut self, step: &Step, log: &Logger) -> Result<(), Error> {
info!(log, "Checking rustc version...");
let _ = build::check_rustc_version(step)?;
info!(log, "Rustc version is correct.");
Ok(())
}

fn step_check_crate_config(&mut self, step: &Step, log: &Logger) -> Result<(), Error> {
info!(log, "Checking crate configuration...");
manifest::check_crate_config(&self.crate_path, step)?;
Expand Down Expand Up @@ -263,6 +283,10 @@ impl Test {
info!(&log, "Ensuring wasm-bindgen-cli is installed...");
true
}
BuildMode::Force => {
info!(&log, "Ensuring wasm-bindgen-cli is installed...");
true
}
BuildMode::Noinstall => {
info!(&log, "Searching for existing wasm-bindgen-cli install...");
false
Expand Down
2 changes: 2 additions & 0 deletions src/test/webdriver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub fn get_or_install_chromedriver(
match (mode, bin_path(log, crate_path, "chromedriver")) {
(_, Some(path)) => Ok(path),
(BuildMode::Normal, None) => install_chromedriver(crate_path),
(BuildMode::Force, None) => install_chromedriver(crate_path),
(BuildMode::Noinstall, None) => Error::crate_config(
"No crate-local `chromedriver` binary found, and could not find a global \
`chromedriver` on the `$PATH`. Not installing `chromedriver` because of noinstall \
Expand Down Expand Up @@ -69,6 +70,7 @@ pub fn get_or_install_geckodriver(
match (mode, bin_path(log, crate_path, "geckodriver")) {
(_, Some(path)) => Ok(path),
(BuildMode::Normal, None) => install_geckodriver(crate_path),
(BuildMode::Force, None) => install_geckodriver(crate_path),
(BuildMode::Noinstall, None) => Error::crate_config(
"No crate-local `geckodriver` binary found, and could not find a global `geckodriver` \
on the `$PATH`. Not installing `geckodriver` because of noinstall mode.",
Expand Down

0 comments on commit 6ed5b00

Please sign in to comment.