mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
feat(ulp): build legacy ULP APIs through CMake v2 shim
This commit is contained in:
@@ -6,6 +6,15 @@ endif()
|
||||
|
||||
set(includes "include" "interface" "${target}/include")
|
||||
|
||||
# TODO(IDF-15983): potentially remove __ULP_BUILD handling from esp_adc
|
||||
if(__ULP_BUILD)
|
||||
# LP-core ADC shared code includes esp_adc/adc_oneshot.h from
|
||||
# ulp/lp_core/shared/include/ulp_lp_core_lp_adc_shared.h.
|
||||
idf_component_register(INCLUDE_DIRS ${includes}
|
||||
REQUIRES esp_hal_ana_conv)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(srcs)
|
||||
|
||||
if(CONFIG_SOC_ADC_SUPPORTED)
|
||||
|
||||
@@ -8,6 +8,15 @@ set(srcs)
|
||||
set(include "include")
|
||||
set(priv_requires esp_driver_gpio esp_driver_dma esp_pm esp_mm esp_hal_clock)
|
||||
|
||||
# TODO(IDF-15984): potentially remove __ULP_BUILD handling from esp_driver_i2s
|
||||
if(__ULP_BUILD)
|
||||
# LP-core VAD shared code includes driver/lp_i2s_vad.h from
|
||||
# ulp/lp_core/shared/include/ulp_lp_core_lp_vad_shared.h.
|
||||
idf_component_register(INCLUDE_DIRS ${include}
|
||||
REQUIRES esp_hal_i2s)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(${target} STREQUAL "esp32")
|
||||
# ADC on esp32 is routed to I2S0, I2S driver needs to operate ADC to ensure the I2S function.
|
||||
list(APPEND priv_requires esp_hal_ana_conv)
|
||||
|
||||
@@ -4,7 +4,9 @@ if(${target} STREQUAL "linux")
|
||||
return() # This component is not supported by the POSIX/Linux simulator
|
||||
endif()
|
||||
|
||||
set(requires soc hal esp_hal_dma)
|
||||
# Public ADC and temperature sensor HAL headers include hal/regi2c_ctrl.h on
|
||||
# several targets, so CMake v2 builds need esp_hal_regi2c explicitly.
|
||||
set(requires soc hal esp_hal_dma esp_hal_regi2c)
|
||||
if(${target} STREQUAL "esp32")
|
||||
list(APPEND requires esp_hal_i2s)
|
||||
endif()
|
||||
@@ -15,6 +17,17 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${target}/include")
|
||||
list(APPEND includes "${target}/include")
|
||||
endif()
|
||||
|
||||
# TODO(IDF-15985): potentially remove __ULP_BUILD handling from esp_hal_ana_conv
|
||||
if(__ULP_BUILD)
|
||||
# ULP ADC code includes ADC HAL headers from
|
||||
# ulp/ulp_riscv/ulp_core/ulp_riscv_adc.c and
|
||||
# ulp/lp_core/shared/include/ulp_lp_core_lp_adc_shared.h. Some target
|
||||
# ADC/temperature sensor headers include hal/regi2c_ctrl.h.
|
||||
idf_component_register(INCLUDE_DIRS ${includes}
|
||||
REQUIRES ${requires})
|
||||
return()
|
||||
endif()
|
||||
|
||||
# ADC related source files
|
||||
if(CONFIG_SOC_ADC_SUPPORTED)
|
||||
list(APPEND srcs "${target}/adc_periph.c" "adc_hal_common.c" "adc_oneshot_hal.c")
|
||||
|
||||
@@ -10,6 +10,15 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${target}/include")
|
||||
list(APPEND public_include "${target}/include")
|
||||
endif()
|
||||
|
||||
# TODO(IDF-15991): potentially remove __ULP_BUILD handling from esp_hal_dma
|
||||
if(__ULP_BUILD)
|
||||
# LP-core SPI uses components/esp_hal_gpspi/include/hal/spi_slave_hd_hal.h,
|
||||
# whose public headers include DMA HAL descriptor types.
|
||||
idf_component_register(INCLUDE_DIRS ${public_include}
|
||||
REQUIRES soc hal)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_GDMA_SUPPORTED)
|
||||
list(APPEND srcs "gdma_hal_top.c" "${target}/gdma_periph.c")
|
||||
|
||||
|
||||
@@ -7,6 +7,15 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${target}/include")
|
||||
list(APPEND includes "${target}/include")
|
||||
endif()
|
||||
|
||||
# TODO(IDF-15986): potentially remove __ULP_BUILD handling from esp_hal_gpspi
|
||||
if(__ULP_BUILD)
|
||||
# LP-core SPI code includes SPI HAL headers from
|
||||
# ulp/lp_core/lp_core/lp_core_spi.c.
|
||||
idf_component_register(INCLUDE_DIRS ${includes}
|
||||
REQUIRES soc hal esp_hal_dma)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_GPSPI_SUPPORTED)
|
||||
list(APPEND srcs
|
||||
"${target}/spi_periph.c"
|
||||
|
||||
@@ -8,6 +8,16 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${target}/include")
|
||||
endif()
|
||||
list(APPEND includes "include")
|
||||
|
||||
# TODO(IDF-15987): potentially remove __ULP_BUILD handling from esp_hal_i2c
|
||||
if(__ULP_BUILD)
|
||||
# ULP I2C code includes hal/i2c_ll.h and hal/i2c_types.h from
|
||||
# ulp/ulp_riscv/ulp_core/ulp_riscv_i2c.c and
|
||||
# ulp/lp_core/lp_core/lp_core_i2c.c.
|
||||
idf_component_register(INCLUDE_DIRS ${includes}
|
||||
REQUIRES soc hal esp_common)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(target_folder "${target}")
|
||||
|
||||
# I2C related source files
|
||||
|
||||
@@ -11,6 +11,15 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${target}/include")
|
||||
list(APPEND includes "${target}/include")
|
||||
endif()
|
||||
|
||||
# TODO(IDF-15988): potentially remove __ULP_BUILD handling from esp_hal_i2s
|
||||
if(__ULP_BUILD)
|
||||
# LP-core VAD shared code includes LP I2S HAL headers from
|
||||
# ulp/lp_core/shared/ulp_lp_core_lp_vad_shared.c.
|
||||
idf_component_register(INCLUDE_DIRS ${includes}
|
||||
REQUIRES soc hal)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# I2S related source files
|
||||
if(CONFIG_SOC_I2S_SUPPORTED)
|
||||
list(APPEND srcs "i2s_hal.c" "${target}/i2s_periph.c")
|
||||
|
||||
@@ -6,6 +6,15 @@ endif()
|
||||
set(srcs)
|
||||
set(public_include "include" "${target}/include")
|
||||
|
||||
# TODO(IDF-15992): potentially remove __ULP_BUILD handling from esp_hal_rtc_timer
|
||||
if(__ULP_BUILD)
|
||||
# LP-core timer shared code includes hal/rtc_timer_ll.h from
|
||||
# ulp/lp_core/shared/ulp_lp_core_lp_timer_shared.c.
|
||||
idf_component_register(INCLUDE_DIRS ${public_include}
|
||||
REQUIRES soc hal esp_rom)
|
||||
return()
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
INCLUDE_DIRS ${public_include}
|
||||
REQUIRES soc hal esp_rom)
|
||||
|
||||
@@ -12,6 +12,16 @@ endif()
|
||||
# "include" should be behind "${target}/include", because `include_next` has sequence requirement
|
||||
list(APPEND includes "include")
|
||||
|
||||
# TODO(IDF-15989): potentially remove __ULP_BUILD handling from esp_hal_touch_sens
|
||||
if(__ULP_BUILD)
|
||||
# ULP touch support includes touch sensor HAL headers from
|
||||
# ulp/ulp_riscv/ulp_core/ulp_riscv_touch.c and
|
||||
# ulp/lp_core/lp_core/lp_core_touch.c.
|
||||
idf_component_register(INCLUDE_DIRS ${includes}
|
||||
REQUIRES soc)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Touch Sensor related source files
|
||||
if(CONFIG_SOC_TOUCH_SENSOR_SUPPORTED)
|
||||
# Source files for the legacy touch hal driver
|
||||
|
||||
@@ -8,6 +8,22 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${target}/include")
|
||||
list(APPEND includes "${target}/include")
|
||||
endif()
|
||||
|
||||
# TODO(IDF-15990): potentially remove __ULP_BUILD handling from esp_hal_uart
|
||||
if(__ULP_BUILD)
|
||||
# LP-core UART and print code includes UART HAL headers from
|
||||
# ulp/lp_core/lp_core/lp_core_uart.c and
|
||||
# ulp/lp_core/lp_core/lp_core_print.c.
|
||||
set(ulp_srcs)
|
||||
if(ULP_TYPE STREQUAL "lp_core" AND CONFIG_SOC_UART_SUPPORTED)
|
||||
list(APPEND ulp_srcs "uart_hal.c" "uart_hal_iram.c")
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS ${ulp_srcs}
|
||||
INCLUDE_DIRS ${includes}
|
||||
REQUIRES esp_common soc hal)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_UART_SUPPORTED)
|
||||
list(APPEND srcs "uart_hal.c" "uart_hal_iram.c" "${target}/uart_periph.c")
|
||||
endif()
|
||||
|
||||
@@ -6,17 +6,35 @@ set(priv_requires "")
|
||||
if(__ULP_BUILD)
|
||||
if(ULP_TYPE STREQUAL "riscv")
|
||||
list(APPEND includes
|
||||
ulp_common/include
|
||||
ulp_riscv/include
|
||||
ulp_riscv/shared/include
|
||||
ulp_riscv/ulp_core/include)
|
||||
list(APPEND srcs
|
||||
"ulp_riscv/ulp_core/ulp_riscv_vectors.S"
|
||||
"ulp_riscv/ulp_core/start.S"
|
||||
"ulp_riscv/ulp_core/ulp_riscv_utils.c")
|
||||
"ulp_riscv/ulp_core/ulp_riscv_adc.c"
|
||||
"ulp_riscv/ulp_core/ulp_riscv_lock.c"
|
||||
"ulp_riscv/ulp_core/ulp_riscv_uart.c"
|
||||
"ulp_riscv/ulp_core/ulp_riscv_print.c"
|
||||
"ulp_riscv/ulp_core/ulp_riscv_i2c.c"
|
||||
"ulp_riscv/ulp_core/ulp_riscv_utils.c"
|
||||
"ulp_riscv/ulp_core/ulp_riscv_touch.c"
|
||||
"ulp_riscv/ulp_core/ulp_riscv_gpio.c"
|
||||
"ulp_riscv/ulp_core/ulp_riscv_interrupt.c")
|
||||
list(APPEND requires
|
||||
esp_common
|
||||
esp_hal_ana_conv
|
||||
esp_hal_gpio
|
||||
esp_hal_i2c
|
||||
esp_hal_touch_sens
|
||||
esp_hw_support
|
||||
riscv
|
||||
soc)
|
||||
elseif(ULP_TYPE STREQUAL "lp_core")
|
||||
list(APPEND includes
|
||||
ulp_common/include
|
||||
lp_core/include
|
||||
lp_core/lp_core/include
|
||||
lp_core/shared/include)
|
||||
list(APPEND srcs
|
||||
@@ -27,16 +45,15 @@ if(__ULP_BUILD)
|
||||
"lp_core/lp_core/lp_core_startup.c"
|
||||
"lp_core/lp_core/lp_core_pmp.c"
|
||||
"lp_core/lp_core/lp_core_utils.c"
|
||||
"lp_core/lp_core/lp_core_print.c"
|
||||
"lp_core/lp_core/lp_core_panic.c"
|
||||
"lp_core/lp_core/lp_core_interrupt.c"
|
||||
"lp_core/shared/ulp_lp_core_lp_uart_shared.c"
|
||||
"lp_core/lp_core/lp_core_uart.c"
|
||||
"lp_core/shared/ulp_lp_core_lp_timer_shared.c"
|
||||
"lp_core/lp_core/lp_core_ubsan.c"
|
||||
"lp_core/lp_core/lp_core_mailbox.c"
|
||||
"lp_core/shared/ulp_lp_core_critical_section_shared.c")
|
||||
|
||||
list(APPEND requires
|
||||
esp_common
|
||||
esp_driver_uart
|
||||
esp_hal_gpio
|
||||
esp_hal_uart
|
||||
esp_rom
|
||||
@@ -44,12 +61,55 @@ if(__ULP_BUILD)
|
||||
riscv
|
||||
soc)
|
||||
list(APPEND priv_requires
|
||||
esp_hal_clock
|
||||
esp_hal_i2s
|
||||
esp_hal_rtc_timer
|
||||
esp_hal_pmu
|
||||
esp_hw_support)
|
||||
|
||||
if(CONFIG_SOC_RTC_TIMER_V2 OR CONFIG_SOC_RTC_TIMER_V3)
|
||||
list(APPEND srcs "lp_core/shared/ulp_lp_core_lp_timer_shared.c")
|
||||
list(APPEND priv_requires
|
||||
esp_hal_clock
|
||||
esp_hal_rtc_timer)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_LP_CORE_SUPPORT_I2C)
|
||||
list(APPEND srcs "lp_core/lp_core/lp_core_i2c.c")
|
||||
list(APPEND requires esp_hal_i2c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_LP_SPI_SUPPORTED)
|
||||
list(APPEND srcs "lp_core/lp_core/lp_core_spi.c")
|
||||
list(APPEND priv_requires esp_hal_gpspi)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_ULP_LP_UART_SUPPORTED)
|
||||
list(APPEND srcs
|
||||
"lp_core/shared/ulp_lp_core_lp_uart_shared.c"
|
||||
"lp_core/lp_core/lp_core_uart.c")
|
||||
list(APPEND requires esp_driver_uart)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_LP_MAILBOX_SUPPORTED)
|
||||
list(APPEND srcs "lp_core/lp_core/port/lp_core_mailbox_impl_hw.c")
|
||||
else()
|
||||
list(APPEND srcs "lp_core/lp_core/port/lp_core_mailbox_impl_sw.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_TOUCH_SENSOR_SUPPORTED)
|
||||
list(APPEND srcs "lp_core/lp_core/lp_core_touch.c")
|
||||
list(APPEND requires esp_hal_touch_sens)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_LP_ADC_SUPPORTED)
|
||||
list(APPEND srcs "lp_core/shared/ulp_lp_core_lp_adc_shared.c")
|
||||
list(APPEND requires
|
||||
esp_adc
|
||||
esp_hal_ana_conv)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_LP_VAD_SUPPORTED)
|
||||
list(APPEND srcs "lp_core/shared/ulp_lp_core_lp_vad_shared.c")
|
||||
list(APPEND requires esp_driver_i2s)
|
||||
endif()
|
||||
elseif(ULP_TYPE STREQUAL "fsm")
|
||||
list(APPEND includes
|
||||
ulp_common/include
|
||||
@@ -60,7 +120,13 @@ if(__ULP_BUILD)
|
||||
message(FATAL_ERROR "__ULP_BUILD requires ULP_TYPE to be one of: riscv, lp_core, fsm.")
|
||||
endif()
|
||||
else()
|
||||
if(CONFIG_ULP_COPROC_ENABLED)
|
||||
# TODO(IDF-15993): Keep esp_driver_gpio and esp_adc public for compatibility
|
||||
# with the CMake v1 dependency graph until downstream users are fixed.
|
||||
list(APPEND requires
|
||||
esp_adc
|
||||
esp_driver_gpio)
|
||||
|
||||
if(CONFIG_ULP_COPROC_ENABLED OR CONFIG_IDF_DOC_BUILD)
|
||||
list(APPEND includes
|
||||
ulp_common/include)
|
||||
list(APPEND requires
|
||||
@@ -68,49 +134,127 @@ else()
|
||||
soc)
|
||||
endif()
|
||||
|
||||
if(CONFIG_ULP_COPROC_TYPE_FSM)
|
||||
if(CONFIG_ULP_COPROC_TYPE_FSM OR (CONFIG_IDF_DOC_BUILD AND CONFIG_SOC_ULP_FSM_SUPPORTED))
|
||||
list(APPEND includes
|
||||
ulp_fsm/include
|
||||
ulp_fsm/include/${target})
|
||||
list(APPEND srcs
|
||||
"ulp_common/ulp_common.c"
|
||||
"ulp_fsm/ulp.c"
|
||||
"ulp_fsm/ulp_macro.c")
|
||||
list(APPEND requires esp_hw_support)
|
||||
endif()
|
||||
|
||||
if(CONFIG_ULP_COPROC_TYPE_RISCV)
|
||||
if(CONFIG_ULP_COPROC_TYPE_RISCV OR CONFIG_IDF_DOC_BUILD)
|
||||
list(APPEND includes
|
||||
ulp_riscv/include
|
||||
ulp_riscv/shared/include
|
||||
ulp_riscv/ulp_core/include)
|
||||
list(APPEND requires esp_hw_support)
|
||||
endif()
|
||||
|
||||
if(CONFIG_ULP_COPROC_TYPE_LP_CORE OR CONFIG_IDF_DOC_BUILD)
|
||||
list(APPEND includes
|
||||
lp_core/include
|
||||
lp_core/lp_core/include
|
||||
lp_core/shared/include)
|
||||
endif()
|
||||
|
||||
if(CONFIG_ULP_COPROC_TYPE_FSM OR CONFIG_ULP_COPROC_TYPE_RISCV)
|
||||
list(APPEND srcs
|
||||
"ulp_common/ulp_common.c"
|
||||
"ulp_riscv/ulp_riscv.c")
|
||||
list(APPEND requires
|
||||
esp_hw_support
|
||||
esp_hal_pmu)
|
||||
"ulp_common/ulp_adc.c")
|
||||
|
||||
if(CONFIG_ULP_COPROC_TYPE_FSM)
|
||||
list(APPEND srcs
|
||||
"ulp_fsm/ulp.c"
|
||||
"ulp_fsm/ulp_macro.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_ULP_COPROC_TYPE_RISCV)
|
||||
list(APPEND srcs
|
||||
"ulp_riscv/ulp_riscv.c"
|
||||
"ulp_riscv/ulp_riscv_lock.c"
|
||||
"ulp_riscv/ulp_riscv_i2c.c")
|
||||
list(APPEND priv_requires esp_driver_gpio)
|
||||
list(APPEND requires
|
||||
# ulp/ulp_riscv/ulp_core/include/ulp_riscv_touch_ulp_core.h
|
||||
# includes hal/touch_sens_types.h.
|
||||
esp_hal_touch_sens
|
||||
esp_hal_i2c
|
||||
hal)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CONFIG_ULP_COPROC_TYPE_LP_CORE)
|
||||
list(APPEND includes
|
||||
lp_core/include
|
||||
lp_core/lp_core/include
|
||||
lp_core/shared/include)
|
||||
list(APPEND srcs
|
||||
"lp_core/lp_core.c"
|
||||
"lp_core/shared/ulp_lp_core_memory_shared.c"
|
||||
"lp_core/shared/ulp_lp_core_lp_timer_shared.c"
|
||||
"lp_core/shared/ulp_lp_core_critical_section_shared.c")
|
||||
list(APPEND requires
|
||||
esp_hw_support
|
||||
esp_hal_clock
|
||||
esp_common
|
||||
esp_hal_pmu
|
||||
esp_hal_rtc_timer
|
||||
esp_rom
|
||||
hal
|
||||
riscv
|
||||
soc)
|
||||
|
||||
if(CONFIG_SOC_ULP_LP_UART_SUPPORTED)
|
||||
list(APPEND srcs
|
||||
"lp_core/lp_core_uart.c"
|
||||
"lp_core/shared/ulp_lp_core_lp_uart_shared.c")
|
||||
list(APPEND requires
|
||||
esp_driver_gpio
|
||||
esp_driver_uart)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_LP_CORE_SUPPORT_I2C)
|
||||
list(APPEND srcs "lp_core/lp_core_i2c.c")
|
||||
list(APPEND requires
|
||||
esp_driver_gpio
|
||||
esp_hal_i2c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_RTC_TIMER_V2 OR CONFIG_SOC_RTC_TIMER_V3)
|
||||
list(APPEND srcs "lp_core/shared/ulp_lp_core_lp_timer_shared.c")
|
||||
list(APPEND requires
|
||||
esp_hal_clock
|
||||
esp_hal_rtc_timer)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_LP_SPI_SUPPORTED)
|
||||
list(APPEND srcs "lp_core/lp_core_spi.c")
|
||||
list(APPEND requires
|
||||
esp_driver_gpio
|
||||
esp_hal_gpspi)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_LP_CORE_SUPPORT_ETM)
|
||||
list(APPEND srcs "lp_core/lp_core_etm.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_TOUCH_SENSOR_SUPPORTED)
|
||||
list(APPEND requires esp_hal_touch_sens)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_LP_ADC_SUPPORTED)
|
||||
list(APPEND srcs "lp_core/shared/ulp_lp_core_lp_adc_shared.c")
|
||||
list(APPEND priv_requires esp_hw_support)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_LP_VAD_SUPPORTED)
|
||||
list(APPEND srcs "lp_core/shared/ulp_lp_core_lp_vad_shared.c")
|
||||
list(APPEND requires esp_driver_i2s)
|
||||
endif()
|
||||
|
||||
list(APPEND srcs "lp_core/lp_core_mailbox.c")
|
||||
if(CONFIG_SOC_LP_MAILBOX_SUPPORTED)
|
||||
list(APPEND srcs "lp_core/lp_core_mailbox_impl_hw.c")
|
||||
else()
|
||||
list(APPEND srcs "lp_core/lp_core_mailbox_impl_sw.c")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(srcs)
|
||||
list(APPEND priv_requires
|
||||
bootloader_support
|
||||
esp_mm)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
10
components/ulp/cmake/legacy_project/CMakeLists.txt.in
Normal file
10
components/ulp/cmake/legacy_project/CMakeLists.txt.in
Normal file
@@ -0,0 +1,10 @@
|
||||
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()
|
||||
17
components/ulp/cmake/legacy_project/main/CMakeLists.txt.in
Normal file
17
components/ulp/cmake/legacy_project/main/CMakeLists.txt.in
Normal file
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
@@ -0,0 +1,16 @@
|
||||
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()
|
||||
@@ -9,6 +9,13 @@
|
||||
include(${IDF_PATH}/tools/cmakev2/idf.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/IDFULPProjectCommon.cmake)
|
||||
|
||||
if(__ULP_BUILD)
|
||||
set(NON_OS_BUILD 1)
|
||||
# Clearing common components below only prevents automatic app-component closure.
|
||||
# Explicitly included ULP dependencies still read NON_OS_BUILD to select their no-OS shape.
|
||||
idf_build_set_property(NON_OS_BUILD 1)
|
||||
endif()
|
||||
|
||||
# Reset the compile/link state inherited from the parent app build and select
|
||||
# ULP-specific build behavior. Idempotent within a child configure.
|
||||
function(__ulp_prepare_build)
|
||||
|
||||
@@ -6,8 +6,88 @@ endif()
|
||||
#
|
||||
# Create ULP binary and embed into the application.
|
||||
|
||||
# Generate a minimal CMake v2 ULP project in the parent build directory for
|
||||
# legacy ulp_embed_binary() callers. This lets the v2 ULP component graph build
|
||||
# legacy source lists without writing into the application source tree.
|
||||
function(__ulp_write_legacy_project project_dir sources component_dir)
|
||||
set(template_dir "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/cmake/legacy_project")
|
||||
set(main_dir "${project_dir}/main")
|
||||
file(MAKE_DIRECTORY "${main_dir}")
|
||||
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
|
||||
"${template_dir}/CMakeLists.txt.in"
|
||||
"${template_dir}/main/CMakeLists.txt.in"
|
||||
"${template_dir}/main/ulp_legacy_inputs.cmake.in")
|
||||
|
||||
file(GENERATE OUTPUT "${project_dir}/CMakeLists.txt"
|
||||
INPUT "${template_dir}/CMakeLists.txt.in")
|
||||
file(GENERATE OUTPUT "${main_dir}/CMakeLists.txt"
|
||||
INPUT "${template_dir}/main/CMakeLists.txt.in")
|
||||
|
||||
set(ULP_LEGACY_SOURCES)
|
||||
foreach(source IN LISTS sources)
|
||||
string(APPEND ULP_LEGACY_SOURCES " [=[${source}]=]\n")
|
||||
endforeach()
|
||||
|
||||
set(ULP_LEGACY_INCLUDE_DIR_CANDIDATES)
|
||||
if(DEFINED COMPONENT_NAME)
|
||||
set(legacy_include_components "${COMPONENT_NAME}")
|
||||
foreach(require_property IN ITEMS REQUIRES PRIV_REQUIRES)
|
||||
idf_component_get_property(component_requires "${COMPONENT_NAME}" ${require_property})
|
||||
list(APPEND legacy_include_components ${component_requires})
|
||||
endforeach()
|
||||
list(REMOVE_DUPLICATES legacy_include_components)
|
||||
|
||||
foreach(component IN LISTS legacy_include_components)
|
||||
if(component STREQUAL "ulp")
|
||||
continue()
|
||||
endif()
|
||||
idf_component_get_property(include_component_dir "${component}" COMPONENT_DIR)
|
||||
set(include_properties INCLUDE_DIRS)
|
||||
if(component STREQUAL COMPONENT_NAME)
|
||||
list(APPEND include_properties PRIV_INCLUDE_DIRS)
|
||||
endif()
|
||||
foreach(include_property IN LISTS include_properties)
|
||||
idf_component_get_property(component_includes "${component}" ${include_property})
|
||||
foreach(include IN LISTS component_includes)
|
||||
if(IS_ABSOLUTE "${include}")
|
||||
string(APPEND ULP_LEGACY_INCLUDE_DIR_CANDIDATES " [=[${include}]=]\n")
|
||||
elseif(include_component_dir)
|
||||
string(APPEND ULP_LEGACY_INCLUDE_DIR_CANDIDATES
|
||||
" [=[${include_component_dir}/${include}]=]\n")
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endif()
|
||||
if(component_dir)
|
||||
string(APPEND ULP_LEGACY_INCLUDE_DIR_CANDIDATES " [=[${component_dir}]=]\n")
|
||||
endif()
|
||||
|
||||
set(ULP_LEGACY_PARENT_SDKCONFIG_HEADER)
|
||||
if(SDKCONFIG_HEADER AND EXISTS "${SDKCONFIG_HEADER}")
|
||||
set(ULP_LEGACY_PARENT_SDKCONFIG_HEADER "${main_dir}/ulp_parent_sdkconfig.h")
|
||||
file(STRINGS "${SDKCONFIG_HEADER}" parent_sdkconfig_lines)
|
||||
set(parent_sdkconfig_content
|
||||
"/* Generated from the parent project sdkconfig for legacy ULP sources. */\n")
|
||||
foreach(parent_sdkconfig_line IN LISTS parent_sdkconfig_lines)
|
||||
if(parent_sdkconfig_line MATCHES "^#define CONFIG_IDF_TOOLCHAIN(_[A-Z]+)?[ \t]")
|
||||
continue()
|
||||
endif()
|
||||
string(APPEND parent_sdkconfig_content "${parent_sdkconfig_line}\n")
|
||||
endforeach()
|
||||
file(GENERATE OUTPUT "${ULP_LEGACY_PARENT_SDKCONFIG_HEADER}"
|
||||
CONTENT "${parent_sdkconfig_content}")
|
||||
endif()
|
||||
|
||||
file(READ "${template_dir}/main/ulp_legacy_inputs.cmake.in" inputs_template)
|
||||
string(CONFIGURE "${inputs_template}" inputs_content @ONLY)
|
||||
file(GENERATE OUTPUT "${main_dir}/ulp_legacy_inputs.cmake"
|
||||
CONTENT "${inputs_content}")
|
||||
endfunction()
|
||||
|
||||
function(__setup_ulp_project app_name project_path prefix prefix_append_bin_name type binary_names
|
||||
s_sources exp_dep_srcs)
|
||||
legacy_project s_sources exp_dep_srcs)
|
||||
|
||||
if(NOT CMAKE_BUILD_EARLY_EXPANSION)
|
||||
set(ulp_cmake_dir "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/cmake")
|
||||
@@ -131,7 +211,9 @@ function(__setup_ulp_project app_name project_path prefix prefix_append_bin_name
|
||||
# subprojects). Do not warn about the ones a given child ignores.
|
||||
--no-warn-unused-cli
|
||||
-DIDF_DEFAULT_PROJECT_NAME=${app_name}
|
||||
-DULP_APP_NAME=${app_name}
|
||||
-DIDF_BUILD_V2=y
|
||||
-DCMAKE_MODULE_PATH=${ulp_cmake_dir}
|
||||
# Internal marker for the ULP child project component graph.
|
||||
-D__ULP_BUILD=1
|
||||
-DIDF_PARENT_BUILD_DIR=${build_dir}
|
||||
@@ -147,21 +229,27 @@ function(__setup_ulp_project app_name project_path prefix prefix_append_bin_name
|
||||
# share more of the normal IDF app toolchain response-file
|
||||
# setup, but keep them under IDF_CUSTOM_TOOLCHAIN for now.
|
||||
-DIDF_CUSTOM_TOOLCHAIN=1)
|
||||
if(s_sources)
|
||||
if(legacy_project)
|
||||
set(generated_project_dir "${ulp_binary_dir}/legacy_project")
|
||||
__ulp_write_legacy_project("${generated_project_dir}" "${sources}" "${COMPONENT_DIR}")
|
||||
set(project_path "${generated_project_dir}")
|
||||
elseif(s_sources)
|
||||
list(APPEND ulp_project_args
|
||||
-DULP_S_SOURCES=$<TARGET_PROPERTY:${app_name},ULP_SOURCES>)
|
||||
endif()
|
||||
if(DEFINED COMPONENT_TARGET AND TARGET ${COMPONENT_TARGET})
|
||||
# Backward compatibility for existing ULP subprojects that
|
||||
# include headers from the parent component. New full
|
||||
# subprojects should declare their own component include
|
||||
# directories and dependencies instead.
|
||||
list(APPEND ulp_project_args
|
||||
-DCOMPONENT_INCLUDES=$<TARGET_PROPERTY:${COMPONENT_TARGET},INTERFACE_INCLUDE_DIRECTORIES>)
|
||||
endif()
|
||||
if(COMPONENT_DIR)
|
||||
list(APPEND ulp_project_args
|
||||
-DCOMPONENT_DIR=${COMPONENT_DIR})
|
||||
if(NOT legacy_project)
|
||||
if(DEFINED COMPONENT_TARGET AND TARGET ${COMPONENT_TARGET})
|
||||
# Backward compatibility for existing ULP subprojects that
|
||||
# include headers from the parent component. New full
|
||||
# subprojects should declare their own component include
|
||||
# directories and dependencies instead.
|
||||
list(APPEND ulp_project_args
|
||||
-DCOMPONENT_INCLUDES=$<TARGET_PROPERTY:${COMPONENT_TARGET},INTERFACE_INCLUDE_DIRECTORIES>)
|
||||
endif()
|
||||
if(COMPONENT_DIR)
|
||||
list(APPEND ulp_project_args
|
||||
-DCOMPONENT_DIR=${COMPONENT_DIR})
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
list(APPEND ulp_project_args
|
||||
@@ -196,6 +284,22 @@ function(__setup_ulp_project app_name project_path prefix prefix_append_bin_name
|
||||
BUILD_ALWAYS 1
|
||||
)
|
||||
|
||||
if(IDF_BUILD_V2)
|
||||
foreach(binary_name IN LISTS binary_names)
|
||||
set(ulp_compat_dir "${CMAKE_CURRENT_BINARY_DIR}/${binary_name}")
|
||||
foreach(extension IN ITEMS bin ld h map sym elf)
|
||||
set(ulp_compat_artifact "${ulp_compat_dir}/${binary_name}.${extension}")
|
||||
set(ulp_source_artifact "${ulp_binary_dir}/${binary_name}.${extension}")
|
||||
add_custom_command(OUTPUT "${ulp_compat_artifact}"
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${ulp_compat_dir}"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${ulp_source_artifact}" "${ulp_compat_artifact}"
|
||||
DEPENDS "${ulp_source_artifact}"
|
||||
VERBATIM)
|
||||
endforeach()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Only the CMake v1 path reads this property when passing ULP_S_SOURCES
|
||||
# to the child project. Leaving it set for v2 is harmless and keeps the
|
||||
# post-ExternalProject artifact wiring common. Can be dropped when
|
||||
@@ -273,7 +377,7 @@ function(ulp_embed_binary app_name s_sources exp_dep_srcs)
|
||||
__setup_ulp_project("${app_name}" "${ulp_cmake_dir}"
|
||||
"${ULP_PREFIX}" FALSE "${ULP_TYPE}"
|
||||
"${app_name}"
|
||||
"${s_sources}" "${exp_dep_srcs}")
|
||||
TRUE "${s_sources}" "${exp_dep_srcs}")
|
||||
endfunction()
|
||||
|
||||
function(ulp_add_project app_name project_path)
|
||||
@@ -298,5 +402,5 @@ function(ulp_add_project app_name project_path)
|
||||
endif()
|
||||
|
||||
__setup_ulp_project("${app_name}" "${project_path}" "${ULP_PREFIX}"
|
||||
"${ULP_PREFIX_APPEND_BIN_NAME}" "${ULP_TYPE}" "${ULP_BINARIES}" "" "")
|
||||
"${ULP_PREFIX_APPEND_BIN_NAME}" "${ULP_TYPE}" "${ULP_BINARIES}" FALSE "" "")
|
||||
endfunction()
|
||||
|
||||
@@ -72,7 +72,7 @@ idf_component_register(SRCS ${app_sources}
|
||||
INCLUDE_DIRS "lp_core"
|
||||
REQUIRES ulp unity esp_timer test_utils
|
||||
PRIV_REQUIRES esp_driver_gptimer esp_driver_i2c esp_driver_tsens esp_hal_rtc_timer
|
||||
esp_driver_gpio hal
|
||||
esp_driver_gpio esp_hal_pmu hal
|
||||
WHOLE_ARCHIVE
|
||||
EMBED_FILES "test_vad_8k.pcm")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user