1+ use crate :: backends:: BuildProfile ;
12use clap:: { Args , Parser , Subcommand } ;
23use serde_derive:: { Deserialize , Serialize } ;
34use std:: path:: PathBuf ;
@@ -17,46 +18,61 @@ pub enum Platform {
1718 Zephyr ,
1819}
1920
20- #[ derive( clap:: ValueEnum , Clone , Copy , Debug , Deserialize , Serialize ) ]
21+ #[ derive( clap:: ValueEnum , Clone , Copy , Debug , Deserialize , Serialize , Eq , PartialEq , Hash ) ]
2122pub enum BuildSystem {
2223 LFC ,
2324 CMake ,
25+ Cargo ,
2426}
2527
2628#[ derive( Args , Debug ) ]
2729pub struct BuildArgs {
28- /// which build system to use
30+ /// Which build system to use
2931 /// TODO: discuss this
3032 #[ clap( short, long) ]
3133 pub build_system : Option < BuildSystem > ,
3234
33- /// which target to build
35+ /// Which target to build
3436 #[ clap( short, long) ]
3537 pub language : Option < TargetLanguage > ,
3638
37- /// overwrites any possible board definition in Lingo.toml
39+ /// Overwrites any possible board definition in Lingo.toml
3840 #[ clap( long) ]
3941 pub platform : Option < Platform > ,
4042
41- /// tell lingo where the lfc toolchain can be found
43+ /// Tell lingo where the lfc toolchain can be found
4244 #[ clap( long) ]
4345 pub lfc : Option < PathBuf > ,
4446
45- /// skips building aka invoking the build system so it only generates code
47+ /// Skips building aka invoking the build system so it only generates code
4648 #[ clap( short, long, action) ]
4749 pub no_compile : bool ,
4850
49- /// if one of the apps fails to build dont interrupt the build process
51+ /// If one of the apps fails to build dont interrupt the build process
5052 #[ clap( short, long, action) ]
5153 pub keep_going : bool ,
5254
53- /// compiles the binaries with optimizations turned on and strips debug symbols
55+ /// Compiles the binaries with optimizations turned on and strips debug symbols
5456 #[ clap( short, long, action) ]
5557 pub release : bool ,
5658
57- /// list of apps to build if left empty all apps are built
59+ /// List of apps to build if left empty all apps are built
5860 #[ clap( short, long, value_delimiter = ',' ) ]
5961 pub apps : Vec < String > ,
62+
63+ /// Number of threads to use for parallel builds. Zero means it will be determined automatically.
64+ #[ clap( short, long, default_value_t = 0 ) ]
65+ pub threads : usize ,
66+ }
67+
68+ impl BuildArgs {
69+ pub fn build_profile ( & self ) -> BuildProfile {
70+ if self . release {
71+ BuildProfile :: Release
72+ } else {
73+ BuildProfile :: Debug
74+ }
75+ }
6076}
6177
6278impl ToString for TargetLanguage {
@@ -75,7 +91,7 @@ pub struct InitArgs {
7591}
7692impl InitArgs {
7793 pub fn get_target_language ( & self ) -> TargetLanguage {
78- self . language . unwrap_or_else ( || {
94+ self . language . unwrap_or ( {
7995 // Target language for Zephyr is C, else Cpp.
8096 match self . platform {
8197 Some ( Platform :: Zephyr ) => TargetLanguage :: C ,
0 commit comments