Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: package_helper CMake script #41302

Merged

Conversation

tejlmand
Copy link
Collaborator

@tejlmand tejlmand commented Dec 17, 2021

The Zephyr CMake package helper script allows to invoke Zephyr package
modules as they are invoked at configure time, up to the modules given
with -DMODULES=<modules>.
This allows to run the configure time part of the Zephyr build system
without generating a complete build system.

This means that for example devicetree module can be invoked for a given
sample and board to generate zephyr.dts identical to what is created
by the build system during a build.

To generate zephyr.dts for hello_world, invoke the script as:
$ cmake -DBOARD= -B build -S samples/hello_world
$ -DMODULES=dts -P <ZEPHYR_BASE>/cmake/package_helper.cmake

Other modules, for example 'kconfig' and 'zephyr_modules' can also be
invoked this way.

This will allow other tools, such as twister, to executed only a
subset of the build system like dts in order to do filtering before
determine if a complete build should be invoked.

Signed-off-by: Torsten Rasmussen [email protected]


NOTE Ignore first commit, it's a squash of #41301.

@tejlmand tejlmand force-pushed the zephyr_package_tooling branch from cd0aae1 to 1849402 Compare January 31, 2022 22:25
@tejlmand tejlmand force-pushed the zephyr_package_tooling branch 2 times, most recently from be58359 to abdcd6d Compare February 3, 2022 11:20
cmake/modules/zephyr_default.cmake Outdated Show resolved Hide resolved
#
# Copyright (c) 2021, Nordic Semiconductor ASA

# The Zephyr package tooling script provides a generic script mode interface
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about package_helper?

@tejlmand tejlmand force-pushed the zephyr_package_tooling branch from abdcd6d to 8751a0f Compare February 16, 2022 16:09
endforeach()

if(NOT DEFINED SUB_COMPONENTS)
include(kernel)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we unconditionally include kernel?

If SUB_COMPONENTS is defined the program will have returned before now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point.

after the cleanup, this if can be removed.

will do.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

SebastianBoe
SebastianBoe previously approved these changes Feb 16, 2022
@tejlmand tejlmand force-pushed the zephyr_package_tooling branch 3 times, most recently from 1467560 to 9423439 Compare February 18, 2022 10:37
@tejlmand tejlmand changed the title cmake: package_tooling CMake script cmake: package_helper CMake script Feb 18, 2022
This commit allows to load only subcomponents of the default Zephyr
CMake module, zephyr_default.cmake.

This allows other tools to execute Zephyr CMake build system up to a
specific module and the stop further processing.

This commit is an enabler for future support in twister to process only
devicetree or kconfig, to allow test / sample filtering before
generating a complete build system.

Sub-components can be loaded as:
> find_package(Zephyr COMPONENTS zephyr_default:<sub-component>)

for example:
> find_package(Zephyr COMPONENTS zephyr_default:dts)

Signed-off-by: Torsten Rasmussen <[email protected]>
The Zephyr CMake package helper script allows to invoke Zephyr package
modules as they are invoked at configure time, up to the modules given
with `-DMODULES=<modules>`.
This allows to run the configure time part of the Zephyr build system
without generating a complete build system.

This means that for example devicetree module can be invoked for a given
sample and board to generate zephyr.dts identical to what is created
by the build system during a build.

To generate zephyr.dts for hello_world, invoke the script as:
$ cmake -DBOARD=<board> -B build -S samples/hello_world \
$       -DMODULES=dts -P <ZEPHYR_BASE>/cmake/package_helper.cmake

Other modules, for example 'kconfig' and 'zephyr_modules' can also be
invoked this way.

This will allow other tools, such as twister, to executed only a
subset of the build system like dts in order to do filtering before
determine if a complete build should be invoked.

Signed-off-by: Torsten Rasmussen <[email protected]>
@tejlmand tejlmand force-pushed the zephyr_package_tooling branch from 9423439 to f75862c Compare February 22, 2022 21:34
@tejlmand tejlmand removed the DNM This PR should not be merged (Do Not Merge) label Feb 22, 2022
@tejlmand
Copy link
Collaborator Author

Re-based, @mbolivar-nordic @SebastianBoe please re-approve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants