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:
parent
e9e3f4f50a
commit
45454ced01
|
@ -1023,6 +1023,16 @@ pub enum Tracing {
|
||||||
KeepTraces,
|
KeepTraces,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<bool> for Tracing {
|
||||||
|
fn from(keep: bool) -> Self {
|
||||||
|
if keep {
|
||||||
|
Tracing::KeepTraces
|
||||||
|
} else {
|
||||||
|
Tracing::NoTraces
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||||
pub struct Span {
|
pub struct Span {
|
||||||
pub start: usize,
|
pub start: usize,
|
||||||
|
|
|
@ -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 {
|
let options = Options {
|
||||||
code_gen_mode: CodeGenMode::Build(uplc),
|
code_gen_mode: CodeGenMode::Build(uplc),
|
||||||
|
tracing,
|
||||||
};
|
};
|
||||||
|
|
||||||
self.compile(options)
|
self.compile(options)
|
||||||
|
@ -130,7 +131,7 @@ where
|
||||||
|
|
||||||
let parsed_modules = self.parse_sources(self.config.name.clone())?;
|
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 {
|
self.event_listener.handle_event(Event::GeneratingDocFiles {
|
||||||
output_path: destination.clone(),
|
output_path: destination.clone(),
|
||||||
|
@ -157,8 +158,10 @@ where
|
||||||
match_tests: Option<Vec<String>>,
|
match_tests: Option<Vec<String>>,
|
||||||
verbose: bool,
|
verbose: bool,
|
||||||
exact_match: bool,
|
exact_match: bool,
|
||||||
|
tracing: Tracing,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let options = Options {
|
let options = Options {
|
||||||
|
tracing,
|
||||||
code_gen_mode: if skip_tests {
|
code_gen_mode: if skip_tests {
|
||||||
CodeGenMode::NoOp
|
CodeGenMode::NoOp
|
||||||
} else {
|
} else {
|
||||||
|
@ -209,7 +212,7 @@ where
|
||||||
|
|
||||||
let parsed_modules = self.parse_sources(self.config.name.clone())?;
|
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 {
|
match options.code_gen_mode {
|
||||||
CodeGenMode::Build(uplc_dump) => {
|
CodeGenMode::Build(uplc_dump) => {
|
||||||
|
@ -391,7 +394,7 @@ where
|
||||||
|
|
||||||
let parsed_modules = self.parse_sources(package.name)?;
|
let parsed_modules = self.parse_sources(package.name)?;
|
||||||
|
|
||||||
self.type_check(parsed_modules)?;
|
self.type_check(parsed_modules, Tracing::NoTraces)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
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()?;
|
let processing_sequence = parsed_modules.sequence()?;
|
||||||
|
|
||||||
for name in processing_sequence {
|
for name in processing_sequence {
|
||||||
|
@ -496,8 +503,7 @@ where
|
||||||
kind,
|
kind,
|
||||||
&self.config.name.to_string(),
|
&self.config.name.to_string(),
|
||||||
&self.module_types,
|
&self.module_types,
|
||||||
// TODO: Make configurable
|
tracing,
|
||||||
Tracing::KeepTraces,
|
|
||||||
&mut type_warnings,
|
&mut type_warnings,
|
||||||
)
|
)
|
||||||
.map_err(|error| Error::Type {
|
.map_err(|error| Error::Type {
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
|
use aiken_lang::ast::Tracing;
|
||||||
|
|
||||||
pub struct Options {
|
pub struct Options {
|
||||||
pub code_gen_mode: CodeGenMode,
|
pub code_gen_mode: CodeGenMode,
|
||||||
|
pub tracing: Tracing,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum CodeGenMode {
|
pub enum CodeGenMode {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::with_project;
|
use crate::with_project;
|
||||||
|
use aiken_lang::ast::Tracing;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
#[derive(clap::Args)]
|
#[derive(clap::Args)]
|
||||||
|
@ -8,19 +9,19 @@ pub struct Args {
|
||||||
/// Path to project
|
/// Path to project
|
||||||
directory: Option<PathBuf>,
|
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)]
|
#[clap(short, long)]
|
||||||
module: Option<String>,
|
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)]
|
#[clap(short, long)]
|
||||||
validator: Option<String>,
|
validator: Option<String>,
|
||||||
|
|
||||||
/// Stake address to attach, if any.
|
/// Stake address to attach, if any
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
delegated_to: Option<String>,
|
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)]
|
#[clap(long)]
|
||||||
rebuild: bool,
|
rebuild: bool,
|
||||||
}
|
}
|
||||||
|
@ -36,7 +37,7 @@ pub fn exec(
|
||||||
) -> miette::Result<()> {
|
) -> miette::Result<()> {
|
||||||
with_project(directory, |p| {
|
with_project(directory, |p| {
|
||||||
if rebuild {
|
if rebuild {
|
||||||
p.build(false)?;
|
p.build(false, Tracing::NoTraces)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let title = module.as_ref().map(|m| {
|
let title = module.as_ref().map(|m| {
|
||||||
|
|
|
@ -9,8 +9,18 @@ pub struct Args {
|
||||||
/// Also dump textual uplc
|
/// Also dump textual uplc
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
uplc: bool,
|
uplc: bool,
|
||||||
|
|
||||||
|
/// Do not remove traces when generating code
|
||||||
|
#[clap(short, long)]
|
||||||
|
keep_traces: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(Args { directory, uplc }: Args) -> miette::Result<()> {
|
pub fn exec(
|
||||||
crate::with_project(directory, |p| p.build(uplc))
|
Args {
|
||||||
|
directory,
|
||||||
|
uplc,
|
||||||
|
keep_traces,
|
||||||
|
}: Args,
|
||||||
|
) -> miette::Result<()> {
|
||||||
|
crate::with_project(directory, |p| p.build(uplc, keep_traces.into()))
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,10 @@ pub struct Args {
|
||||||
/// It forces test names to match exactly
|
/// It forces test names to match exactly
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
exact_match: bool,
|
exact_match: bool,
|
||||||
|
|
||||||
|
/// Remove traces when generating code (including tests)
|
||||||
|
#[clap(long)]
|
||||||
|
no_traces: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(
|
pub fn exec(
|
||||||
|
@ -33,9 +37,16 @@ pub fn exec(
|
||||||
debug,
|
debug,
|
||||||
match_tests,
|
match_tests,
|
||||||
exact_match,
|
exact_match,
|
||||||
|
no_traces,
|
||||||
}: Args,
|
}: Args,
|
||||||
) -> miette::Result<()> {
|
) -> miette::Result<()> {
|
||||||
crate::with_project(directory, |p| {
|
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(),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue