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

@@ -1,4 +1,5 @@
use crate::with_project;
use aiken_lang::ast::Tracing;
use std::path::PathBuf;
#[derive(clap::Args)]
@@ -8,19 +9,19 @@ pub struct Args {
/// Path to project
directory: Option<PathBuf>,
/// Name of the validator's module within the project. Optional if there's only one validator.
/// Name of the validator's module within the project. Optional if there's only one validator
#[clap(short, long)]
module: Option<String>,
/// Name of the validator within the module. Optional if there's only one validator.
/// Name of the validator within the module. Optional if there's only one validator
#[clap(short, long)]
validator: Option<String>,
/// Stake address to attach, if any.
/// Stake address to attach, if any
#[clap(long)]
delegated_to: Option<String>,
/// Force the project to be rebuilt, otherwise relies on existing artifacts (i.e. plutus.json).
/// Force the project to be rebuilt, otherwise relies on existing artifacts (i.e. plutus.json)
#[clap(long)]
rebuild: bool,
}
@@ -36,7 +37,7 @@ pub fn exec(
) -> miette::Result<()> {
with_project(directory, |p| {
if rebuild {
p.build(false)?;
p.build(false, Tracing::NoTraces)?;
}
let title = module.as_ref().map(|m| {

View File

@@ -9,8 +9,18 @@ pub struct Args {
/// Also dump textual uplc
#[clap(short, long)]
uplc: bool,
/// Do not remove traces when generating code
#[clap(short, long)]
keep_traces: bool,
}
pub fn exec(Args { directory, uplc }: Args) -> miette::Result<()> {
crate::with_project(directory, |p| p.build(uplc))
pub fn exec(
Args {
directory,
uplc,
keep_traces,
}: Args,
) -> miette::Result<()> {
crate::with_project(directory, |p| p.build(uplc, keep_traces.into()))
}

View File

@@ -24,6 +24,10 @@ pub struct Args {
/// It forces test names to match exactly
#[clap(short, long)]
exact_match: bool,
/// Remove traces when generating code (including tests)
#[clap(long)]
no_traces: bool,
}
pub fn exec(
@@ -33,9 +37,16 @@ pub fn exec(
debug,
match_tests,
exact_match,
no_traces,
}: Args,
) -> miette::Result<()> {
crate::with_project(directory, |p| {
p.check(skip_tests, match_tests.clone(), debug, exact_match)
p.check(
skip_tests,
match_tests.clone(),
debug,
exact_match,
(!no_traces).into(),
)
})
}