cmake: west: west flash dependencies in sync with CMake flash target
This commit creates a list of a phony targets for each runner, that is: `west_flash_depends`, `west_debug_depends`, and so on. Those targets has identical dependencies as CMake runner target. flash, debug, debugserver, attach targets. As example `ninja flash` correctly ensures dependencies are taken into consideration before calling `west flash`. Unfortunately, calling `west flash` directly would not re-run the flash dependencies, cause `west flash` would only build the default CMake target. Now, `west flash` calls the phony `west_flash_depends` target, ensuring all deps are up-to-date before flashing (unless --skip-rebuild is given) The same is true for the other mentioned runners. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
parent
d38da9d386
commit
13642fe013
2 changed files with 12 additions and 1 deletions
|
@ -211,6 +211,16 @@ foreach(target flash debug debugserver attach)
|
|||
${comment}
|
||||
USES_TERMINAL
|
||||
)
|
||||
|
||||
# This is an artificial target to allow west to ensure all dependencies of
|
||||
# target is build before carrying out the actual command.
|
||||
# This allows `west` to run just the dependencies before flashing.
|
||||
add_custom_target(west_${target}_depends
|
||||
COMMAND ${CMAKE_COMMAND} -E echo ""
|
||||
DEPENDS ${RUNNERS_DEPS}
|
||||
$<TARGET_PROPERTY:zephyr_property_target,${TARGET_UPPER}_DEPENDENCIES>
|
||||
USES_TERMINAL
|
||||
)
|
||||
else()
|
||||
add_custom_target(${target}
|
||||
COMMAND ${CMAKE_COMMAND} -E echo \"West was not found in path. To support
|
||||
|
|
|
@ -258,8 +258,9 @@ def load_cmake_cache(build_dir, args):
|
|||
|
||||
def rebuild(command, build_dir, args):
|
||||
_banner(f'west {command.name}: rebuilding')
|
||||
extra_args = ['--target', 'west_' + command.name + '_depends']
|
||||
try:
|
||||
zcmake.run_build(build_dir)
|
||||
zcmake.run_build(build_dir, extra_args=extra_args)
|
||||
except CalledProcessError:
|
||||
if args.build_dir:
|
||||
log.die(f're-build in {args.build_dir} failed')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue