Skip to content
Open
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
2 changes: 2 additions & 0 deletions cmake/modules/configuration_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# - EXTRA_DTC_OVERLAY_FILE List of additional devicetree overlay files
# - DTS_EXTRA_CPPFLAGS List of additional devicetree preprocessor defines
# - APPLICATION_CONFIG_DIR: Root folder for application configuration
# - NET_INIT_CONFIG_FILE: Name of the network init configuration file
#
# If any of the above variables are already set when this CMake module is
# loaded, then no changes to the variable will happen.
Expand Down Expand Up @@ -95,5 +96,6 @@ zephyr_boilerplate_watch(DTC_OVERLAY_FILE)
zephyr_get(EXTRA_CONF_FILE SYSBUILD LOCAL VAR EXTRA_CONF_FILE OVERLAY_CONFIG MERGE REVERSE)
zephyr_get(EXTRA_DTC_OVERLAY_FILE SYSBUILD LOCAL MERGE REVERSE)
zephyr_get(DTS_EXTRA_CPPFLAGS SYSBUILD LOCAL MERGE REVERSE)
zephyr_get(NET_INIT_CONFIG_FILE)
Copy link
Contributor

Choose a reason for hiding this comment

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

should be using SYSBUILD LOCAL flags

build_info(application source-dir VALUE ${APPLICATION_SOURCE_DIR})
build_info(application configuration-dir VALUE ${APPLICATION_CONFIG_DIR})
74 changes: 74 additions & 0 deletions cmake/modules/extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ include(CheckCXXCompilerFlag)
# 1.2. zephyr_library_*
# 1.2.1 zephyr_interface_library_*
# 1.3. generate_inc_*
# 1.3.1 generate_config_*
# 1.4. board_*
# 1.5. Misc.
# 2. Kconfig-aware extensions
Expand Down Expand Up @@ -739,6 +740,79 @@ function(generate_inc_file_for_target
generate_inc_file_for_gen_target(${target} ${source_file} ${generated_file} ${generated_target_name} ${ARGN})
endfunction()

# 1.3.1 generate_config_*

# These functions are needed if a configuration file is generated
# from a user supplied yaml file.
#
function(generate_config_file
source_file # The yaml source file to be converted to config data
Copy link
Contributor

Choose a reason for hiding this comment

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

cmake indent is 2 spaces, also the functions are not documented like this in CMake and it goes in the bit above, see https://github.com/zephyrproject-rtos/zephyr/blob/main/cmake/modules/extensions.cmake#L1615 for an example

generated_file # The generated file
yaml_to_config_script # Script that generates the config
)
add_custom_command(
OUTPUT ${generated_file}
COMMAND
${PYTHON_EXECUTABLE}
${yaml_to_config_script}
${ARGN} # Extra arguments are passed to the script
< ${source_file}
> ${generated_file}
DEPENDS ${source_file}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endfunction()

function(generate_config_file_for_gen_target
target # The cmake target that depends on the generated file
source_file # The yaml source file to be converted to config data
generated_file # The generated file
gen_target # The generated file target we depend on
yaml_to_config_script # Script that generates the config
# Any additional arguments are passed on to script
)

generate_config_file(${source_file} ${generated_file} ${yaml_to_config_script} ${ARGN})

# Ensure 'generated_file' is generated before 'target' by creating a
# dependency between the two targets

add_dependencies(${target} ${gen_target})
endfunction()

function(generate_config_file_for_target
target # The cmake target that depends on the generated file
source_file # The yaml source file to be converted to config data
generated_file # The generated file
yaml_to_config_script # Script that generates the config
# Any additional arguments are passed on to script
)

# Ensure 'generated_file' is generated before 'target' by creating a
# 'custom_target' for it and setting up a dependency between the two
# targets

# But first create a unique name for the custom target
generate_unique_target_name_from_filename(${generated_file} generated_target_name)

add_custom_target(${generated_target_name} DEPENDS ${generated_file})
generate_config_file_for_gen_target(${target} ${source_file} ${generated_file}
${generated_target_name} ${yaml_to_config_script} ${ARGN})
endfunction()

function(network_generate_config_file_for_target
target # The cmake target that depends on the generated file
source_file # The yaml source file to be converted to config data
)

set(generated_file ${ZEPHYR_BINARY_DIR}/include/generated/network_config.inc)
set(yaml_to_config_script ${ZEPHYR_BASE}/scripts/net/net-yaml-config.py)
set(yaml_schema_file ${ZEPHYR_BASE}/scripts/schemas/network-configuration-schema.yml)

generate_config_file_for_target(${target} ${source_file} ${generated_file}
${yaml_to_config_script} ${yaml_schema_file})
endfunction()

# 1.4. board_*
#
# This section is for extensions related to Zephyr board handling.
Expand Down
14 changes: 14 additions & 0 deletions cmake/modules/kernel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,17 @@ if("${CMAKE_EXTRA_GENERATOR}" STREQUAL "Eclipse CDT4")
include(${ZEPHYR_BASE}/cmake/ide/eclipse_cdt4_generator_amendment.cmake)
eclipse_cdt4_generator_amendment(1)
endif()

if(CONFIG_NET_CONFIG_SETTINGS)
# If network configuration library is enabled, check if the yaml file
# is present and use it to generate an initial configuration. Otherwise
# use the .config file to generate the initial configuration.
if(NOT NET_CONFIG_FILE)
set(NET_CONFIG_FILE ${APPLICATION_SOURCE_DIR}/network-config.yaml)
endif()
if(EXISTS ${NET_CONFIG_FILE})
network_generate_config_file_for_target(app ${NET_CONFIG_FILE})
else()
network_generate_config_file_for_target(app ${DOTCONFIG})
endif()
endif()
1 change: 1 addition & 0 deletions doc/connectivity/networking/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ operation of the stacks and how they were implemented.
overview.rst
net-stack-architecture.rst
net_config_guide.rst
network_config.rst
networking_with_host.rst
network_monitoring.rst
network_tracing.rst
Expand Down
Loading
Loading