Skip to content
Draft
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)
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 @@
# 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 @@ -563,7 +564,7 @@
string(MD5 uniqueness "${ARGV}")
set(lib_name options_interface_lib_${uniqueness})

if (NOT TARGET ${lib_name})

Check failure on line 567 in cmake/modules/extensions.cmake

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CMakeStyle

cmake/modules/extensions.cmake:567 CMakeStyle
# Create the unique target only if it doesn't exist.
add_library( ${lib_name} INTERFACE)
target_compile_options(${lib_name} INTERFACE ${item} ${ARGN})
Expand Down Expand Up @@ -739,6 +740,79 @@
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
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/net_init_config.inc)
set(yaml_to_config_script ${ZEPHYR_BASE}/scripts/net/net-yaml-config.py)
set(yaml_schema_file ${ZEPHYR_BASE}/scripts/schemas/net-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 All @@ -758,7 +832,7 @@

set(TYPES "FLASH" "DEBUG" "SIM" "ROBOT")
function(_board_check_runner_type type) # private helper
if (NOT "${type}" IN_LIST TYPES)

Check failure on line 835 in cmake/modules/extensions.cmake

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CMakeStyle

cmake/modules/extensions.cmake:835 CMakeStyle
message(FATAL_ERROR "invalid type ${type}; should be one of: ${TYPES}")
endif()
endfunction()
Expand All @@ -779,7 +853,7 @@
# the name of a runner.
function(board_set_runner type runner)
_board_check_runner_type(${type})
if (DEFINED BOARD_${type}_RUNNER)

Check failure on line 856 in cmake/modules/extensions.cmake

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CMakeStyle

cmake/modules/extensions.cmake:856 CMakeStyle
message(STATUS "overriding ${type} runner ${BOARD_${type}_RUNNER}; it's now ${runner}")
endif()
set(BOARD_${type}_RUNNER ${runner} PARENT_SCOPE)
Expand Down Expand Up @@ -1335,7 +1409,7 @@

# Clear destination files if this is the first time the function is called.
get_property(cleared GLOBAL PROPERTY snippet_files_cleared)
if (NOT DEFINED cleared)

Check failure on line 1412 in cmake/modules/extensions.cmake

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CMakeStyle

cmake/modules/extensions.cmake:1412 CMakeStyle
file(WRITE ${sections_path} "")
file(WRITE ${rom_sections_path} "")
file(WRITE ${ram_sections_path} "")
Expand All @@ -1356,7 +1430,7 @@
endif()

# Choose destination file, based on the <location> argument.
if ("${location}" STREQUAL "SECTIONS")

Check failure on line 1433 in cmake/modules/extensions.cmake

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CMakeStyle

cmake/modules/extensions.cmake:1433 CMakeStyle
set(snippet_path "${sections_path}")
elseif("${location}" STREQUAL "ROM_SECTIONS")
set(snippet_path "${rom_sections_path}")
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_INIT_CONFIG_FILE)
set(NET_INIT_CONFIG_FILE ${APPLICATION_SOURCE_DIR}/net-init-config.yaml)
endif()
if(EXISTS ${APPLICATION_SOURCE_DIR}/net-init-config.yaml)
network_generate_config_file_for_target(app ${NET_INIT_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
net_init_config.rst
networking_with_host.rst
network_monitoring.rst
network_tracing.rst
Expand Down
Loading
Loading