80ca540522
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>
36 lines
938 B
CMake
36 lines
938 B
CMake
# 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()
|