From 1bec6e09d9d3870c1192c22bc2194ca0f2a00570 Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Tue, 1 Sep 2026 14:51:47 +0200 Subject: [PATCH] refactor(ulp): make the ULP subproject directory explicit components/ulp/cmake holds the project that builds a ULP program. Name it subproject, as the bootloader does. --- .gitlab/ci/rules.yml | 2 +- components/ulp/project_include.cmake | 22 +++++++++---------- .../ulp/{cmake => subproject}/CMakeLists.txt | 0 .../{cmake => subproject}/CMakeLists_v2.txt | 0 .../{cmake => subproject}/IDFULPProject.cmake | 2 +- .../IDFULPProjectCommon.cmake | 7 +++++- .../ulp/{ => subproject}/esp32ulp_mapgen.py | 0 .../preprocess_fsm_asm.cmake | 0 .../toolchain-esp32-ulp.cmake | 0 .../toolchain-esp32s2-ulp.cmake | 0 .../toolchain-esp32s3-ulp.cmake | 0 .../toolchain-lp-core-riscv.cmake | 0 .../toolchain-ulp-riscv.cmake | 0 .../{cmake => subproject}/ulp_project.cmake | 0 .../main/ulp/CMakeLists.txt | 2 +- tools/ci/executable-list.txt | 2 +- .../combined/main/ulp_fsm/CMakeLists.txt | 2 +- .../combined/main/ulp_riscv/CMakeLists.txt | 2 +- .../fsm/main/ulp/CMakeLists.txt | 2 +- .../lp_core/main/ulp/CMakeLists.txt | 2 +- .../multi_binary/main/ulp/CMakeLists.txt | 2 +- .../riscv/main/ulp/CMakeLists.txt | 2 +- tools/test_build_system/buildv2/test_ulp.py | 8 +++---- 23 files changed, 31 insertions(+), 26 deletions(-) rename components/ulp/{cmake => subproject}/CMakeLists.txt (100%) rename components/ulp/{cmake => subproject}/CMakeLists_v2.txt (100%) rename components/ulp/{cmake => subproject}/IDFULPProject.cmake (99%) rename components/ulp/{cmake => subproject}/IDFULPProjectCommon.cmake (92%) rename components/ulp/{ => subproject}/esp32ulp_mapgen.py (100%) rename components/ulp/{cmake => subproject}/preprocess_fsm_asm.cmake (100%) rename components/ulp/{cmake => subproject}/toolchain-esp32-ulp.cmake (100%) rename components/ulp/{cmake => subproject}/toolchain-esp32s2-ulp.cmake (100%) rename components/ulp/{cmake => subproject}/toolchain-esp32s3-ulp.cmake (100%) rename components/ulp/{cmake => subproject}/toolchain-lp-core-riscv.cmake (100%) rename components/ulp/{cmake => subproject}/toolchain-ulp-riscv.cmake (100%) rename components/ulp/{cmake => subproject}/ulp_project.cmake (100%) diff --git a/.gitlab/ci/rules.yml b/.gitlab/ci/rules.yml index dc7bda7bf8b..24cd2ca4291 100644 --- a/.gitlab/ci/rules.yml +++ b/.gitlab/ci/rules.yml @@ -52,7 +52,7 @@ - ".gitlab/ci/host-test.yml" - "components/ulp/ld/**/*" - - "components/ulp/cmake/**/*" + - "components/ulp/subproject/**/*" - "components/ulp/CMakeLists*.txt" - "components/ulp/component_ulp_common.cmake" - "components/ulp/project_include.cmake" diff --git a/components/ulp/project_include.cmake b/components/ulp/project_include.cmake index 7ef3b4d7ea4..a5662f6442b 100644 --- a/components/ulp/project_include.cmake +++ b/components/ulp/project_include.cmake @@ -10,7 +10,7 @@ function(__setup_ulp_project app_name project_path prefix prefix_append_bin_name s_sources exp_dep_srcs linker_script) if(NOT CMAKE_BUILD_EARLY_EXPANSION) - set(ulp_cmake_dir "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/cmake") + set(ulp_subproject_dir "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/subproject") set(sources "") spaces2list(s_sources) foreach(source ${s_sources}) @@ -95,7 +95,7 @@ function(__setup_ulp_project app_name project_path prefix prefix_append_bin_name "Only FSM type is available for ULP on this target.") endif() endif() - set(TOOLCHAIN_FLAG ${ulp_cmake_dir}/toolchain-${idf_target}-ulp.cmake) + set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/toolchain-${idf_target}-ulp.cmake) set(ULP_IS_RISCV OFF) elseif(IDF_TARGET STREQUAL "esp32s2" OR IDF_TARGET STREQUAL "esp32s3") # If both FSM and RISC-V are enabled in sdkconfig and a TYPE was @@ -105,21 +105,21 @@ function(__setup_ulp_project app_name project_path prefix prefix_append_bin_name message(STATUS "Both RISCV and FSM are enabled, using '${type}' toolchain for ${app_name} ULP project.") string(TOLOWER "${type}" type_lower) if(type_lower STREQUAL "riscv") - set(TOOLCHAIN_FLAG ${ulp_cmake_dir}/toolchain-ulp-riscv.cmake) + set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/toolchain-ulp-riscv.cmake) elseif(type_lower STREQUAL "fsm") - set(TOOLCHAIN_FLAG ${ulp_cmake_dir}/toolchain-${idf_target}-ulp.cmake) + set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/toolchain-${idf_target}-ulp.cmake) else() message(FATAL_ERROR "Invalid ULP_TYPE '${type}'; expected 'fsm' or 'riscv'.") endif() else() if(CONFIG_ULP_COPROC_TYPE_RISCV STREQUAL "y") - set(TOOLCHAIN_FLAG ${ulp_cmake_dir}/toolchain-ulp-riscv.cmake) + set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/toolchain-ulp-riscv.cmake) else() - set(TOOLCHAIN_FLAG ${ulp_cmake_dir}/toolchain-${idf_target}-ulp.cmake) + set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/toolchain-${idf_target}-ulp.cmake) endif() endif() elseif(CONFIG_ULP_COPROC_TYPE_LP_CORE) - set(TOOLCHAIN_FLAG ${ulp_cmake_dir}/toolchain-lp-core-riscv.cmake) + set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/toolchain-lp-core-riscv.cmake) endif() set(ulp_project_args) @@ -133,7 +133,7 @@ function(__setup_ulp_project app_name project_path prefix prefix_append_bin_name -DIDF_DEFAULT_PROJECT_NAME=${app_name} -DULP_APP_NAME=${app_name} -DIDF_BUILD_V2=y - -DCMAKE_MODULE_PATH=${ulp_cmake_dir} + -DCMAKE_MODULE_PATH=${ulp_subproject_dir} # Internal marker for ULP child component graphs. Only the # IDF_BUILD_V2 path sets it for now. -D__ULP_BUILDV2=1 @@ -176,7 +176,7 @@ function(__setup_ulp_project app_name project_path prefix prefix_append_bin_name -DSDKCONFIG_HEADER=${SDKCONFIG_HEADER} -DSDKCONFIG_CMAKE=${SDKCONFIG_CMAKE} # The v1 ULP child resolves include(IDFULPProject) via the module path. - -DCMAKE_MODULE_PATH=${ulp_cmake_dir}) + -DCMAKE_MODULE_PATH=${ulp_subproject_dir}) endif() externalproject_add(${app_name} @@ -315,9 +315,9 @@ function(ulp_embed_binary app_name s_sources exp_dep_srcs) set(ULP_TYPE "${ulp_resolved_type}") endif() __resolve_lp_core_linker("${ULP_LINKER_LAYOUT}" "${ulp_resolved_type}" LP_CORE_LINKER) - set(ulp_cmake_dir "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/cmake") + set(ulp_subproject_dir "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/subproject") - __setup_ulp_project("${app_name}" "${ulp_cmake_dir}" + __setup_ulp_project("${app_name}" "${ulp_subproject_dir}" "${ULP_PREFIX}" FALSE "${ULP_TYPE}" "${app_name}" "${s_sources}" "${exp_dep_srcs}" "${LP_CORE_LINKER}") diff --git a/components/ulp/cmake/CMakeLists.txt b/components/ulp/subproject/CMakeLists.txt similarity index 100% rename from components/ulp/cmake/CMakeLists.txt rename to components/ulp/subproject/CMakeLists.txt diff --git a/components/ulp/cmake/CMakeLists_v2.txt b/components/ulp/subproject/CMakeLists_v2.txt similarity index 100% rename from components/ulp/cmake/CMakeLists_v2.txt rename to components/ulp/subproject/CMakeLists_v2.txt diff --git a/components/ulp/cmake/IDFULPProject.cmake b/components/ulp/subproject/IDFULPProject.cmake similarity index 99% rename from components/ulp/cmake/IDFULPProject.cmake rename to components/ulp/subproject/IDFULPProject.cmake index ed082b1763f..3ae78c21168 100644 --- a/components/ulp/cmake/IDFULPProject.cmake +++ b/components/ulp/subproject/IDFULPProject.cmake @@ -1,5 +1,5 @@ # This is the CMake v1 (legacy) ULP child entry point, used by ulp_embed_binary. -# CMake v2 full-subproject builds include components/ulp/cmake/ulp_project.cmake +# CMake v2 full-subproject builds include components/ulp/subproject/ulp_project.cmake # instead. # # Legacy ULP child projects are plain CMake projects, so the parent-provided diff --git a/components/ulp/cmake/IDFULPProjectCommon.cmake b/components/ulp/subproject/IDFULPProjectCommon.cmake similarity index 92% rename from components/ulp/cmake/IDFULPProjectCommon.cmake rename to components/ulp/subproject/IDFULPProjectCommon.cmake index 8579ccbd396..e11097741c6 100644 --- a/components/ulp/cmake/IDFULPProjectCommon.cmake +++ b/components/ulp/subproject/IDFULPProjectCommon.cmake @@ -1,3 +1,8 @@ +# The directory of this file, captured while it is being processed: +# CMAKE_CURRENT_LIST_DIR inside a function resolves at call time, which is the +# caller's directory, not this one. +set(__ULP_SUBPROJECT_DIR "${CMAKE_CURRENT_LIST_DIR}") + macro(ulp_detect_build_type) # Logic to determine ULP type and set reusable flags set(BUILD_RISCV OFF) @@ -49,7 +54,7 @@ function(ulp_add_build_binary_targets ulp_app_name) set(ULP_BASE_ADDR "0x50000000") endif() - set(ULP_MAP_GEN ${PYTHON} ${IDF_PATH}/components/ulp/esp32ulp_mapgen.py) + set(ULP_MAP_GEN ${PYTHON} ${__ULP_SUBPROJECT_DIR}/esp32ulp_mapgen.py) # Dump the list of global symbols in a convenient format add_custom_command(OUTPUT ${ulp_app_name}.sym diff --git a/components/ulp/esp32ulp_mapgen.py b/components/ulp/subproject/esp32ulp_mapgen.py similarity index 100% rename from components/ulp/esp32ulp_mapgen.py rename to components/ulp/subproject/esp32ulp_mapgen.py diff --git a/components/ulp/cmake/preprocess_fsm_asm.cmake b/components/ulp/subproject/preprocess_fsm_asm.cmake similarity index 100% rename from components/ulp/cmake/preprocess_fsm_asm.cmake rename to components/ulp/subproject/preprocess_fsm_asm.cmake diff --git a/components/ulp/cmake/toolchain-esp32-ulp.cmake b/components/ulp/subproject/toolchain-esp32-ulp.cmake similarity index 100% rename from components/ulp/cmake/toolchain-esp32-ulp.cmake rename to components/ulp/subproject/toolchain-esp32-ulp.cmake diff --git a/components/ulp/cmake/toolchain-esp32s2-ulp.cmake b/components/ulp/subproject/toolchain-esp32s2-ulp.cmake similarity index 100% rename from components/ulp/cmake/toolchain-esp32s2-ulp.cmake rename to components/ulp/subproject/toolchain-esp32s2-ulp.cmake diff --git a/components/ulp/cmake/toolchain-esp32s3-ulp.cmake b/components/ulp/subproject/toolchain-esp32s3-ulp.cmake similarity index 100% rename from components/ulp/cmake/toolchain-esp32s3-ulp.cmake rename to components/ulp/subproject/toolchain-esp32s3-ulp.cmake diff --git a/components/ulp/cmake/toolchain-lp-core-riscv.cmake b/components/ulp/subproject/toolchain-lp-core-riscv.cmake similarity index 100% rename from components/ulp/cmake/toolchain-lp-core-riscv.cmake rename to components/ulp/subproject/toolchain-lp-core-riscv.cmake diff --git a/components/ulp/cmake/toolchain-ulp-riscv.cmake b/components/ulp/subproject/toolchain-ulp-riscv.cmake similarity index 100% rename from components/ulp/cmake/toolchain-ulp-riscv.cmake rename to components/ulp/subproject/toolchain-ulp-riscv.cmake diff --git a/components/ulp/cmake/ulp_project.cmake b/components/ulp/subproject/ulp_project.cmake similarity index 100% rename from components/ulp/cmake/ulp_project.cmake rename to components/ulp/subproject/ulp_project.cmake diff --git a/components/ulp/test_apps/lp_core/host_tests/lp_core_custom_linker_v2/main/ulp/CMakeLists.txt b/components/ulp/test_apps/lp_core/host_tests/lp_core_custom_linker_v2/main/ulp/CMakeLists.txt index 46cc1d8f144..6a89cf6f960 100644 --- a/components/ulp/test_apps/lp_core/host_tests/lp_core_custom_linker_v2/main/ulp/CMakeLists.txt +++ b/components/ulp/test_apps/lp_core/host_tests/lp_core_custom_linker_v2/main/ulp/CMakeLists.txt @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 cmake_minimum_required(VERSION 3.22) -include(${IDF_PATH}/components/ulp/cmake/ulp_project.cmake) +include(${IDF_PATH}/components/ulp/subproject/ulp_project.cmake) project(${IDF_DEFAULT_PROJECT_NAME} C CXX ASM) diff --git a/tools/ci/executable-list.txt b/tools/ci/executable-list.txt index 0ebf0d55f63..3b3b81eccb8 100644 --- a/tools/ci/executable-list.txt +++ b/tools/ci/executable-list.txt @@ -25,7 +25,7 @@ components/partition_table/test_gen_esp32part_host/check_sizes_test.py components/partition_table/test_gen_esp32part_host/gen_esp32part_tests.py components/spiffs/spiffsgen.py components/spiffs/test_spiffsgen/test_spiffsgen.py -components/ulp/esp32ulp_mapgen.py +components/ulp/subproject/esp32ulp_mapgen.py docs/check_lang_folder_sync.sh examples/build_system/cmake/idf_as_lib/build-esp32.sh examples/build_system/cmake/idf_as_lib/build-esp32c2.sh diff --git a/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_fsm/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_fsm/CMakeLists.txt index b48a7286f3e..4105a4fa745 100644 --- a/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_fsm/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_fsm/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.22) -include(${IDF_PATH}/components/ulp/cmake/ulp_project.cmake) +include(${IDF_PATH}/components/ulp/subproject/ulp_project.cmake) project(${IDF_DEFAULT_PROJECT_NAME} ASM) diff --git a/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_riscv/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_riscv/CMakeLists.txt index ec8b058fc29..99d21d6d5a7 100644 --- a/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_riscv/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_riscv/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.22) -include(${IDF_PATH}/components/ulp/cmake/ulp_project.cmake) +include(${IDF_PATH}/components/ulp/subproject/ulp_project.cmake) project(${IDF_DEFAULT_PROJECT_NAME} C CXX ASM) diff --git a/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/CMakeLists.txt index b48a7286f3e..4105a4fa745 100644 --- a/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.22) -include(${IDF_PATH}/components/ulp/cmake/ulp_project.cmake) +include(${IDF_PATH}/components/ulp/subproject/ulp_project.cmake) project(${IDF_DEFAULT_PROJECT_NAME} ASM) diff --git a/tools/test_apps/system/ulp/full_subproject/lp_core/main/ulp/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/lp_core/main/ulp/CMakeLists.txt index ec8b058fc29..99d21d6d5a7 100644 --- a/tools/test_apps/system/ulp/full_subproject/lp_core/main/ulp/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/lp_core/main/ulp/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.22) -include(${IDF_PATH}/components/ulp/cmake/ulp_project.cmake) +include(${IDF_PATH}/components/ulp/subproject/ulp_project.cmake) project(${IDF_DEFAULT_PROJECT_NAME} C CXX ASM) diff --git a/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/CMakeLists.txt index 1df774c07fb..c30110b29d3 100644 --- a/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.22) -include(${IDF_PATH}/components/ulp/cmake/ulp_project.cmake) +include(${IDF_PATH}/components/ulp/subproject/ulp_project.cmake) project(${IDF_DEFAULT_PROJECT_NAME} C CXX ASM) diff --git a/tools/test_apps/system/ulp/full_subproject/riscv/main/ulp/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/riscv/main/ulp/CMakeLists.txt index ec8b058fc29..99d21d6d5a7 100644 --- a/tools/test_apps/system/ulp/full_subproject/riscv/main/ulp/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/riscv/main/ulp/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.22) -include(${IDF_PATH}/components/ulp/cmake/ulp_project.cmake) +include(${IDF_PATH}/components/ulp/subproject/ulp_project.cmake) project(${IDF_DEFAULT_PROJECT_NAME} C CXX ASM) diff --git a/tools/test_build_system/buildv2/test_ulp.py b/tools/test_build_system/buildv2/test_ulp.py index 77750628a34..5f75bdb3dfe 100644 --- a/tools/test_build_system/buildv2/test_ulp.py +++ b/tools/test_build_system/buildv2/test_ulp.py @@ -87,7 +87,7 @@ def _sha256(path: Path) -> str: 'entry_point,add_native_executable,expected_available,expected_unavailable', ( ( - '${IDF_PATH}/components/ulp/cmake/ulp_project.cmake', + '${IDF_PATH}/components/ulp/subproject/ulp_project.cmake', False, FULL_PROJECT_APIS, LEGACY_PROJECT_APIS, @@ -116,7 +116,7 @@ def test_ulp_cmake_api_availability( build_dir = tmp_path / 'build' project_dir.mkdir() _write_api_probe_project(project_dir, entry_point, add_native_executable) - ulp_cmake_dir = idf_path / 'components' / 'ulp' / 'cmake' + ulp_subproject_dir = idf_path / 'components' / 'ulp' / 'subproject' cmake_args = ( 'cmake', @@ -126,8 +126,8 @@ def test_ulp_cmake_api_availability( _cmake_path(project_dir), '-B', _cmake_path(build_dir), - f'-DCMAKE_MODULE_PATH={_cmake_path(ulp_cmake_dir)}', - f'-DCMAKE_TOOLCHAIN_FILE={_cmake_path(ulp_cmake_dir / "toolchain-lp-core-riscv.cmake")}', + f'-DCMAKE_MODULE_PATH={_cmake_path(ulp_subproject_dir)}', + f'-DCMAKE_TOOLCHAIN_FILE={_cmake_path(ulp_subproject_dir / "toolchain-lp-core-riscv.cmake")}', f'-DIDF_PATH={_cmake_path(idf_path)}', '-DIDF_TARGET=esp32c6', f'-DSDKCONFIG_CMAKE={_cmake_path(project_dir / "sdkconfig.cmake")}',