zephyr/cmake/flash/check_runner_dependencies.cmake
Torsten Rasmussen 3dd65a7663 runners: remove dependencies from runners
Today, there is a build target is added for each runner: flash, debug,
debugserver, attach.

And those runners will have a dependency to Zephyr logical target that
is built before invoking `west <runner>`.

This design has some flaws, mainly that additional dependencies directly
on the target will not be built when running `west <runner>` directly.
That generator expressions cannot be used for the DEPENDS argument.

Instead, the build target `<runner>` will not have any dependencies, and
will raise a build error if a dependency is added to the target.
Due to how `add_dependencies()` work, this must be done as a build time
check, and not configure time check.

`west <runner>` will invoke a build before executing the runner, and
this way ensure the build target is up-to-date, which again removes the
need for a dedicated `west_<runner>_target`.

It also minimizes the risk of developer errors, as developers no longer
need to consider the need for adding additional dependencies.
If a custom target is part of the default `all` build, then it's ensured
to be up-to-date.

Fixes: Issue reported on slack.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-04-19 15:35:30 +02:00

20 lines
585 B
CMake

# SPDX-License-Identifier: Apache-2.0
# The purpose of this script is to ensure that no runners targets contains
# additional dependencies.
#
# If the target contains dependencies, an error will be printed.
#
# Arguments to the script
#
# TARGET: The target being checked.
# DEPENDENCIES: List containing dependencies on target.
if(DEPENDENCIES)
string(REPLACE ";" " " DEPENDENCIES "${DEPENDENCIES}")
message(FATAL_ERROR
"`${TARGET}` cannot have dependencies, please remove "
"`add_dependencies(${TARGET} ${DEPENDENCIES})` in build system."
)
endif()