mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-03 03:31:41 +03:00
fix(ulp): use builtin v2 project for legacy embed
Route ulp_embed_binary() through a built-in CMake v2 default ULP project instead of generating a compatibility project with a synthetic main component. Attach legacy ULP sources directly to the ULP executable, pass the parent component include view through the existing ULP_S_SOURCES/COMPONENT_* channel, and remove the generated legacy project templates plus the component path ownership validation bypass they required. Update the build-system coverage to assert that the builtin child project builds and rebuilds when parent-owned ULP sources change.
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
if(IDF_BUILD_V2)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/CMakeLists_v2.txt)
|
||||
return()
|
||||
endif()
|
||||
|
||||
include(${IDF_PATH}/tools/cmake/idf.cmake)
|
||||
project(${ULP_APP_NAME})
|
||||
add_executable(${ULP_APP_NAME})
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
# CMake v2 default ULP project for ulp_embed_binary() callers. The ULP runtime
|
||||
# is built from the ulp component graph, and the legacy source list is attached
|
||||
# directly to the executable, matching the CMake v1 link semantics.
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/ulp_project.cmake)
|
||||
|
||||
if("${ULP_TYPE}" STREQUAL "fsm")
|
||||
project(${ULP_APP_NAME} ASM)
|
||||
else()
|
||||
project(${ULP_APP_NAME} C CXX ASM)
|
||||
endif()
|
||||
|
||||
ulp_project_init()
|
||||
|
||||
# A single executable is built, so DEFERRED optional-requires resolution is
|
||||
# safe and keeps the linked component set minimal.
|
||||
idf_build_set_property(IDF_COMPONENT_OPTIONAL_REQUIRES_MODE DEFERRED)
|
||||
|
||||
set(executable_args COMPONENTS ulp)
|
||||
if(NOT BUILD_FSM)
|
||||
list(APPEND executable_args MAPFILE_TARGET ${ULP_APP_NAME}_mapfile)
|
||||
endif()
|
||||
ulp_build_executable(${ULP_APP_NAME} ${executable_args})
|
||||
|
||||
target_sources(${ULP_APP_NAME} PRIVATE ${ULP_S_SOURCES})
|
||||
if(ULP_PARENT_SDKCONFIG_HEADER)
|
||||
# Legacy ulp_embed_binary() sources are authored against the parent app's
|
||||
# sdkconfig, including project-local Kconfig.projbuild symbols.
|
||||
get_filename_component(parent_sdkconfig_dir "${ULP_PARENT_SDKCONFIG_HEADER}" DIRECTORY)
|
||||
target_include_directories(${ULP_APP_NAME} BEFORE PRIVATE "${parent_sdkconfig_dir}")
|
||||
endif()
|
||||
if(COMPONENT_INCLUDES)
|
||||
target_include_directories(${ULP_APP_NAME} PRIVATE ${COMPONENT_INCLUDES})
|
||||
endif()
|
||||
# CMake v1 exposed COMPONENT_DIR only to the FSM assembly preprocessing, not to
|
||||
# the compilation of ULP C sources. The v2 FSM toolchain preprocesses inside
|
||||
# the compile rule, which takes its include flags from the target, so keep the
|
||||
# directory on the target for FSM builds only.
|
||||
if(BUILD_FSM AND COMPONENT_DIR)
|
||||
target_include_directories(${ULP_APP_NAME} PRIVATE ${COMPONENT_DIR})
|
||||
endif()
|
||||
|
||||
if(DEFINED ULP_VAR_PREFIX AND NOT "${ULP_VAR_PREFIX}" STREQUAL "")
|
||||
ulp_build_binary(${ULP_APP_NAME} PREFIX ${ULP_VAR_PREFIX})
|
||||
else()
|
||||
ulp_build_binary(${ULP_APP_NAME})
|
||||
endif()
|
||||
|
||||
idf_build_generate_metadata(EXECUTABLE ${ULP_APP_NAME})
|
||||
if(TARGET "${ULP_APP_NAME}_mapfile")
|
||||
idf_create_size_report("${ULP_APP_NAME}_mapfile" TARGET size)
|
||||
endif()
|
||||
idf_build_generate_depgraph("${ULP_APP_NAME}")
|
||||
@@ -1,10 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
include(${IDF_PATH}/components/ulp/cmake/ulp_project.cmake)
|
||||
if("${ULP_TYPE}" STREQUAL "fsm")
|
||||
project(${IDF_DEFAULT_PROJECT_NAME} ASM)
|
||||
else()
|
||||
project(${IDF_DEFAULT_PROJECT_NAME} C CXX ASM)
|
||||
endif()
|
||||
|
||||
ulp_project_default()
|
||||
@@ -1,17 +0,0 @@
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/ulp_legacy_inputs.cmake)
|
||||
|
||||
if(ULP_LEGACY_PARENT_SDKCONFIG_HEADER)
|
||||
add_compile_options(-include "${ULP_LEGACY_PARENT_SDKCONFIG_HEADER}")
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS ${ULP_LEGACY_SOURCES}
|
||||
INCLUDE_DIRS ${ULP_LEGACY_INCLUDE_DIRS}
|
||||
REQUIRES ulp
|
||||
# Match CMake v1-compatible idf_component_register(WHOLE_ARCHIVE)
|
||||
# semantics used by existing ULP test/example components.
|
||||
WHOLE_ARCHIVE)
|
||||
# This generated compatibility component intentionally uses parent app sources
|
||||
# and include directories. Skip __component_validation_check_sources() and
|
||||
# __component_validation_check_include_dirs(), which validate native CMake v2
|
||||
# component ownership in tools/cmakev2/component_validation.cmake.
|
||||
idf_component_set_property("${COMPONENT_NAME}" __SKIP_COMPONENT_PATH_OWNERSHIP_VALIDATION YES)
|
||||
@@ -1,16 +0,0 @@
|
||||
set(ULP_LEGACY_SOURCES
|
||||
@ULP_LEGACY_SOURCES@
|
||||
)
|
||||
|
||||
set(ULP_LEGACY_INCLUDE_DIR_CANDIDATES
|
||||
@ULP_LEGACY_INCLUDE_DIR_CANDIDATES@
|
||||
)
|
||||
|
||||
set(ULP_LEGACY_PARENT_SDKCONFIG_HEADER [=[@ULP_LEGACY_PARENT_SDKCONFIG_HEADER@]=])
|
||||
|
||||
set(ULP_LEGACY_INCLUDE_DIRS)
|
||||
foreach(include IN LISTS ULP_LEGACY_INCLUDE_DIR_CANDIDATES)
|
||||
if(IS_DIRECTORY "${include}")
|
||||
list(APPEND ULP_LEGACY_INCLUDE_DIRS "${include}")
|
||||
endif()
|
||||
endforeach()
|
||||
Reference in New Issue
Block a user