Make tracing configurable, when relevant.

Tracing is now turn OFF by default when:

  - building project
  - building documentation
  - building dependencies

  It can be turned ON only when building project using `--keep-traces`.
  That means it's not possible to build dependencies with traces. The
  address `--rebuild` flag will also rebuild without traces.

  Tracing is however turn ON by default when:

  - checking the project (and running tests).

  In this scenario, tracing can be disabled using `--no-traces` (if for
  example, one want to analyze the execution units of specific functions
  without having to manually remove traces from code).
This commit is contained in:
KtorZ
2023-02-16 14:33:19 +01:00
committed by Lucas
parent e9e3f4f50a
commit 45454ced01
6 changed files with 56 additions and 15 deletions

View File

@@ -106,9 +106,10 @@ where
})
}
pub fn build(&mut self, uplc: bool) -> Result<(), Error> {
pub fn build(&mut self, uplc: bool, tracing: Tracing) -> Result<(), Error> {
let options = Options {
code_gen_mode: CodeGenMode::Build(uplc),
tracing,
};
self.compile(options)
@@ -130,7 +131,7 @@ where
let parsed_modules = self.parse_sources(self.config.name.clone())?;
self.type_check(parsed_modules)?;
self.type_check(parsed_modules, Tracing::NoTraces)?;
self.event_listener.handle_event(Event::GeneratingDocFiles {
output_path: destination.clone(),
@@ -157,8 +158,10 @@ where
match_tests: Option<Vec<String>>,
verbose: bool,
exact_match: bool,
tracing: Tracing,
) -> Result<(), Error> {
let options = Options {
tracing,
code_gen_mode: if skip_tests {
CodeGenMode::NoOp
} else {
@@ -209,7 +212,7 @@ where
let parsed_modules = self.parse_sources(self.config.name.clone())?;
self.type_check(parsed_modules)?;
self.type_check(parsed_modules, options.tracing)?;
match options.code_gen_mode {
CodeGenMode::Build(uplc_dump) => {
@@ -391,7 +394,7 @@ where
let parsed_modules = self.parse_sources(package.name)?;
self.type_check(parsed_modules)?;
self.type_check(parsed_modules, Tracing::NoTraces)?;
}
Ok(())
@@ -474,7 +477,11 @@ where
}
}
fn type_check(&mut self, mut parsed_modules: ParsedModules) -> Result<(), Error> {
fn type_check(
&mut self,
mut parsed_modules: ParsedModules,
tracing: Tracing,
) -> Result<(), Error> {
let processing_sequence = parsed_modules.sequence()?;
for name in processing_sequence {
@@ -496,8 +503,7 @@ where
kind,
&self.config.name.to_string(),
&self.module_types,
// TODO: Make configurable
Tracing::KeepTraces,
tracing,
&mut type_warnings,
)
.map_err(|error| Error::Type {

View File

@@ -1,5 +1,8 @@
use aiken_lang::ast::Tracing;
pub struct Options {
pub code_gen_mode: CodeGenMode,
pub tracing: Tracing,
}
pub enum CodeGenMode {