@@ -143,7 +143,9 @@ def add_parser_common(command, parser_adder=None, parser=None):
143
143
group .add_argument ('-r' , '--runner' ,
144
144
help = 'override default runner from --build-dir' )
145
145
group .add_argument ('--skip-rebuild' , action = 'store_true' ,
146
- help = 'do not refresh cmake dependencies first' )
146
+ help = '(deprecated) do not refresh cmake dependencies first' )
147
+ group .add_argument ('--rebuild' , action = argparse .BooleanOptionalAction ,
148
+ help = 'manually specify to refresh cmake dependencies or not' )
147
149
group .add_argument ('--domain' , action = 'append' ,
148
150
help = 'execute runner only for given domain' )
149
151
@@ -244,8 +246,7 @@ def do_run_common(command, user_args, user_runner_args, domain_file=None):
244
246
)
245
247
246
248
build_dir = get_build_dir (user_args )
247
- if not user_args .skip_rebuild :
248
- rebuild (command , build_dir , user_args )
249
+ rebuild (command , build_dir , user_args )
249
250
250
251
domains = get_domains_to_process (build_dir , user_args , domain_file )
251
252
@@ -567,7 +568,25 @@ def load_cmake_cache(build_dir, args):
567
568
except FileNotFoundError :
568
569
log .die (f'no CMake cache found (expected one at { cache_file } )' )
569
570
571
+ def skip_rebuild (command , args ):
572
+ if args .rebuild is not None :
573
+ return not args .rebuild
574
+
575
+ if args .skip_rebuild :
576
+ log .wrn ("--skip-rebuild is deprecated. Please use --no-rebuild instead" )
577
+ return True
578
+
579
+ rebuild_config = config .getboolean (command .name , 'rebuild' , fallback = None )
580
+
581
+ if rebuild_config is not None :
582
+ return not rebuild_config
583
+
584
+ return False
585
+
570
586
def rebuild (command , build_dir , args ):
587
+ if skip_rebuild (command , args ):
588
+ return
589
+
571
590
_banner (f'west { command .name } : rebuilding' )
572
591
try :
573
592
zcmake .run_build (build_dir )
@@ -723,7 +742,7 @@ def dump_context(command, args, unknown_args):
723
742
get_all_domain = True
724
743
725
744
# Re-build unless asked not to, to make sure the output is up to date.
726
- if build_dir and not args . skip_rebuild :
745
+ if build_dir :
727
746
rebuild (command , build_dir , args )
728
747
729
748
domains = get_domains_to_process (build_dir , args , None , get_all_domain )
0 commit comments