mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
hook max-threads up for roc check
This commit is contained in:
parent
35bf66f650
commit
abbe8ecd24
3 changed files with 16 additions and 4 deletions
|
@ -350,6 +350,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,
|
||||||
|
threading: Threading,
|
||||||
) -> Result<(program::Problems, Duration), LoadingProblem> {
|
) -> Result<(program::Problems, Duration), LoadingProblem> {
|
||||||
let compilation_start = SystemTime::now();
|
let compilation_start = SystemTime::now();
|
||||||
|
|
||||||
|
@ -368,7 +369,7 @@ pub fn check_file(
|
||||||
target_info,
|
target_info,
|
||||||
// TODO: expose this from CLI?
|
// TODO: expose this from CLI?
|
||||||
RenderTarget::ColorTerminal,
|
RenderTarget::ColorTerminal,
|
||||||
Threading::AllAvailable,
|
threading,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let buf = &mut String::with_capacity(1024);
|
let buf = &mut String::with_capacity(1024);
|
||||||
|
|
|
@ -62,8 +62,8 @@ pub fn build_app<'a>() -> Command<'a> {
|
||||||
let flag_max_threads = Arg::new(FLAG_MAX_THREADS)
|
let flag_max_threads = Arg::new(FLAG_MAX_THREADS)
|
||||||
.long(FLAG_MAX_THREADS)
|
.long(FLAG_MAX_THREADS)
|
||||||
.help("Limit the number of threads (and hence cores) used during compilation.")
|
.help("Limit the number of threads (and hence cores) used during compilation.")
|
||||||
.takes_value(true)
|
|
||||||
.requires(ROC_FILE)
|
.requires(ROC_FILE)
|
||||||
|
.takes_value(true)
|
||||||
.validator(|s| s.parse::<usize>())
|
.validator(|s| s.parse::<usize>())
|
||||||
.required(false);
|
.required(false);
|
||||||
|
|
||||||
|
@ -185,6 +185,7 @@ pub fn build_app<'a>() -> Command<'a> {
|
||||||
.subcommand(Command::new(CMD_CHECK)
|
.subcommand(Command::new(CMD_CHECK)
|
||||||
.about("Check the code for problems, but doesn’t build or run it")
|
.about("Check the code for problems, but doesn’t build or run it")
|
||||||
.arg(flag_time.clone())
|
.arg(flag_time.clone())
|
||||||
|
.arg(flag_max_threads.clone())
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(ROC_FILE)
|
Arg::new(ROC_FILE)
|
||||||
.help("The .roc file of an app to check")
|
.help("The .roc file of an app to check")
|
||||||
|
|
|
@ -6,7 +6,7 @@ use roc_cli::{
|
||||||
FLAG_NO_LINK, FLAG_TARGET, FLAG_TIME, ROC_FILE,
|
FLAG_NO_LINK, FLAG_TARGET, FLAG_TIME, ROC_FILE,
|
||||||
};
|
};
|
||||||
use roc_error_macros::user_error;
|
use roc_error_macros::user_error;
|
||||||
use roc_load::LoadingProblem;
|
use roc_load::{LoadingProblem, Threading};
|
||||||
use std::fs::{self, FileType};
|
use std::fs::{self, FileType};
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
@ -94,7 +94,17 @@ fn main() -> io::Result<()> {
|
||||||
let roc_file_path = PathBuf::from(filename);
|
let roc_file_path = PathBuf::from(filename);
|
||||||
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) {
|
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)) => {
|
Ok((problems, total_time)) => {
|
||||||
println!(
|
println!(
|
||||||
"\x1B[{}m{}\x1B[39m {} and \x1B[{}m{}\x1B[39m {} found in {} ms.",
|
"\x1B[{}m{}\x1B[39m {} and \x1B[{}m{}\x1B[39m {} found in {} ms.",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue