mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 10:40:47 +03:00
feat(cmakev2): expose Build system v1 build properties under shim
Under __V1_COMPAT_SHIM, populate EXECUTABLE, EXECUTABLE_NAME, and BUILD_COMPONENTS build properties in __project_default(), and propagate project_elf to the caller scope. Relax the BUILD_COMPONENTS query gate in build.cmake so component code that uses idf_build_get_property(... BUILD_COMPONENTS) keeps working. Co-authored-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
committed by
BOT
co-authored by
Frantisek Hrbata
parent
3b16b7a7fa
commit
797d8deb5b
@@ -83,7 +83,12 @@ function(idf_build_get_property variable property)
|
||||
cmake_parse_arguments(ARG "${options}" "${one_value}" "${multi_value}" ${ARGN})
|
||||
|
||||
if("${property}" STREQUAL BUILD_COMPONENTS)
|
||||
idf_die("Build property 'BUILD_COMPONENTS' is not supported")
|
||||
# BUILD_COMPONENTS is populated by the Build system v1 compatibility
|
||||
# shim; reject only when running as a native Build system v2 project.
|
||||
idf_build_get_property(_v1_compat __V1_COMPAT_SHIM)
|
||||
if(NOT _v1_compat)
|
||||
idf_die("Build property 'BUILD_COMPONENTS' is not supported")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(genexpr)
|
||||
|
||||
@@ -755,6 +755,40 @@ function(__project_default)
|
||||
COMPONENTS ${root_components}
|
||||
MAPFILE_TARGET "${executable}_mapfile")
|
||||
|
||||
# In Build system v1, the ``project_elf`` variable (set to
|
||||
# "${project_name}.elf") is used by several app CMakeLists.txt files to add
|
||||
# linker flags after project(). In Build system v2 the executable target
|
||||
# is just "${executable}" (the .elf suffix is an output property, not part
|
||||
# of the target name). Propagate it to the caller's scope so existing
|
||||
# code keeps working.
|
||||
set(project_elf "${executable}" PARENT_SCOPE)
|
||||
|
||||
# Provide Build system v1-compatible build properties so that existing
|
||||
# test apps and project CMakeLists.txt files that query EXECUTABLE or
|
||||
# BUILD_COMPONENTS continue to work when built through the shim.
|
||||
idf_build_get_property(v1_compat __V1_COMPAT_SHIM)
|
||||
if(v1_compat)
|
||||
idf_build_set_property(EXECUTABLE "${executable}")
|
||||
idf_build_set_property(EXECUTABLE_NAME "${executable}")
|
||||
|
||||
# BUILD_COMPONENTS: in Build system v1 this is the set of components
|
||||
# actually processed during the build (COMPONENTS + their transitive
|
||||
# REQUIRES within the restricted scope). Use LIBRARY_COMPONENTS_LINKED
|
||||
# from the Build system v2 library target which reflects the actual
|
||||
# list of components linked, plus the architecture component which
|
||||
# Build system v1 always includes but Build system v2 does not track
|
||||
# as a linked library.
|
||||
get_target_property(library ${executable} LIBRARY_INTERFACE)
|
||||
if(library)
|
||||
idf_library_get_property(linked_components "${library}" LIBRARY_COMPONENTS_LINKED)
|
||||
idf_build_get_property(target_arch IDF_TARGET_ARCH)
|
||||
if(target_arch AND NOT target_arch IN_LIST linked_components)
|
||||
list(APPEND linked_components ${target_arch})
|
||||
endif()
|
||||
idf_build_set_property(BUILD_COMPONENTS "${linked_components}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CONFIG_APP_BUILD_GENERATE_BINARIES AND TARGET idf::esptool_py)
|
||||
# Is it possible to have a configuration where
|
||||
# CONFIG_APP_BUILD_GENERATE_BINARIES is not set?
|
||||
|
||||
Reference in New Issue
Block a user