Skip to content

Commit 08d1f28

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. Also add corresponding symmetrical CLI options. Signed-off-by: Declan Snyder <[email protected]>
1 parent bbe4a06 commit 08d1f28

File tree

2 files changed

+58
-4
lines changed

2 files changed

+58
-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: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ def add_parser_common(command, parser_adder=None, parser=None):
143143
group.add_argument('-r', '--runner',
144144
help='override default runner from --build-dir')
145145
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')
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

@@ -567,7 +568,25 @@ def load_cmake_cache(build_dir, args):
567568
except FileNotFoundError:
568569
log.die(f'no CMake cache found (expected one at {cache_file})')
569570

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+
570586
def rebuild(command, build_dir, args):
587+
if skip_rebuild(command, args):
588+
return
589+
571590
_banner(f'west {command.name}: rebuilding')
572591
try:
573592
zcmake.run_build(build_dir)
@@ -723,7 +742,7 @@ def dump_context(command, args, unknown_args):
723742
get_all_domain = True
724743

725744
# 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:
727746
rebuild(command, build_dir, args)
728747

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

0 commit comments

Comments
 (0)