Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmake/modules/configuration_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ if(DEFINED CONF_FILE)

# In order to support a `prj_<name>.conf pattern for auto inclusion of board
# overlays, then we must first ensure only a single conf file is provided.
string(REPLACE " " ";" CONF_FILE_AS_LIST "${CONF_FILE}")
string(CONFIGURE "${CONF_FILE}" CONF_FILE_EXPANDED)
string(REPLACE " " ";" CONF_FILE_AS_LIST "${CONF_FILE_EXPANDED}")
list(LENGTH CONF_FILE_AS_LIST CONF_FILE_LENGTH)
if(${CONF_FILE_LENGTH} EQUAL 1)
# Need the file name to look for match.
Expand Down
3 changes: 2 additions & 1 deletion cmake/modules/dts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ set(dts_files
if(SUPPORTS_DTS)
if(DTC_OVERLAY_FILE)
# Convert from space-separated files into file list
string(REPLACE " " ";" DTC_OVERLAY_FILE_RAW_LIST "${DTC_OVERLAY_FILE}")
string(CONFIGURE "${DTC_OVERLAY_FILE}" DTC_OVERLAY_FILE_EXPANDED)
string(REPLACE " " ";" DTC_OVERLAY_FILE_RAW_LIST "${DTC_OVERLAY_FILE_EXPANDED}")
foreach(file ${DTC_OVERLAY_FILE_RAW_LIST})
file(TO_CMAKE_PATH "${file}" cmake_path_file)
list(APPEND DTC_OVERLAY_FILE_AS_LIST ${cmake_path_file})
Expand Down
6 changes: 4 additions & 2 deletions cmake/modules/kconfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ set(DOTCONFIG ${PROJECT_BINARY_DIR}/.config)
set(PARSED_KCONFIG_SOURCES_TXT ${PROJECT_BINARY_DIR}/kconfig/sources.txt)

if(CONF_FILE)
string(REPLACE " " ";" CONF_FILE_AS_LIST "${CONF_FILE}")
string(CONFIGURE "${CONF_FILE}" CONF_FILE_EXPANDED)
string(REPLACE " " ";" CONF_FILE_AS_LIST "${CONF_FILE_EXPANDED}")
endif()

zephyr_get(OVERLAY_CONFIG SYSBUILD LOCAL)
if(OVERLAY_CONFIG)
string(REPLACE " " ";" OVERLAY_CONFIG_AS_LIST "${OVERLAY_CONFIG}")
string(CONFIGURE "${OVERLAY_CONFIG}" OVERLAY_CONFIG_EXPANDED)
string(REPLACE " " ";" OVERLAY_CONFIG_AS_LIST "${OVERLAY_CONFIG_EXPANDED}")
endif()

if((DEFINED BOARD_REVISION) AND EXISTS ${BOARD_DIR}/${BOARD}_${BOARD_REVISION_STRING}.conf)
Expand Down
5 changes: 4 additions & 1 deletion doc/build/dts/howtos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,10 @@ Set devicetree overlays
Devicetree overlays are explained in :ref:`devicetree-intro`. The CMake
variable :makevar:`DTC_OVERLAY_FILE` contains a space- or semicolon-separated
list of overlay files to use. If :makevar:`DTC_OVERLAY_FILE` specifies multiple
files, they are included in that order by the C preprocessor.
files, they are included in that order by the C preprocessor. A file in a
Zephyr module can be referred to by escaping the Zephyr module dir variable
like ``\${ZEPHYR_<module>_MODULE_DIR}/<path-to>/dts.overlay``
when setting the DTC_OVERLAY_FILE variable.

You can set :makevar:`DTC_OVERLAY_FILE` to contain exactly the files you want
to use. Here is an :ref:`example <west-building-dtc-overlay-file>` using
Expand Down
5 changes: 4 additions & 1 deletion doc/build/kconfig/setting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ The application configuration can come from the sources below. By default,

All configuration files will be taken from the application's configuration
directory except for files with an absolute path that are given with the
``CONF_FILE`` argument.
``CONF_FILE``, ``OVERLAY_CONFIG``, and ``DTC_OVERLAY_FILE`` arguments. For these,
a file in a Zephyr module can be referred by escaping the Zephyr module dir
variable like this ``\${ZEPHYR_<module>_MODULE_DIR}/<path-to>/<file>``
when setting any of said variables in the application's :file:`CMakeLists.txt`.

See :ref:`Application Configuration Directory <application-configuration-directory>`
on how the application configuration directory is defined.
Expand Down
12 changes: 12 additions & 0 deletions tests/cmake/overlays/var_expansions/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

set(ZEPHYR_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/my_module")
set(ZEPHYR_EXTRA_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/my_extra_module")

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(overlay_var_expansions)

FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: my_extra_module_name
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright (c) 2022 Legrand, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/

/ {
/* This file is intentionally empty */
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# extra-overlay-empty.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: my_module_name
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright (c) 2022 Legrand, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/

/ {
/* This file is intentionally empty */
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# overlay-empty.conf
2 changes: 2 additions & 0 deletions tests/cmake/overlays/var_expansions/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_ZTEST=y
CONFIG_ZTEST_NEW_API=y
16 changes: 16 additions & 0 deletions tests/cmake/overlays/var_expansions/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Legrand North America, LLC.
*
* SPDX-License-Identifier: Apache-2.0
*/


#include <zephyr/ztest.h>


ZTEST_SUITE(cmake_overlay_tests, NULL, NULL, NULL, NULL, NULL);

ZTEST(cmake_overlay_tests, test_stub_for_build_only_test)
{
ztest_test_pass();
}
11 changes: 11 additions & 0 deletions tests/cmake/overlays/var_expansions/testcase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
common:
tags: cmake
build_only: true
platform_allow: native_posix
tests:
cmake.overlays.var_expansions.CONF_FILE:
extra_args: CONF_FILE=${ZEPHYR_MY_MODULE_NAME_MODULE_DIR}/zephyr/my_module-overlay.conf;${ZEPHYR_MY_EXTRA_MODULE_NAME_MODULE_DIR}/zephyr/my_extra_module-overlay.conf;prj.conf
cmake.overlays.var_expansions.OVERLAY_CONFIG:
extra_args: OVERLAY_CONFIG=${ZEPHYR_MY_MODULE_NAME_MODULE_DIR}/zephyr/my_module-overlay.conf;${ZEPHYR_MY_EXTRA_MODULE_NAME_MODULE_DIR}/zephyr/my_extra_module-overlay.conf
cmake.overlays.var_expansions.DTC_OVERLAY_FILE:
extra_args: DTC_OVERLAY_FILE=${ZEPHYR_MY_MODULE_NAME_MODULE_DIR}/zephyr/my_module-board.overlay;${ZEPHYR_MY_EXTRA_MODULE_NAME_MODULE_DIR}/zephyr/my_extra_module-board.overlay