hook max-threads up for roc check

This commit is contained in:
Folkert 2022-05-07 14:32:38 +02:00
parent 35bf66f650
commit abbe8ecd24
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
3 changed files with 16 additions and 4 deletions

View file

@ -350,6 +350,7 @@ pub fn check_file(
src_dir: PathBuf,
roc_file_path: PathBuf,
emit_timings: bool,
threading: Threading,
) -> Result<(program::Problems, Duration), LoadingProblem> {
let compilation_start = SystemTime::now();
@ -368,7 +369,7 @@ pub fn check_file(
target_info,
// TODO: expose this from CLI?
RenderTarget::ColorTerminal,
Threading::AllAvailable,
threading,
)?;
let buf = &mut String::with_capacity(1024);

View file

@ -62,8 +62,8 @@ pub fn build_app<'a>() -> Command<'a> {
let flag_max_threads = Arg::new(FLAG_MAX_THREADS)
.long(FLAG_MAX_THREADS)
.help("Limit the number of threads (and hence cores) used during compilation.")
.takes_value(true)
.requires(ROC_FILE)
.takes_value(true)
.validator(|s| s.parse::<usize>())
.required(false);
@ -185,6 +185,7 @@ pub fn build_app<'a>() -> Command<'a> {
.subcommand(Command::new(CMD_CHECK)
.about("Check the code for problems, but doesnt build or run it")
.arg(flag_time.clone())
.arg(flag_max_threads.clone())
.arg(
Arg::new(ROC_FILE)
.help("The .roc file of an app to check")

View file

@ -6,7 +6,7 @@ use roc_cli::{
FLAG_NO_LINK, FLAG_TARGET, FLAG_TIME, ROC_FILE,
};
use roc_error_macros::user_error;
use roc_load::LoadingProblem;
use roc_load::{LoadingProblem, Threading};
use std::fs::{self, FileType};
use std::io;
use std::path::{Path, PathBuf};
@ -94,7 +94,17 @@ fn main() -> io::Result<()> {
let roc_file_path = PathBuf::from(filename);
let src_dir = roc_file_path.parent().unwrap().to_owned();
match check_file(&arena, src_dir, roc_file_path, emit_timings) {
let threading = match matches
.value_of(roc_cli::FLAG_MAX_THREADS)
.and_then(|s| s.parse::<usize>().ok())
{
None => Threading::AllAvailable,
Some(0) => user_error!("cannot build with at most 0 threads"),
Some(1) => Threading::Single,
Some(n) => Threading::AtMost(n),
};
match check_file(&arena, src_dir, roc_file_path, emit_timings, threading) {
Ok((problems, total_time)) => {
println!(
"\x1B[{}m{}\x1B[39m {} and \x1B[{}m{}\x1B[39m {} found in {} ms.",