refactor(ulp): provide a ulp_project.cmake subproject wrapper API

Build ULP full subprojects through a dedicated entry file,
components/ulp/cmake/ulp_project.cmake, that wraps tools/cmakev2/idf.cmake
and layers a small ULP API on top, mirroring the cmakev2 layering:

  ulp_project_init      like idf_project_init (init, detect the ULP type,
                        reset the compile/link options inherited from the app)
  ulp_build_executable  like idf_build_executable, plus the embeddable
                        .bin/.h/.ld artifacts
  ulp_project_default   like idf_project_default (single-executable case)

A child project now includes this one file instead of idf.cmake and calls
these helpers directly, so idf_build_executable is used as-is for the
multi-binary case and the module-path indirection (include(IDFULPProject)
resolved via -DCMAKE_MODULE_PATH) is gone.

As a result:
- IDFULPProjectv2.cmake is removed; its setup moves into the wrapper.
- IDFULPProject.cmake becomes the CMake v1-only entry point.
- The ULP component no longer registers a POST_ELF callback; the binary
  artifacts are produced by ulp_build_executable.
- The v2 full-subproject examples (lp_core, riscv, fsm, multi_binary,
  combined) are updated to the new API.
- The ULP subproject API is documented in build-system-v2.rst.

Also fix a latent bug this exercises: idf_build_library emitted linker
scripts as "-T <name>" relying on a following "-L" search directory. GNU
ld only searches -L directories that precede -T, so the direct
esp32ulp-elf-ld link used for ULP FSM failed to open the script. Emit the
absolute path instead, matching what the CMake v1 ULP build already does.

Finally, replace the parent-argument bypass loop that used to live in
IDFULPProjectv2.cmake with --no-warn-unused-cli on the child configure,
and stop passing the unused IDF_PARENT_BUILD_DIR.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
Frantisek Hrbata
2026-07-15 09:34:05 +09:00
committed by Renz Bagaporo
parent ceaa0b7a3d
commit a9ea4f1105
13 changed files with 233 additions and 142 deletions
+7 -5
View File
@@ -599,12 +599,14 @@ function(idf_build_library library)
# seen before any section-placement script references them.
foreach(script IN LISTS memory_scripts other_scripts)
get_filename_component(script_dir "${script}" DIRECTORY)
# Add linker script directory to the linker search path.
# Add the linker script directory to the linker search path so INCLUDE
# directives inside a script can resolve sibling scripts by name.
target_link_directories("${library}" INTERFACE "${script_dir}")
# Add linker script to link. Use the full path because direct ld
# resolves -T against only the -L directories that came before it, while
# CMake may emit link options before link directories. Keep -L above so
# linker scripts can still INCLUDE siblings by name.
# Add the linker script to the link by absolute path. Passing the full
# path (rather than a bare name resolved via -L) keeps this working for
# direct linker drivers such as the ULP FSM esp32ulp-elf-ld link, where
# the -L search directories follow the -T options on the command line
# and GNU ld therefore does not use them to locate the -T script.
# Regarding the usage of SHELL, see
# https://cmake.org/cmake/help/latest/command/target_link_options.html#option-de-duplication
# Quote the path: SHELL: strings are re-split on spaces, so an unquoted