feat(cmakev2): Reorganise build system initialization

This commit updates the order of initialization for build system v2. All
non-project initializations are handled in idf.cmake and all
project-specific initializations are now moved to idf_project_init().
This commit is contained in:
Sudeep Mohanty
2025-11-04 07:48:14 +01:00
committed by Frantisek Hrbata
parent 5157690109
commit f284381225
2 changed files with 25 additions and 32 deletions
+5 -32
View File
@@ -587,38 +587,11 @@ __init_toolchain()
# Enable ccache if requested.
__init_ccache()
# Discover and initialize components.
__init_components()
#[[
# Generate initial sdkconfig with discovered components.
__generate_sdkconfig()
# Initialize the component manager and fetch components in a loop
__fetch_components_from_registry()
# 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}")
# Initialize the target architecture based on the configuration. Ensure this is
# done after including the sdkconfig.
__init_idf_target_arch()
#[[ TODO
Many of the following things are already implemented in PoC !38337, but they
need to be reviewed.
* Enable ccache if requested and available.
There may be additional steps. We should initialize everything necessary before
calling the ``project()`` function, as well as any global settings that cannot be
modified later.
At this point, the build system infrastructure is ready.
Project-specific operations (component discovery, Kconfig generation,
component manager, etc.) are handled in idf_project_init() after the
project() call.
#]]
+20
View File
@@ -581,6 +581,26 @@ macro(idf_project_init)
# Create global flash targets.
__create_project_flash_targets()
# Discover and initialize components
__init_components()
# Generate initial sdkconfig with discovered components
__generate_sdkconfig()
# Initialize the component manager and fetch components in a loop
__fetch_components_from_registry()
# 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}")
# Initialize the target architecture based on the configuration
# Ensure this is done after including the sdkconfig.
__init_idf_target_arch()
# Include all project_include.cmake files for the components that have
# been discovered.
idf_build_get_property(component_names COMPONENTS_DISCOVERED)