Skip to content

Commit 4eef91a

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 4eef91a

File tree

2 files changed

+52
-4
lines changed

2 files changed

+52
-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: 17 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

@@ -568,6 +569,18 @@ 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+
if args.rebuild is False:
573+
return
574+
575+
if args.skip_rebuild:
576+
log.wrn("--skip-rebuild is deprecated. Please use --no-rebuild instead")
577+
return
578+
579+
rebuild_config = config.getboolean(command.name, 'rebuild', fallback=True)
580+
581+
if not rebuild_config and not args.rebuild:
582+
return
583+
571584
_banner(f'west {command.name}: rebuilding')
572585
try:
573586
zcmake.run_build(build_dir)
@@ -723,7 +736,7 @@ def dump_context(command, args, unknown_args):
723736
get_all_domain = True
724737

725738
# Re-build unless asked not to, to make sure the output is up to date.
726-
if build_dir and not args.skip_rebuild:
739+
if build_dir:
727740
rebuild(command, build_dir, args)
728741

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

0 commit comments

Comments
 (0)