Merge pull request #367 from rustwasm/i-hope-u-know-what-ur-doing

feat(buildmode): allow --mode force to skip rustc check
master
ashley williams 7 years ago committed by GitHub
commit 6ed5b00f5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      src/command/build.rs
  2. 24
      src/command/test.rs
  3. 2
      src/test/webdriver.rs

@ -38,6 +38,8 @@ pub enum BuildMode {
/// Don't install tools like `wasm-bindgen`, just use the global /// Don't install tools like `wasm-bindgen`, just use the global
/// environment's existing versions to do builds. /// environment's existing versions to do builds.
Noinstall, Noinstall,
/// Skip the rustc version check
Force,
} }
impl Default for BuildMode { impl Default for BuildMode {
@ -52,6 +54,7 @@ impl FromStr for BuildMode {
match s { match s {
"no-install" => Ok(BuildMode::Noinstall), "no-install" => Ok(BuildMode::Noinstall),
"normal" => Ok(BuildMode::Normal), "normal" => Ok(BuildMode::Normal),
"force" => Ok(BuildMode::Force),
_ => Error::crate_config(&format!("Unknown build mode: {}", s)).map(|_| unreachable!()), _ => Error::crate_config(&format!("Unknown build mode: {}", s)).map(|_| unreachable!()),
} }
} }
@ -175,6 +178,13 @@ impl Build {
step_copy_readme, step_copy_readme,
step_run_wasm_bindgen step_run_wasm_bindgen
], ],
BuildMode::Force => steps![
step_build_wasm,
step_create_dir,
step_create_json,
step_copy_readme,
step_run_wasm_bindgen
],
} }
} }
@ -255,6 +265,7 @@ impl Build {
info!(&log, "Installing wasm-bindgen-cli..."); info!(&log, "Installing wasm-bindgen-cli...");
let install_permitted = match self.mode { let install_permitted = match self.mode {
BuildMode::Normal => true, BuildMode::Normal => true,
BuildMode::Force => true,
BuildMode::Noinstall => false, BuildMode::Noinstall => false,
}; };
bindgen::install_wasm_bindgen( bindgen::install_wasm_bindgen(

@ -185,6 +185,7 @@ impl Test {
} }
match self.mode { match self.mode {
BuildMode::Normal => steps![ BuildMode::Normal => steps![
step_check_rustc_version,
step_check_crate_config, step_check_crate_config,
step_add_wasm_target, step_add_wasm_target,
step_build_tests, step_build_tests,
@ -197,6 +198,18 @@ impl Test {
step_get_safaridriver if self.safari && self.safaridriver.is_none(), step_get_safaridriver if self.safari && self.safaridriver.is_none(),
step_test_safari if self.safari, 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![ BuildMode::Noinstall => steps![
step_check_crate_config, step_check_crate_config,
step_build_tests, step_build_tests,
@ -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> { fn step_check_crate_config(&mut self, step: &Step, log: &Logger) -> Result<(), Error> {
info!(log, "Checking crate configuration..."); info!(log, "Checking crate configuration...");
manifest::check_crate_config(&self.crate_path, step)?; manifest::check_crate_config(&self.crate_path, step)?;
@ -263,6 +283,10 @@ impl Test {
info!(&log, "Ensuring wasm-bindgen-cli is installed..."); info!(&log, "Ensuring wasm-bindgen-cli is installed...");
true true
} }
BuildMode::Force => {
info!(&log, "Ensuring wasm-bindgen-cli is installed...");
true
}
BuildMode::Noinstall => { BuildMode::Noinstall => {
info!(&log, "Searching for existing wasm-bindgen-cli install..."); info!(&log, "Searching for existing wasm-bindgen-cli install...");
false false

@ -19,6 +19,7 @@ pub fn get_or_install_chromedriver(
match (mode, bin_path(log, crate_path, "chromedriver")) { match (mode, bin_path(log, crate_path, "chromedriver")) {
(_, Some(path)) => Ok(path), (_, Some(path)) => Ok(path),
(BuildMode::Normal, None) => install_chromedriver(crate_path), (BuildMode::Normal, None) => install_chromedriver(crate_path),
(BuildMode::Force, None) => install_chromedriver(crate_path),
(BuildMode::Noinstall, None) => Error::crate_config( (BuildMode::Noinstall, None) => Error::crate_config(
"No crate-local `chromedriver` binary found, and could not find a global \ "No crate-local `chromedriver` binary found, and could not find a global \
`chromedriver` on the `$PATH`. Not installing `chromedriver` because of noinstall \ `chromedriver` on the `$PATH`. Not installing `chromedriver` because of noinstall \
@ -69,6 +70,7 @@ pub fn get_or_install_geckodriver(
match (mode, bin_path(log, crate_path, "geckodriver")) { match (mode, bin_path(log, crate_path, "geckodriver")) {
(_, Some(path)) => Ok(path), (_, Some(path)) => Ok(path),
(BuildMode::Normal, None) => install_geckodriver(crate_path), (BuildMode::Normal, None) => install_geckodriver(crate_path),
(BuildMode::Force, None) => install_geckodriver(crate_path),
(BuildMode::Noinstall, None) => Error::crate_config( (BuildMode::Noinstall, None) => Error::crate_config(
"No crate-local `geckodriver` binary found, and could not find a global `geckodriver` \ "No crate-local `geckodriver` binary found, and could not find a global `geckodriver` \
on the `$PATH`. Not installing `geckodriver` because of noinstall mode.", on the `$PATH`. Not installing `geckodriver` because of noinstall mode.",

Loading…
Cancel
Save