@@ -27,7 +27,7 @@ use step;
2727
2828/// Deserialized version of all flags for this compile.
2929pub struct Flags {
30- pub verbose : bool ,
30+ pub verbose : usize , // verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose
3131 pub stage : Option < u32 > ,
3232 pub keep_stage : Option < u32 > ,
3333 pub build : String ,
@@ -37,6 +37,17 @@ pub struct Flags {
3737 pub src : Option < PathBuf > ,
3838 pub jobs : Option < u32 > ,
3939 pub cmd : Subcommand ,
40+ pub incremental : bool ,
41+ }
42+
43+ impl Flags {
44+ pub fn verbose ( & self ) -> bool {
45+ self . verbose > 0
46+ }
47+
48+ pub fn very_verbose ( & self ) -> bool {
49+ self . verbose > 1
50+ }
4051}
4152
4253pub enum Subcommand {
@@ -63,7 +74,8 @@ pub enum Subcommand {
6374impl Flags {
6475 pub fn parse ( args : & [ String ] ) -> Flags {
6576 let mut opts = Options :: new ( ) ;
66- opts. optflag ( "v" , "verbose" , "use verbose output" ) ;
77+ opts. optflagmulti ( "v" , "verbose" , "use verbose output (-vv for very verbose)" ) ;
78+ opts. optflag ( "i" , "incremental" , "use incremental compilation" ) ;
6779 opts. optopt ( "" , "config" , "TOML configuration file for build" , "FILE" ) ;
6880 opts. optopt ( "" , "build" , "build target of the stage0 compiler" , "BUILD" ) ;
6981 opts. optmulti ( "" , "host" , "host targets to build" , "HOST" ) ;
@@ -256,8 +268,18 @@ To learn more about a subcommand, run `./x.py <command> -h`
256268 }
257269 } ) ;
258270
271+ let mut stage = m. opt_str ( "stage" ) . map ( |j| j. parse ( ) . unwrap ( ) ) ;
272+
273+ let incremental = m. opt_present ( "i" ) ;
274+
275+ if incremental {
276+ if stage. is_none ( ) {
277+ stage = Some ( 1 ) ;
278+ }
279+ }
280+
259281 Flags {
260- verbose : m. opt_present ( "v" ) ,
282+ verbose : m. opt_count ( "v" ) ,
261283 stage : m. opt_str ( "stage" ) . map ( |j| j. parse ( ) . unwrap ( ) ) ,
262284 keep_stage : m. opt_str ( "keep-stage" ) . map ( |j| j. parse ( ) . unwrap ( ) ) ,
263285 build : m. opt_str ( "build" ) . unwrap_or_else ( || {
@@ -269,6 +291,7 @@ To learn more about a subcommand, run `./x.py <command> -h`
269291 src : m. opt_str ( "src" ) . map ( PathBuf :: from) ,
270292 jobs : m. opt_str ( "jobs" ) . map ( |j| j. parse ( ) . unwrap ( ) ) ,
271293 cmd : cmd,
294+ incremental : incremental,
272295 }
273296 }
274297}
0 commit comments