diff --git a/doc/develop/west/build-flash-debug.rst b/doc/develop/west/build-flash-debug.rst index 00cf29191c6b..a183108d5142 100644 --- a/doc/develop/west/build-flash-debug.rst +++ b/doc/develop/west/build-flash-debug.rst @@ -551,6 +551,22 @@ only the image from this domain:: .. _west-debugging: +Configuration Options +===================== + +You can :ref:`configure ` ``west flash`` using these options. + +.. NOTE: docs authors: keep this table sorted alphabetically + +.. list-table:: + :widths: 10 30 + :header-rows: 1 + + * - Option + - Description + * - ``flash.rebuild`` + - Boolean, default ``true``. If ``false``, do not rebuild on west flash. + Debugging: ``west debug``, ``west debugserver`` *********************************************** @@ -683,6 +699,25 @@ to debug:: .. _west-runner: +Configuration Options +===================== + +You can :ref:`configure ` ``west debug`` and +:ref:`configure ` ``west debugserver`` using these options. + +.. NOTE: docs authors: keep this table sorted alphabetically + +.. list-table:: + :widths: 10 30 + :header-rows: 1 + + * - Option + - Description + * - ``debug.rebuild`` + - Boolean, default ``true``. If ``false``, do not rebuild on west debug. + * - ``debugserver.rebuild`` + - Boolean, default ``true``. If ``false``, do not rebuild on west debugserver. + Flash and debug runners *********************** diff --git a/scripts/west_commands/run_common.py b/scripts/west_commands/run_common.py index 2989c8698ebe..52201a1d45be 100644 --- a/scripts/west_commands/run_common.py +++ b/scripts/west_commands/run_common.py @@ -143,7 +143,9 @@ def add_parser_common(command, parser_adder=None, parser=None): group.add_argument('-r', '--runner', help='override default runner from --build-dir') group.add_argument('--skip-rebuild', action='store_true', - help='do not refresh cmake dependencies first') + help='(deprecated) do not refresh cmake dependencies first') + group.add_argument('--rebuild', action=argparse.BooleanOptionalAction, + help='manually specify to refresh cmake dependencies or not') group.add_argument('--domain', action='append', help='execute runner only for given domain') @@ -244,8 +246,7 @@ def do_run_common(command, user_args, user_runner_args, domain_file=None): ) build_dir = get_build_dir(user_args) - if not user_args.skip_rebuild: - rebuild(command, build_dir, user_args) + rebuild(command, build_dir, user_args) domains = get_domains_to_process(build_dir, user_args, domain_file) @@ -567,7 +568,25 @@ def load_cmake_cache(build_dir, args): except FileNotFoundError: log.die(f'no CMake cache found (expected one at {cache_file})') +def skip_rebuild(command, args): + if args.rebuild is not None: + return not args.rebuild + + if args.skip_rebuild: + log.wrn("--skip-rebuild is deprecated. Please use --no-rebuild instead") + return True + + rebuild_config = config.getboolean(command.name, 'rebuild', fallback=None) + + if rebuild_config is not None: + return not rebuild_config + + return False + def rebuild(command, build_dir, args): + if skip_rebuild(command, args): + return + _banner(f'west {command.name}: rebuilding') try: zcmake.run_build(build_dir) @@ -723,7 +742,7 @@ def dump_context(command, args, unknown_args): get_all_domain = True # Re-build unless asked not to, to make sure the output is up to date. - if build_dir and not args.skip_rebuild: + if build_dir: rebuild(command, build_dir, args) domains = get_domains_to_process(build_dir, args, None, get_all_domain)