mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
feat(cmakev2): Add build event callback framework for components
Introduce a callback mechanism that lets components register CMake functions to be called at specific points in the build lifecycle. Currently, this framework only supports registering callbacks to be called after the executable target is created, i.e, the POST_ELF phase of the build but before the binary target is created.
This commit is contained in:
@@ -112,6 +112,32 @@ function(__dump_build_properties)
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
#[[
|
||||
__idf_build_dispatch_build_event(<event> <target>)
|
||||
|
||||
*event[in]*
|
||||
|
||||
Build event name. Currently only ``POST_ELF`` is supported. Other build
|
||||
events may be extended when required.
|
||||
|
||||
*target[in]*
|
||||
|
||||
Name of the primary CMake target at this event point. Passed as the
|
||||
sole argument to every registered callback so that callbacks can
|
||||
operate on the correct target without querying build properties.
|
||||
For ``POST_ELF`` this is the executable target name.
|
||||
|
||||
Internal dispatcher called by the build system at well-defined lifecycle
|
||||
points. Invokes every CMake function registered for
|
||||
``event`` via ``idf_component_register_build_event_callback``.
|
||||
#]]
|
||||
function(__idf_build_dispatch_build_event event target)
|
||||
idf_build_get_property(callbacks "__BUILD_EVENT_CALLBACKS_${event}")
|
||||
foreach(cb IN LISTS callbacks)
|
||||
cmake_language(CALL "${cb}" "${target}")
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
#[[
|
||||
__get_library_interface_or_die(LIBRARY <library>
|
||||
OUTPUT <variable>)
|
||||
@@ -608,6 +634,9 @@ function(idf_build_executable executable)
|
||||
endif()
|
||||
|
||||
set_target_properties(${executable} PROPERTIES LIBRARY_INTERFACE ${library})
|
||||
|
||||
# Dispatch POST_ELF event once the executable target exists
|
||||
__idf_build_dispatch_build_event(POST_ELF "${executable}")
|
||||
endfunction()
|
||||
|
||||
#[[
|
||||
|
||||
Reference in New Issue
Block a user