From bb4447cb5272e937f26123abb903e26183dbb21a Mon Sep 17 00:00:00 2001 From: Lukasz Rubaszewski <117115317+lrubasze@users.noreply.github.com> Date: Thu, 19 Dec 2024 14:14:09 +0100 Subject: [PATCH] Add FastWithNoLogs compiler profile --- scrypto-compiler/src/lib.rs | 9 +++++++-- scrypto-test/src/ledger_simulator/compile.rs | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/scrypto-compiler/src/lib.rs b/scrypto-compiler/src/lib.rs index be488684a10..054a6ad8c3f 100644 --- a/scrypto-compiler/src/lib.rs +++ b/scrypto-compiler/src/lib.rs @@ -1326,12 +1326,17 @@ impl ScryptoCompilerBuilder { self } - pub fn log_level(&mut self, log_level: Level) -> &mut Self { - // Firstly clear any log level previously set + pub fn disable_logs(&mut self) -> &mut Self { let all_features = ScryptoCompilerInputParams::log_level_to_scrypto_features(Level::Trace); all_features.iter().for_each(|log_level| { self.input_params.features.swap_remove(log_level); }); + self + } + + pub fn log_level(&mut self, log_level: Level) -> &mut Self { + // Firstly clear any log level previously set + self.disable_logs(); // Now set log level provided by the user if Level::Error <= log_level { diff --git a/scrypto-test/src/ledger_simulator/compile.rs b/scrypto-test/src/ledger_simulator/compile.rs index af064d5338b..d3d29ef5825 100644 --- a/scrypto-test/src/ledger_simulator/compile.rs +++ b/scrypto-test/src/ledger_simulator/compile.rs @@ -12,6 +12,8 @@ pub enum CompileProfile { Fast, /// Disables WASM optimization and enables all logs from error to trace level, by default used by Ledger Simulator. FastWithTraceLogs, + /// Disables WASM optimization and disables all logs. + FastWithNoLogs, } pub struct Compile; @@ -55,6 +57,10 @@ impl Compile { compiler_builder.optimize_with_wasm_opt(None); compiler_builder.log_level(Level::Trace); // all logs from error to trace } + CompileProfile::FastWithNoLogs => { + compiler_builder.optimize_with_wasm_opt(None); + compiler_builder.disable_logs(); + } } env_vars.iter().for_each(|(name, value)| {