Skip to content

Commit 35945f6

Browse files
committed
scripts: flash: Add west config for flash skip rebuild
Add a west config option to skip rebuilds by default or not when doing west flash. Signed-off-by: Declan Snyder <[email protected]>
1 parent 18497c5 commit 35945f6

File tree

2 files changed

+62
-4
lines changed

2 files changed

+62
-4
lines changed

doc/develop/west/build-flash-debug.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,22 @@ only the image from this domain::
551551

552552
.. _west-debugging:
553553

554+
Configuration Options
555+
=====================
556+
557+
You can :ref:`configure <west-config-cmd>` ``west flash`` using these options.
558+
559+
.. NOTE: docs authors: keep this table sorted alphabetically
560+
561+
.. list-table::
562+
:widths: 10 30
563+
:header-rows: 1
564+
565+
* - Option
566+
- Description
567+
* - ``flash.rebuild``
568+
- Boolean, default ``true``. If ``false``, do not rebuild on west flash.
569+
554570
Debugging: ``west debug``, ``west debugserver``
555571
***********************************************
556572

@@ -683,6 +699,25 @@ to debug::
683699

684700
.. _west-runner:
685701

702+
Configuration Options
703+
=====================
704+
705+
You can :ref:`configure <west-config-cmd>` ``west debug`` and
706+
:ref:`configure <west-config-cmd>` ``west debugserver`` using these options.
707+
708+
.. NOTE: docs authors: keep this table sorted alphabetically
709+
710+
.. list-table::
711+
:widths: 10 30
712+
:header-rows: 1
713+
714+
* - Option
715+
- Description
716+
* - ``debug.rebuild``
717+
- Boolean, default ``true``. If ``false``, do not rebuild on west debug.
718+
* - ``debugserver.rebuild``
719+
- Boolean, default ``true``. If ``false``, do not rebuild on west debugserver.
720+
686721
Flash and debug runners
687722
***********************
688723

scripts/west_commands/run_common.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,10 @@ def add_parser_common(command, parser_adder=None, parser=None):
142142
help=argparse.SUPPRESS)
143143
group.add_argument('-r', '--runner',
144144
help='override default runner from --build-dir')
145-
group.add_argument('--skip-rebuild', action='store_true',
145+
group.add_argument('-s', '--skip-rebuild', "--no-rebuild", action='store_true',
146146
help='do not refresh cmake dependencies first')
147+
group.add_argument('--force-rebuild', '--rebuild', action='store_true',
148+
help='force a refresh of the cmake dependencies before running')
147149
group.add_argument('--domain', action='append',
148150
help='execute runner only for given domain')
149151

@@ -244,8 +246,7 @@ def do_run_common(command, user_args, user_runner_args, domain_file=None):
244246
)
245247

246248
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)
249250

250251
domains = get_domains_to_process(build_dir, user_args, domain_file)
251252

@@ -568,6 +569,28 @@ def load_cmake_cache(build_dir, args):
568569
log.die(f'no CMake cache found (expected one at {cache_file})')
569570

570571
def rebuild(command, build_dir, args):
572+
rebuild_config = config.get(command.name, 'rebuild', fallback='true').lower()
573+
574+
# Truth table ->
575+
# config rebuild | manual option | rebuild?
576+
# ==========================================
577+
# X | skip | skip
578+
# X | force | rebuild
579+
# true (default) | [none] | rebuild
580+
# false | [none] | skip
581+
#============================================
582+
# Therefore, only two cases in which we skip:
583+
584+
# user manually specified skip rebuild, so we skip
585+
if args.skip_rebuild:
586+
return
587+
588+
# config says to skip, and user did not manually override, so skip
589+
if rebuild_config == 'false' and not args.force_rebuild:
590+
return
591+
592+
# any other case, we do rebuild
593+
571594
_banner(f'west {command.name}: rebuilding')
572595
try:
573596
zcmake.run_build(build_dir)
@@ -723,7 +746,7 @@ def dump_context(command, args, unknown_args):
723746
get_all_domain = True
724747

725748
# Re-build unless asked not to, to make sure the output is up to date.
726-
if build_dir and not args.skip_rebuild:
749+
if build_dir:
727750
rebuild(command, build_dir, args)
728751

729752
domains = get_domains_to_process(build_dir, args, None, get_all_domain)

0 commit comments

Comments
 (0)