Move UPLC dump into separate function + log event.
``` Compiling aiken-lang/stdlib 43d8e740ffdf5febc59e51b7f0d5f8506115340c (examples/hello_world/build/packages/aiken-lang-stdlib) Compiling aiken-lang/hello_world 1.0.0 (examples/hello_world) Generating project's blueprint (examples/hello_world/plutus.json) Exporting UPLC (examples/hello_world/artifacts) ```
This commit is contained in:
parent
b667b7f7b7
commit
f8970ecb9e
|
@ -184,6 +184,20 @@ where
|
|||
self.compile(options)
|
||||
}
|
||||
|
||||
pub fn dump_uplc(&self, blueprint: &Blueprint) -> Result<(), Error> {
|
||||
let dir = self.root.join("artifacts");
|
||||
self.event_listener
|
||||
.handle_event(Event::DumpingUPLC { path: dir.clone() });
|
||||
fs::create_dir_all(&dir)?;
|
||||
for validator in &blueprint.validators {
|
||||
// TODO: Also include validator name.
|
||||
let path = dir.clone().join(format!("{}.uplc", validator.purpose));
|
||||
fs::write(&path, validator.program.to_pretty())
|
||||
.map_err(|error| Error::FileIo { error, path })?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn compile(&mut self, options: Options) -> Result<(), Error> {
|
||||
self.compile_deps()?;
|
||||
|
||||
|
@ -222,14 +236,7 @@ where
|
|||
}
|
||||
|
||||
if uplc_dump {
|
||||
let dir = self.root.join("artifacts");
|
||||
fs::create_dir_all(&dir)?;
|
||||
for validator in &blueprint.validators {
|
||||
// TODO: Also include validator name.
|
||||
let path = dir.clone().join(format!("{}.uplc", validator.purpose));
|
||||
fs::write(&path, validator.program.to_pretty())
|
||||
.map_err(|error| Error::FileIo { error, path })?;
|
||||
}
|
||||
self.dump_uplc(&blueprint)?;
|
||||
}
|
||||
|
||||
let json = serde_json::to_string_pretty(&blueprint).unwrap();
|
||||
|
|
|
@ -22,6 +22,9 @@ pub enum Event {
|
|||
GeneratingBlueprint {
|
||||
path: PathBuf,
|
||||
},
|
||||
DumpingUPLC {
|
||||
path: PathBuf,
|
||||
},
|
||||
GeneratingUPLCFor {
|
||||
name: String,
|
||||
path: PathBuf,
|
||||
|
|
|
@ -165,7 +165,7 @@ fn gitignore(root: &Path) -> miette::Result<()> {
|
|||
indoc! {
|
||||
r#"
|
||||
# Aiken compilation artifacts
|
||||
assets/
|
||||
artifacts/
|
||||
# Aiken's project working directory
|
||||
build/
|
||||
# Aiken's default documentation export
|
||||
|
|
|
@ -94,11 +94,19 @@ impl telemetry::EventListener for Terminal {
|
|||
telemetry::Event::WaitingForBuildDirLock => {
|
||||
println!("{}", "Waiting for build directory lock ...".bold().purple());
|
||||
}
|
||||
telemetry::Event::DumpingUPLC { path } => {
|
||||
println!(
|
||||
"{} {} ({})",
|
||||
" Exporting".bold().purple(),
|
||||
"UPLC".bold(),
|
||||
path.display().bright_blue()
|
||||
);
|
||||
}
|
||||
telemetry::Event::GeneratingBlueprint { path } => {
|
||||
println!(
|
||||
"{} {} ({})",
|
||||
" Generating".bold().purple(),
|
||||
"contract blueprint".bold(),
|
||||
"project's blueprint".bold(),
|
||||
path.display().bright_blue()
|
||||
);
|
||||
}
|
||||
|
@ -112,7 +120,7 @@ impl telemetry::EventListener for Terminal {
|
|||
telemetry::Event::GeneratingUPLCFor { name, path } => {
|
||||
println!(
|
||||
"{} {}.{{{}}}",
|
||||
" Generating Untyped Plutus Core for".bold().purple(),
|
||||
" Generating UPLC for".bold().purple(),
|
||||
path.to_str().unwrap_or("").blue(),
|
||||
name.bright_blue(),
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue