mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 18:50:34 +03:00
feat(cmakev2/kconfig): Added __init_kconfig() and initial Kconfig properties
This commit adds the tools/cmakev2/kconfig.cmake file for Kconfig processing. The file provides the following functions: - __init_kconfig(): Placeholder to initialize Kconfig build properties, collect kconfig files and generate the initial sdkconfig. - __generate_sdkconfig(): Placeholder to generate sdkconfig output files.
This commit is contained in:
committed by
Frantisek Hrbata
parent
c657466c78
commit
9e90c05d4d
+27
-37
@@ -15,6 +15,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/../cmake/version.cmake)
|
||||
|
||||
include(component)
|
||||
include(build)
|
||||
include(kconfig)
|
||||
|
||||
#[[
|
||||
__init_idf_path()
|
||||
@@ -92,41 +93,6 @@ function(__init_python)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#[[
|
||||
__init_sdkconfig_files()
|
||||
|
||||
Set the SDKCONFIG and SDKCONFIG_DEFAULTS build properties using environment
|
||||
variables, CMake cache variables, or default values.
|
||||
#]]
|
||||
function(__init_sdkconfig_files)
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/sdkconfig.defaults")
|
||||
set(sdkconfig_defaults "${CMAKE_SOURCE_DIR}/sdkconfig.defaults")
|
||||
else()
|
||||
set(sdkconfig_defaults "")
|
||||
endif()
|
||||
|
||||
__get_default_value(VARIABLE SDKCONFIG
|
||||
DEFAULT "${CMAKE_SOURCE_DIR}/sdkconfig"
|
||||
OUTPUT sdkconfig)
|
||||
__get_default_value(VARIABLE SDKCONFIG_DEFAULTS
|
||||
DEFAULT "${sdkconfig_defaults}"
|
||||
OUTPUT sdkconfig_defaults)
|
||||
|
||||
__get_absolute_paths(PATHS "${sdkconfig}" OUTPUT sdkconfig)
|
||||
__get_absolute_paths(PATHS "${sdkconfig_defaults}" OUTPUT sdkconfig_defaults)
|
||||
|
||||
set(sdkconfig_defaults_checked "")
|
||||
foreach(sdkconfig_default ${sdkconfig_defaults})
|
||||
if(NOT EXISTS "${sdkconfig_default}")
|
||||
idf_die("SDKCONFIG_DEFAULTS '${sdkconfig_default}' does not exist.")
|
||||
endif()
|
||||
list(APPEND sdkconfig_defaults_checked ${sdkconfig_default})
|
||||
endforeach()
|
||||
|
||||
idf_build_set_property(SDKCONFIG "${sdkconfig}")
|
||||
idf_build_set_property(SDKCONFIG_DEFAULTS "${sdkconfig_defaults_checked}")
|
||||
endfunction()
|
||||
|
||||
#[[
|
||||
__init_idf_target()
|
||||
|
||||
@@ -356,6 +322,12 @@ add_library(idf_build_properties INTERFACE)
|
||||
# Set build system prefix for component targets.
|
||||
idf_build_set_property(PREFIX "idf")
|
||||
|
||||
# Set project directory property.
|
||||
idf_build_set_property(PROJECT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
# Set build directory property.
|
||||
idf_build_set_property(BUILD_DIR "${CMAKE_BINARY_DIR}")
|
||||
|
||||
# Initialize IDF_PATH and set it as a global and environmental variable, as
|
||||
# well as a build property.
|
||||
__init_idf_path()
|
||||
@@ -363,8 +335,8 @@ __init_idf_path()
|
||||
# Determine the Python interpreter and check package dependencies if necessary.
|
||||
__init_python()
|
||||
|
||||
# Set SDKCONFIG and SDKCONFIG_DEFAULTS build properties.
|
||||
__init_sdkconfig_files()
|
||||
# Initialize Kconfig system infrastructure.
|
||||
__init_kconfig()
|
||||
|
||||
# Set IDF_TARGET.
|
||||
__init_idf_target()
|
||||
@@ -375,6 +347,24 @@ __init_toolchain()
|
||||
# Discover and initialize components.
|
||||
__init_components()
|
||||
|
||||
# Generate initial sdkconfig with discovered components.
|
||||
__generate_sdkconfig()
|
||||
|
||||
# TODO: Invoke component manager with initial sdkconfig.
|
||||
# We need to re-collect and re-generate sdkconfig with managed components.
|
||||
# This will be done iteratively until the component manager resolves all sdkconfig
|
||||
# related dependencies.
|
||||
|
||||
# Create Kconfig targets
|
||||
__create_kconfig_targets()
|
||||
|
||||
# Include sdkconfig.cmake
|
||||
idf_build_get_property(sdkconfig_cmake __SDKCONFIG_CMAKE)
|
||||
if(NOT EXISTS "${sdkconfig_cmake}")
|
||||
idf_die("sdkconfig.cmake file not found.")
|
||||
endif()
|
||||
include("${sdkconfig_cmake}")
|
||||
|
||||
#[[ TODO
|
||||
|
||||
Many of the following things are already implemented in PoC !38337, but they
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
# SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# Kconfig utilities for ESP-IDF CMake build system v2
|
||||
# This module provides functions for Kconfig processing and sdkconfig generation
|
||||
|
||||
include_guard(GLOBAL)
|
||||
|
||||
include(utilities)
|
||||
include(build)
|
||||
include(component)
|
||||
|
||||
#[[
|
||||
__init_kconfig()
|
||||
|
||||
Initialize the Kconfig system infrastructure for the build.
|
||||
This function performs the Kconfig initialization and setup by:
|
||||
1. Setting up SDKCONFIG and SDKCONFIG_DEFAULTS build properties
|
||||
2. Setting up ESP-IDF root Kconfig files and config directory
|
||||
3. Creating the default config directory
|
||||
|
||||
This should be called after component discovery but before component manager.
|
||||
Note: Regular component Kconfig files are collected during component discovery.
|
||||
#]]
|
||||
function(__init_kconfig)
|
||||
idf_build_get_property(idf_path IDF_PATH)
|
||||
|
||||
# Initialize SDKCONFIG and SDKCONFIG_DEFAULTS build properties using environment
|
||||
# variables, CMake cache variables, or default values.
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/sdkconfig.defaults")
|
||||
set(sdkconfig_defaults "${CMAKE_SOURCE_DIR}/sdkconfig.defaults")
|
||||
else()
|
||||
set(sdkconfig_defaults "")
|
||||
endif()
|
||||
|
||||
__get_default_value(VARIABLE SDKCONFIG
|
||||
DEFAULT "${CMAKE_SOURCE_DIR}/sdkconfig"
|
||||
OUTPUT sdkconfig)
|
||||
__get_default_value(VARIABLE SDKCONFIG_DEFAULTS
|
||||
DEFAULT "${sdkconfig_defaults}"
|
||||
OUTPUT sdkconfig_defaults)
|
||||
|
||||
__get_absolute_paths(PATHS "${sdkconfig}" OUTPUT sdkconfig)
|
||||
__get_absolute_paths(PATHS "${sdkconfig_defaults}" OUTPUT sdkconfig_defaults)
|
||||
|
||||
set(sdkconfig_defaults_checked "")
|
||||
foreach(sdkconfig_default ${sdkconfig_defaults})
|
||||
if(NOT EXISTS "${sdkconfig_default}")
|
||||
idf_die("SDKCONFIG_DEFAULTS '${sdkconfig_default}' does not exist.")
|
||||
endif()
|
||||
list(APPEND sdkconfig_defaults_checked ${sdkconfig_default})
|
||||
endforeach()
|
||||
|
||||
idf_build_set_property(SDKCONFIG "${sdkconfig}")
|
||||
idf_build_set_property(SDKCONFIG_DEFAULTS "${sdkconfig_defaults_checked}")
|
||||
|
||||
# Setup ESP-IDF root Kconfig and sdkconfig.rename files.
|
||||
idf_build_set_property(__ROOT_KCONFIG "${idf_path}/Kconfig")
|
||||
idf_build_set_property(__ROOT_SDKCONFIG_RENAME "${idf_path}/sdkconfig.rename")
|
||||
|
||||
# Setup and create the default config directory.
|
||||
idf_build_get_property(build_dir BUILD_DIR)
|
||||
set(config_dir "${build_dir}/config")
|
||||
file(MAKE_DIRECTORY "${config_dir}")
|
||||
idf_build_set_property(CONFIG_DIR "${config_dir}")
|
||||
endfunction()
|
||||
|
||||
#[[
|
||||
__generate_sdkconfig()
|
||||
|
||||
This function performs the complete Kconfig generation process:
|
||||
1. Collect Kconfig files from discovered components
|
||||
2. Collect Kconfig files from bootloader components
|
||||
3. Set up the Kconfig environment with all collected files
|
||||
4. Generate all output files (sdkconfig.h, sdkconfig.cmake, etc.)
|
||||
#]]
|
||||
function(__generate_sdkconfig)
|
||||
idf_msg("Generating sdkconfig configuration...")
|
||||
|
||||
# Collect Kconfig files from discovered components
|
||||
__consolidate_component_kconfig_files()
|
||||
|
||||
# Collect Kconfig files from bootloader components
|
||||
__collect_kconfig_files_from_bootloader_components()
|
||||
|
||||
# Prepare Kconfig environment using collected files
|
||||
__setup_kconfig_environment()
|
||||
|
||||
# Generate Kconfig outputs
|
||||
__generate_kconfig_outputs()
|
||||
|
||||
idf_msg("Generated sdkconfig configuration")
|
||||
endfunction()
|
||||
Reference in New Issue
Block a user