mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 00:01:16 +00:00
Revamp notes printed after compilation finishes.
This commit is contained in:
parent
62484d3890
commit
4d11e7cbe6
3 changed files with 142 additions and 14 deletions
|
@ -306,7 +306,7 @@ fn spawn_rebuild_thread(
|
||||||
let thread_local_target = target.clone();
|
let thread_local_target = target.clone();
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
if !precompiled {
|
if !precompiled {
|
||||||
print!("🔨 Rebuilding host... ");
|
println!("🔨 Rebuilding host...");
|
||||||
}
|
}
|
||||||
|
|
||||||
let rebuild_host_start = SystemTime::now();
|
let rebuild_host_start = SystemTime::now();
|
||||||
|
@ -348,7 +348,7 @@ pub fn check_file(
|
||||||
src_dir: PathBuf,
|
src_dir: PathBuf,
|
||||||
roc_file_path: PathBuf,
|
roc_file_path: PathBuf,
|
||||||
emit_timings: bool,
|
emit_timings: bool,
|
||||||
) -> Result<program::Problems, LoadingProblem> {
|
) -> Result<(program::Problems, Duration), LoadingProblem> {
|
||||||
let compilation_start = SystemTime::now();
|
let compilation_start = SystemTime::now();
|
||||||
|
|
||||||
// only used for generating errors. We don't do code generation, so hardcoding should be fine
|
// only used for generating errors. We don't do code generation, so hardcoding should be fine
|
||||||
|
@ -421,5 +421,8 @@ pub fn check_file(
|
||||||
println!("Finished checking in {} ms\n", compilation_end.as_millis(),);
|
println!("Finished checking in {} ms\n", compilation_end.as_millis(),);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(program::report_problems_typechecked(&mut loaded))
|
Ok((
|
||||||
|
program::report_problems_typechecked(&mut loaded),
|
||||||
|
compilation_end,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
106
cli/src/lib.rs
106
cli/src/lib.rs
|
@ -405,23 +405,91 @@ pub fn build(matches: &ArgMatches, config: BuildConfig) -> io::Result<i32> {
|
||||||
std::mem::forget(arena);
|
std::mem::forget(arena);
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"🎉 Built {} in {} ms",
|
"\x1B[{}m{}\x1B[39m {} and \x1B[{}m{}\x1B[39m {} found in {} ms while sucessfully building:\n\n {}",
|
||||||
generated_filename.to_str().unwrap(),
|
if problems.errors == 0 {
|
||||||
total_time.as_millis()
|
32 // green
|
||||||
|
} else {
|
||||||
|
33 // yellow
|
||||||
|
},
|
||||||
|
problems.errors,
|
||||||
|
if problems.errors == 1 {
|
||||||
|
"error"
|
||||||
|
} else {
|
||||||
|
"errors"
|
||||||
|
},
|
||||||
|
if problems.warnings == 0 {
|
||||||
|
32 // green
|
||||||
|
} else {
|
||||||
|
33 // yellow
|
||||||
|
},
|
||||||
|
problems.warnings,
|
||||||
|
if problems.warnings == 1 {
|
||||||
|
"warning"
|
||||||
|
} else {
|
||||||
|
"warnings"
|
||||||
|
},
|
||||||
|
total_time.as_millis(),
|
||||||
|
generated_filename.to_str().unwrap()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Return a nonzero exit code if there were problems
|
// Return a nonzero exit code if there were problems
|
||||||
Ok(problems.exit_code())
|
Ok(problems.exit_code())
|
||||||
}
|
}
|
||||||
BuildAndRun { roc_file_arg_index } => roc_run(
|
BuildAndRun { roc_file_arg_index } => {
|
||||||
|
if problems.errors > 0 || problems.warnings > 0 {
|
||||||
|
println!(
|
||||||
|
"\x1B[{}m{}\x1B[39m {} and \x1B[{}m{}\x1B[39m {} found in {} ms.\n\nRunning program anyway…\n\n\x1B[36m{}\x1B[39m",
|
||||||
|
if problems.errors == 0 {
|
||||||
|
32 // green
|
||||||
|
} else {
|
||||||
|
33 // yellow
|
||||||
|
},
|
||||||
|
problems.errors,
|
||||||
|
if problems.errors == 1 {
|
||||||
|
"error"
|
||||||
|
} else {
|
||||||
|
"errors"
|
||||||
|
},
|
||||||
|
if problems.warnings == 0 {
|
||||||
|
32 // green
|
||||||
|
} else {
|
||||||
|
33 // yellow
|
||||||
|
},
|
||||||
|
problems.warnings,
|
||||||
|
if problems.warnings == 1 {
|
||||||
|
"warning"
|
||||||
|
} else {
|
||||||
|
"warnings"
|
||||||
|
},
|
||||||
|
total_time.as_millis(),
|
||||||
|
"─".repeat(80)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
roc_run(
|
||||||
&arena,
|
&arena,
|
||||||
&original_cwd,
|
&original_cwd,
|
||||||
triple,
|
triple,
|
||||||
roc_file_arg_index,
|
roc_file_arg_index,
|
||||||
&binary_path,
|
&binary_path,
|
||||||
),
|
)
|
||||||
|
}
|
||||||
BuildAndRunIfNoErrors { roc_file_arg_index } => {
|
BuildAndRunIfNoErrors { roc_file_arg_index } => {
|
||||||
if problems.errors == 0 {
|
if problems.errors == 0 {
|
||||||
|
if problems.warnings > 0 {
|
||||||
|
println!(
|
||||||
|
"\x1B[32m0\x1B[39m errors and \x1B[33m{}\x1B[39m {} found in {} ms.\n\nRunning program…\n\n\x1B[36m{}\x1B[39m",
|
||||||
|
problems.warnings,
|
||||||
|
if problems.warnings == 1 {
|
||||||
|
"warning"
|
||||||
|
} else {
|
||||||
|
"warnings"
|
||||||
|
},
|
||||||
|
total_time.as_millis(),
|
||||||
|
"─".repeat(80)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
roc_run(
|
roc_run(
|
||||||
&arena,
|
&arena,
|
||||||
&original_cwd,
|
&original_cwd,
|
||||||
|
@ -430,6 +498,34 @@ pub fn build(matches: &ArgMatches, config: BuildConfig) -> io::Result<i32> {
|
||||||
&binary_path,
|
&binary_path,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
println!(
|
||||||
|
"\x1B[{}m{}\x1B[39m {} and \x1B[{}m{}\x1B[39m {} found in {} ms.\n\nYou can run the program anyway with: \x1B[32mroc run {}\x1B[39m",
|
||||||
|
if problems.errors == 0 {
|
||||||
|
32 // green
|
||||||
|
} else {
|
||||||
|
33 // yellow
|
||||||
|
},
|
||||||
|
problems.errors,
|
||||||
|
if problems.errors == 1 {
|
||||||
|
"error"
|
||||||
|
} else {
|
||||||
|
"errors"
|
||||||
|
},
|
||||||
|
if problems.warnings == 0 {
|
||||||
|
32 // green
|
||||||
|
} else {
|
||||||
|
33 // yellow
|
||||||
|
},
|
||||||
|
problems.warnings,
|
||||||
|
if problems.warnings == 1 {
|
||||||
|
"warning"
|
||||||
|
} else {
|
||||||
|
"warnings"
|
||||||
|
},
|
||||||
|
total_time.as_millis(),
|
||||||
|
filename
|
||||||
|
);
|
||||||
|
|
||||||
Ok(problems.exit_code())
|
Ok(problems.exit_code())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,36 @@ fn main() -> io::Result<()> {
|
||||||
let src_dir = roc_file_path.parent().unwrap().to_owned();
|
let src_dir = roc_file_path.parent().unwrap().to_owned();
|
||||||
|
|
||||||
match check_file(&arena, src_dir, roc_file_path, emit_timings) {
|
match check_file(&arena, src_dir, roc_file_path, emit_timings) {
|
||||||
Ok(problems) => Ok(problems.exit_code()),
|
Ok((problems, total_time)) => {
|
||||||
|
println!(
|
||||||
|
"\x1B[{}m{}\x1B[39m {} and \x1B[{}m{}\x1B[39m {} found in {} ms.",
|
||||||
|
if problems.errors == 0 {
|
||||||
|
32 // green
|
||||||
|
} else {
|
||||||
|
33 // yellow
|
||||||
|
},
|
||||||
|
problems.errors,
|
||||||
|
if problems.errors == 1 {
|
||||||
|
"error"
|
||||||
|
} else {
|
||||||
|
"errors"
|
||||||
|
},
|
||||||
|
if problems.warnings == 0 {
|
||||||
|
32 // green
|
||||||
|
} else {
|
||||||
|
33 // yellow
|
||||||
|
},
|
||||||
|
problems.warnings,
|
||||||
|
if problems.warnings == 1 {
|
||||||
|
"warning"
|
||||||
|
} else {
|
||||||
|
"warnings"
|
||||||
|
},
|
||||||
|
total_time.as_millis(),
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(problems.exit_code())
|
||||||
|
}
|
||||||
|
|
||||||
Err(LoadingProblem::FormattedReport(report)) => {
|
Err(LoadingProblem::FormattedReport(report)) => {
|
||||||
print!("{}", report);
|
print!("{}", report);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue