snippets: basic build system boilerplate
Basic things needed to integrate the new 'snippets' feature into the build system. The main CMake variable which controls snippets is SNIPPET. It is a whitespace-or-semicolon-separated list of snippet names. - Add minimal new cmake module for processing snippets. This just has basic infrastructure for processing a SNIPPET variable into SNIPPET_AS_LIST, and warning the user if they try to change it too late. - Integrate the new module into the build system, via zephyr_default.cmake This is anologous to the shields and boards modules' boilerplate and input variables. Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
6898094111
commit
80ca540522
2 changed files with 36 additions and 0 deletions
35
cmake/modules/snippets.cmake
Normal file
35
cmake/modules/snippets.cmake
Normal file
|
@ -0,0 +1,35 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Copyright (c) 2021, Nordic Semiconductor ASA
|
||||
|
||||
# Snippets support
|
||||
#
|
||||
# Outcome:
|
||||
# The following variables will be defined when this module completes:
|
||||
#
|
||||
# - SNIPPET_AS_LIST: CMake list of snippet names, created from the
|
||||
# SNIPPET variable
|
||||
|
||||
include_guard(GLOBAL)
|
||||
|
||||
include(extensions)
|
||||
|
||||
# Warn the user if SNIPPET changes later. Such changes are ignored.
|
||||
zephyr_check_cache(SNIPPET WATCH)
|
||||
|
||||
# Putting the body into a function prevents us from polluting the
|
||||
# parent scope. We'll set our outcome variables in the parent scope of
|
||||
# the function to ensure the outcome of the module.
|
||||
function(zephyr_process_snippets)
|
||||
if (SNIPPET)
|
||||
message(STATUS "Snippet(s): ${SNIPPET}")
|
||||
else()
|
||||
set(SNIPPET_AS_LIST "" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
string(REPLACE " " ";" SNIPPET_AS_LIST "${SNIPPET}")
|
||||
set(SNIPPET_AS_LIST "${SNIPPET_AS_LIST}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
zephyr_process_snippets()
|
|
@ -81,6 +81,7 @@ list(APPEND zephyr_cmake_modules zephyr_module)
|
|||
|
||||
list(APPEND zephyr_cmake_modules boards)
|
||||
list(APPEND zephyr_cmake_modules shields)
|
||||
list(APPEND zephyr_cmake_modules snippets)
|
||||
list(APPEND zephyr_cmake_modules arch)
|
||||
list(APPEND zephyr_cmake_modules configuration_files)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue