diff --git a/build/build/src/project/wasm.rs b/build/build/src/project/wasm.rs index ed4d1552339f..b57b68963780 100644 --- a/build/build/src/project/wasm.rs +++ b/build/build/src/project/wasm.rs @@ -49,7 +49,17 @@ pub const WASM_ARTIFACT_NAME: &str = "gui_wasm"; pub const DEFAULT_TARGET_CRATE: &str = "app/gui"; -#[derive(Clone, Copy, Debug, Default, strum::Display, strum::EnumString, PartialEq, Eq)] +#[derive( + clap::ArgEnum, + Clone, + Copy, + Debug, + Default, + strum::Display, + strum::EnumString, + PartialEq, + Eq +)] #[strum(serialize_all = "kebab-case")] pub enum ProfilingLevel { #[default] @@ -59,7 +69,17 @@ pub enum ProfilingLevel { Debug, } -#[derive(Clone, Copy, Debug, Default, strum::Display, strum::EnumString, PartialEq, Eq)] +#[derive( + clap::ArgEnum, + Clone, + Copy, + Debug, + Default, + strum::Display, + strum::EnumString, + PartialEq, + Eq +)] #[strum(serialize_all = "kebab-case")] pub enum LogLevel { Error, @@ -129,8 +149,8 @@ pub struct BuildInput { pub extra_cargo_options: Vec, pub profile: Profile, pub profiling_level: Option, - pub log_level: Option, - pub uncollapsed_log_level: Option, + pub log_level: LogLevel, + pub uncollapsed_log_level: LogLevel, pub wasm_size_limit: Option, } @@ -234,11 +254,8 @@ impl IsTarget for Wasm { if let Some(profiling_level) = profiling_level { command.set_env(env::ENSO_MAX_PROFILING_LEVEL, &profiling_level)?; } - command.set_env(env::ENSO_MAX_LOG_LEVEL, &log_level.unwrap_or_default())?; - command.set_env( - env::ENSO_MAX_UNCOLLAPSED_LOG_LEVEL, - &uncollapsed_log_level.unwrap_or_default(), - )?; + command.set_env(env::ENSO_MAX_LOG_LEVEL, &log_level)?; + command.set_env(env::ENSO_MAX_UNCOLLAPSED_LOG_LEVEL, &uncollapsed_log_level)?; command.run_ok().await?; Self::finalize_wasm(wasm_opt_options, *skip_wasm_opt, *profile, &temp_dist).await?; @@ -343,11 +360,9 @@ impl IsWatchable for Wasm { if let Some(profiling_level) = profiling_level { watch_cmd.args(["--profiling-level", profiling_level.to_string().as_str()]); } - watch_cmd.args(["--log-level", log_level.unwrap_or_default().to_string().as_str()]); - watch_cmd.args([ - "--uncollapsed-log-level", - uncollapsed_log_level.unwrap_or_default().to_string().as_str(), - ]); + watch_cmd.args(["--wasm-log-level", log_level.to_string().as_str()]); + watch_cmd + .args(["--wasm-uncollapsed-log-level", uncollapsed_log_level.to_string().as_str()]); for wasm_opt_option in wasm_opt_options { watch_cmd.args(["--wasm-opt-option", &wasm_opt_option]); } diff --git a/build/cli/src/arg/wasm.rs b/build/cli/src/arg/wasm.rs index 88cb0530ee01..e73a3310dc85 100644 --- a/build/cli/src/arg/wasm.rs +++ b/build/cli/src/arg/wasm.rs @@ -7,7 +7,6 @@ use crate::source_args_hlp; use crate::BuildJob; use crate::IsWatchableSource; -use clap::ArgEnum; use clap::Args; use clap::Subcommand; use enso_build::project::wasm::test::Browser; @@ -19,7 +18,9 @@ use std::sync::OnceLock; // === Export === // ============== +pub use enso_build::project::wasm::LogLevel; pub use enso_build::project::wasm::Profile; +pub use enso_build::project::wasm::ProfilingLevel; @@ -37,48 +38,6 @@ pub fn initialize_default_wasm_size_limit(limit: byte_unit::Byte) -> Result { .map_err(|e| anyhow!("WASM size limit was already set to {e}.")) } -// Follows hierarchy defined in lib/rust/profiler/src/lib.rs -#[derive(ArgEnum, Clone, Copy, Debug, PartialEq, Eq)] -pub enum ProfilingLevel { - Objective, - Task, - Detail, - Debug, -} - -impl From for enso_build::project::wasm::ProfilingLevel { - fn from(profile: ProfilingLevel) -> Self { - match profile { - ProfilingLevel::Objective => Self::Objective, - ProfilingLevel::Task => Self::Task, - ProfilingLevel::Detail => Self::Detail, - ProfilingLevel::Debug => Self::Debug, - } - } -} - -// Follows hierarchy defined in lib/rust/logging/src/lib.rs -#[derive(ArgEnum, Clone, Copy, Debug, PartialEq, Eq)] -pub enum LogLevel { - Error, - Warn, - Info, - Debug, - Trace, -} - -impl From for enso_build::project::wasm::LogLevel { - fn from(level: LogLevel) -> Self { - match level { - LogLevel::Error => Self::Error, - LogLevel::Warn => Self::Warn, - LogLevel::Info => Self::Info, - LogLevel::Debug => Self::Debug, - LogLevel::Trace => Self::Trace, - } - } -} - #[derive(Args, Clone, Debug, PartialEq, Eq)] pub struct BuildInput { /// Which crate should be treated as a WASM entry point. Relative path from source root. @@ -106,13 +65,13 @@ pub struct BuildInput { #[clap(long, arg_enum, enso_env())] pub profiling_level: Option, - /// Compiles Enso with given log level. If not set, defaults to [`warn`]. - #[clap(long, arg_enum, enso_env())] - pub log_level: Option, + /// Compiles Enso with given log level. + #[clap(long, arg_enum, enso_env(), default_value_t)] + pub wasm_log_level: LogLevel, - /// Compiles Enso with given uncollapsed log level. If not set, defaults to [`warn`]. - #[clap(long, arg_enum, enso_env())] - pub uncollapsed_log_level: Option, + /// Compiles Enso with given uncollapsed log level. + #[clap(long, arg_enum, enso_env(), default_value_t)] + pub wasm_uncollapsed_log_level: LogLevel, /// Fail the build if compressed WASM exceeds the specified size. Supports format like /// "4.06MiB". Pass "0" to disable check. diff --git a/build/cli/src/lib.rs b/build/cli/src/lib.rs index 5ff98d1e3cdf..af13b8b39df9 100644 --- a/build/cli/src/lib.rs +++ b/build/cli/src/lib.rs @@ -620,8 +620,8 @@ impl Resolvable for Wasm { wasm_opt_option: wasm_opt_options, cargo_options, profiling_level, - log_level, - uncollapsed_log_level, + wasm_log_level, + wasm_uncollapsed_log_level, wasm_size_limit, skip_wasm_opt, } = from; @@ -631,9 +631,9 @@ impl Resolvable for Wasm { skip_wasm_opt, extra_cargo_options: cargo_options, profile: wasm_profile, - profiling_level: profiling_level.map(into), - log_level: log_level.map(into), - uncollapsed_log_level: uncollapsed_log_level.map(into), + profiling_level, + log_level: wasm_log_level, + uncollapsed_log_level: wasm_uncollapsed_log_level, wasm_size_limit: wasm_size_limit.filter(|size_limit| size_limit.get_bytes() > 0), }) }