Skip to content
Closed
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/app/boilerplate.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,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/dts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,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/kconfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ 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()

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/application/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,10 @@ Application Configuration Directory
Zephyr will use configuration files from the application's configuration
directory except for files with an absolute path provided by the arguments
described earlier, for example ``CONF_FILE``, ``OVERLAY_CONFIG``, and
``DTC_OVERLAY_FILE``.
``DTC_OVERLAY_FILE``. 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.

The application configuration directory is defined by the
``APPLICATION_CONFIG_DIR`` variable.
Expand Down
5 changes: 4 additions & 1 deletion doc/guides/dts/howtos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,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
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
1 change: 1 addition & 0 deletions tests/cmake/overlays/var_expansions/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_ZTEST=y
22 changes: 22 additions & 0 deletions tests/cmake/overlays/var_expansions/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2022 Legrand North America, LLC.
*
* SPDX-License-Identifier: Apache-2.0
*/


#include <zephyr.h>
#include <ztest.h>


static void test_stub_for_build_only_test(void)
{
ztest_test_pass();
}

void test_main(void)
{
ztest_test_suite(cmake_overlay_var_expansions_test_suite,
ztest_unit_test(test_stub_for_build_only_test));
ztest_run_test_suite(cmake_overlay_var_expansions_test_suite);
}
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