feat: add component_source property to component targets

This commit is contained in:
Fu Hanxi
2025-01-21 16:45:29 +08:00
parent aedf0408a6
commit 539971de6c
9 changed files with 254 additions and 42 deletions
+23 -3
View File
@@ -223,7 +223,7 @@ function(__build_init idf_path)
if(IS_DIRECTORY ${component_dir})
__component_dir_quick_check(is_component ${component_dir})
if(is_component)
__component_add(${component_dir} ${prefix})
__component_add(${component_dir} ${prefix} "idf_components")
endif()
endif()
endforeach()
@@ -253,9 +253,29 @@ endfunction()
# during build (see the COMPONENTS argument description for command idf_build_process)
#
# @param[in] component_dir directory of the component
# @param[in, optional] component_source source of the component, defaults to "project_components"
function(idf_build_component component_dir)
idf_build_get_property(prefix __PREFIX)
__component_add(${component_dir} ${prefix} 0)
# if argvc is 1, then component_source is not specified
# this should only happen when users call this function directly
if(${ARGC} EQUAL 1)
set(component_source "project_components")
else()
set(component_source ${ARGV1})
endif()
# component_source must be one of the following (sorted by the override order):
set(valid_component_sources "idf_components"
"project_managed_components"
"project_extra_components"
"project_components")
if(NOT component_source IN_LIST valid_component_sources)
message(FATAL_ERROR "Invalid component source '${component_source}'.")
endif()
__component_add(${component_dir} ${prefix} ${component_source})
endfunction()
#
@@ -449,7 +469,7 @@ endfunction()
# if PROJECT_DIR is set and CMAKE_SOURCE_DIR/sdkconfig if not
# @param[in, optional] SDKCONFIG_DEFAULTS (single value) config defaults file to use for the build; defaults
# to none (Kconfig defaults or previously generated config are used)
# @param[in, optional] BUILD_DIR (single value) directory for build artifacts; defautls to CMAKE_BINARY_DIR
# @param[in, optional] BUILD_DIR (single value) directory for build artifacts; defaults to CMAKE_BINARY_DIR
# @param[in, optional] COMPONENTS (multivalue) select components to process among the components
# known by the build system
# (added via `idf_build_component`). This argument is used to trim the build.