diff --git a/tooling/cli/src/lib.rs b/tooling/cli/src/lib.rs index 307485324..c64e61008 100644 --- a/tooling/cli/src/lib.rs +++ b/tooling/cli/src/lib.rs @@ -192,9 +192,9 @@ where Commands::Init(options) => init::command(options)?, Commands::Plugin(cli) => plugin::command(cli)?, Commands::Signer(cli) => signer::command(cli)?, - Commands::Android(cli) => mobile::android::command(cli)?, + Commands::Android(c) => mobile::android::command(c, cli.verbose)?, #[cfg(target_os = "macos")] - Commands::Ios(cli) => mobile::ios::command(cli)?, + Commands::Ios(c) => mobile::ios::command(c, cli.verbose)?, } Ok(()) diff --git a/tooling/cli/src/mobile/android.rs b/tooling/cli/src/mobile/android.rs index 2220cc0fd..0c10d8b9d 100644 --- a/tooling/cli/src/mobile/android.rs +++ b/tooling/cli/src/mobile/android.rs @@ -83,12 +83,13 @@ enum Commands { AndroidStudioScript(android_studio_script::Options), } -pub fn command(cli: Cli) -> Result<()> { +pub fn command(cli: Cli, verbosity: usize) -> Result<()> { + let noise_level = super::verbosity_to_noise_level(verbosity); match cli.command { Commands::Init(options) => init_command(options, MobileTarget::Android)?, Commands::Open => open::command()?, - Commands::Dev(options) => dev::command(options)?, - Commands::Build(options) => build::command(options)?, + Commands::Dev(options) => dev::command(options, noise_level)?, + Commands::Build(options) => build::command(options, noise_level)?, Commands::AndroidStudioScript(options) => android_studio_script::command(options)?, } diff --git a/tooling/cli/src/mobile/android/android_studio_script.rs b/tooling/cli/src/mobile/android/android_studio_script.rs index b4c2417c2..018ee1559 100644 --- a/tooling/cli/src/mobile/android/android_studio_script.rs +++ b/tooling/cli/src/mobile/android/android_studio_script.rs @@ -31,7 +31,7 @@ pub fn command(options: Options) -> Result<()> { } else { Profile::Debug }; - let noise_level = NoiseLevel::Polite; + let noise_level = NoiseLevel::FranklyQuitePedantic; with_config(None, |root_conf, config, metadata| { ensure_init(config.project_dir(), MobileTarget::Android) diff --git a/tooling/cli/src/mobile/android/build.rs b/tooling/cli/src/mobile/android/build.rs index 4872ba4e8..4388b98ca 100644 --- a/tooling/cli/src/mobile/android/build.rs +++ b/tooling/cli/src/mobile/android/build.rs @@ -67,7 +67,7 @@ impl From for crate::build::Options { } } -pub fn command(options: Options) -> Result<()> { +pub fn command(options: Options, noise_level: NoiseLevel) -> Result<()> { delete_codegen_vars(); with_config(Some(Default::default()), |root_conf, config, _metadata| { set_var("WRY_RUSTWEBVIEWCLIENT_CLASS_EXTENSION", ""); @@ -80,7 +80,8 @@ pub fn command(options: Options) -> Result<()> { init_dot_cargo(root_conf, Some(&env)).map_err(Error::InitDotCargo)?; let open = options.open; - run_build(options, config, env).map_err(|e| Error::BuildFailed(format!("{:#}", e)))?; + run_build(options, config, env, noise_level) + .map_err(|e| Error::BuildFailed(format!("{:#}", e)))?; if open { open_and_wait(config); @@ -91,13 +92,17 @@ pub fn command(options: Options) -> Result<()> { .map_err(Into::into) } -fn run_build(mut options: Options, config: &AndroidConfig, env: Env) -> Result<()> { +fn run_build( + mut options: Options, + config: &AndroidConfig, + env: Env, + noise_level: NoiseLevel, +) -> Result<()> { let profile = if options.debug { Profile::Debug } else { Profile::Release }; - let noise_level = NoiseLevel::Polite; if !(options.apk || options.aab) { // if the user didn't specify the format to build, we'll do both diff --git a/tooling/cli/src/mobile/android/dev.rs b/tooling/cli/src/mobile/android/dev.rs index cba5f7c8f..6fa94000c 100644 --- a/tooling/cli/src/mobile/android/dev.rs +++ b/tooling/cli/src/mobile/android/dev.rs @@ -62,7 +62,7 @@ impl From for crate::dev::Options { } } -pub fn command(options: Options) -> Result<()> { +pub fn command(options: Options, noise_level: NoiseLevel) -> Result<()> { delete_codegen_vars(); with_config(Some(Default::default()), |root_conf, config, metadata| { set_var( @@ -72,7 +72,8 @@ pub fn command(options: Options) -> Result<()> { set_var("WRY_RUSTWEBVIEW_CLASS_INIT", WEBVIEW_CLASS_INIT); ensure_init(config.project_dir(), MobileTarget::Android) .map_err(|e| Error::ProjectNotInitialized(e.to_string()))?; - run_dev(options, root_conf, config, metadata).map_err(|e| Error::DevFailed(format!("{:#}", e))) + run_dev(options, root_conf, config, metadata, noise_level) + .map_err(|e| Error::DevFailed(format!("{:#}", e))) }) .map_err(Into::into) } @@ -82,6 +83,7 @@ fn run_dev( root_conf: &Config, config: &AndroidConfig, metadata: &AndroidMetadata, + noise_level: NoiseLevel, ) -> Result<()> { let mut dev_options = options.clone().into(); let mut interface = crate::dev::setup(&mut dev_options)?; @@ -121,7 +123,7 @@ fn run_dev( if open { open_and_wait(config) } else { - match run(options, root_conf, config, metadata) { + match run(options, root_conf, config, metadata, noise_level) { Ok(c) => Ok(Box::new(c) as Box), Err(Error::FailedToPromptForDevice(e)) => { log::error!("{}", e); @@ -139,13 +141,13 @@ fn run( root_conf: &Config, config: &AndroidConfig, metadata: &AndroidMetadata, + noise_level: NoiseLevel, ) -> Result { let profile = if options.debug { Profile::Debug } else { Profile::Release }; - let noise_level = NoiseLevel::Polite; let build_app_bundle = metadata.asset_packs().is_some(); diff --git a/tooling/cli/src/mobile/ios.rs b/tooling/cli/src/mobile/ios.rs index 8b067c40b..f98b3ea38 100644 --- a/tooling/cli/src/mobile/ios.rs +++ b/tooling/cli/src/mobile/ios.rs @@ -91,12 +91,13 @@ enum Commands { XcodeScript(xcode_script::Options), } -pub fn command(cli: Cli) -> Result<()> { +pub fn command(cli: Cli, verbosity: usize) -> Result<()> { + let noise_level = super::verbosity_to_noise_level(verbosity); match cli.command { Commands::Init(options) => init_command(options, MobileTarget::Ios)?, Commands::Open => open::command()?, - Commands::Dev(options) => dev::command(options)?, - Commands::Build(options) => build::command(options)?, + Commands::Dev(options) => dev::command(options, noise_level)?, + Commands::Build(options) => build::command(options, noise_level)?, Commands::XcodeScript(options) => xcode_script::command(options)?, } diff --git a/tooling/cli/src/mobile/ios/build.rs b/tooling/cli/src/mobile/ios/build.rs index c00aaea01..556714430 100644 --- a/tooling/cli/src/mobile/ios/build.rs +++ b/tooling/cli/src/mobile/ios/build.rs @@ -63,7 +63,7 @@ impl From for crate::build::Options { } } -pub fn command(options: Options) -> Result<()> { +pub fn command(options: Options, noise_level: NoiseLevel) -> Result<()> { with_config(Some(Default::default()), |root_conf, config, _metadata| { ensure_init(config.project_dir(), MobileTarget::Ios) .map_err(|e| Error::ProjectNotInitialized(e.to_string()))?; @@ -72,7 +72,8 @@ pub fn command(options: Options) -> Result<()> { init_dot_cargo(root_conf, None).map_err(Error::InitDotCargo)?; let open = options.open; - run_build(options, config, env).map_err(|e| Error::BuildFailed(format!("{:#}", e)))?; + run_build(options, config, env, noise_level) + .map_err(|e| Error::BuildFailed(format!("{:#}", e)))?; if open { open_and_wait(config); @@ -83,13 +84,17 @@ pub fn command(options: Options) -> Result<()> { .map_err(Into::into) } -fn run_build(mut options: Options, config: &AppleConfig, env: Env) -> Result<()> { +fn run_build( + mut options: Options, + config: &AppleConfig, + env: Env, + noise_level: NoiseLevel, +) -> Result<()> { let profile = if options.debug { Profile::Debug } else { Profile::Release }; - let noise_level = NoiseLevel::Polite; let bundle_identifier = { let tauri_config = get_tauri_config(None)?; diff --git a/tooling/cli/src/mobile/ios/dev.rs b/tooling/cli/src/mobile/ios/dev.rs index 5daa148b7..4cbb8b30a 100644 --- a/tooling/cli/src/mobile/ios/dev.rs +++ b/tooling/cli/src/mobile/ios/dev.rs @@ -53,16 +53,22 @@ impl From for crate::dev::Options { } } -pub fn command(options: Options) -> Result<()> { +pub fn command(options: Options, noise_level: NoiseLevel) -> Result<()> { with_config(Some(Default::default()), |root_conf, config, _metadata| { ensure_init(config.project_dir(), MobileTarget::Ios) .map_err(|e| Error::ProjectNotInitialized(e.to_string()))?; - run_dev(options, root_conf, config).map_err(|e| Error::DevFailed(format!("{:#}", e))) + run_dev(options, root_conf, config, noise_level) + .map_err(|e| Error::DevFailed(format!("{:#}", e))) }) .map_err(Into::into) } -fn run_dev(options: Options, root_conf: &Config, config: &AppleConfig) -> Result<()> { +fn run_dev( + options: Options, + root_conf: &Config, + config: &AppleConfig, + noise_level: NoiseLevel, +) -> Result<()> { let mut dev_options = options.clone().into(); let mut interface = crate::dev::setup(&mut dev_options)?; @@ -101,7 +107,7 @@ fn run_dev(options: Options, root_conf: &Config, config: &AppleConfig) -> Result if open { open_and_wait(config) } else { - match run(options, root_conf, config) { + match run(options, root_conf, config, noise_level) { Ok(c) => Ok(Box::new(c) as Box), Err(Error::FailedToPromptForDevice(e)) => { log::error!("{}", e); @@ -118,13 +124,13 @@ fn run( options: MobileOptions, root_conf: &Config, config: &AppleConfig, + noise_level: NoiseLevel, ) -> Result { let profile = if options.debug { Profile::Debug } else { Profile::Release }; - let noise_level = NoiseLevel::Polite; let env = env()?; init_dot_cargo(root_conf, None).map_err(Error::InitDotCargo)?; diff --git a/tooling/cli/src/mobile/ios/xcode_script.rs b/tooling/cli/src/mobile/ios/xcode_script.rs index b2421a0ec..90576b152 100644 --- a/tooling/cli/src/mobile/ios/xcode_script.rs +++ b/tooling/cli/src/mobile/ios/xcode_script.rs @@ -44,7 +44,7 @@ pub fn command(options: Options) -> Result<()> { let profile = profile_from_configuration(&options.configuration); let macos = macos_from_platform(&options.platform); - let noise_level = NoiseLevel::Polite; + let noise_level = NoiseLevel::FranklyQuitePedantic; with_config(None, |root_conf, config, metadata| { let env = env()?; diff --git a/tooling/cli/src/mobile/mod.rs b/tooling/cli/src/mobile/mod.rs index bf1558a7d..8ff69d19d 100644 --- a/tooling/cli/src/mobile/mod.rs +++ b/tooling/cli/src/mobile/mod.rs @@ -16,6 +16,7 @@ use cargo_mobile::{ bossy, config::{app::Raw as RawAppConfig, metadata::Metadata, Config, Raw}, env::Error as EnvError, + opts::NoiseLevel, }; use interprocess::local_socket::{LocalSocketListener, LocalSocketStream}; use serde::{Deserialize, Serialize}; @@ -346,3 +347,12 @@ fn log_finished(outputs: Vec, kind: &str) { log::info!(action = "Finished"; "{} {}{} at:\n{}", outputs.len(), kind, if outputs.len() == 1 { "" } else { "s" }, printable_paths); } } + +fn verbosity_to_noise_level(verbosity: usize) -> NoiseLevel { + match verbosity { + 0 => NoiseLevel::Polite, + 1 => NoiseLevel::LoudAndProud, + 2.. => NoiseLevel::FranklyQuitePedantic, + _ => panic!(), + } +}