diff --git a/cli/src/lib.rs b/cli/src/lib.rs index 18d4e4de53..e6603cdbdb 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -35,6 +35,7 @@ pub const CMD_FORMAT: &str = "format"; pub const FLAG_DEBUG: &str = "debug"; pub const FLAG_DEV: &str = "dev"; pub const FLAG_OPTIMIZE: &str = "optimize"; +pub const FLAG_MAX_THREADS: &str = "max-threads"; pub const FLAG_OPT_SIZE: &str = "opt-size"; pub const FLAG_LIB: &str = "lib"; pub const FLAG_NO_LINK: &str = "no-link"; @@ -58,6 +59,14 @@ pub fn build_app<'a>() -> Command<'a> { .requires(ROC_FILE) .required(false); + 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) + .validator(|s| s.parse::()) + .required(false); + let flag_opt_size = Arg::new(FLAG_OPT_SIZE) .long(FLAG_OPT_SIZE) .help("Optimize the compiled program to have a small binary size. (Optimization takes time to complete.)") @@ -102,6 +111,7 @@ pub fn build_app<'a>() -> Command<'a> { .subcommand(Command::new(CMD_BUILD) .about("Build a binary from the given .roc file, but don't run it") .arg(flag_optimize.clone()) + .arg(flag_max_threads.clone()) .arg(flag_opt_size.clone()) .arg(flag_dev.clone()) .arg(flag_debug.clone()) @@ -141,6 +151,7 @@ pub fn build_app<'a>() -> Command<'a> { .subcommand(Command::new(CMD_RUN) .about("Run a .roc file even if it has build errors") .arg(flag_optimize.clone()) + .arg(flag_max_threads.clone()) .arg(flag_opt_size.clone()) .arg(flag_dev.clone()) .arg(flag_debug.clone()) @@ -193,6 +204,7 @@ pub fn build_app<'a>() -> Command<'a> { ) .trailing_var_arg(true) .arg(flag_optimize) + .arg(flag_max_threads.clone()) .arg(flag_opt_size) .arg(flag_dev) .arg(flag_debug)