Merge branch 'bugfix/fix_idf_as_lib_build' into 'master'
Build: fix idf_as_lib example not building Closes IDFGH-6453 See merge request espressif/esp-idf!16514
This commit is contained in:
@@ -2,21 +2,24 @@ cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
project(idf_as_lib C)
|
||||
|
||||
if("${TARGET}" STREQUAL "esp32")
|
||||
set(targets "esp32" "esp32s2" "esp32s3" "esp32c3" "esp32h2" "esp8684")
|
||||
|
||||
if("${TARGET}" IN_LIST targets)
|
||||
# Include for ESP-IDF build system functions
|
||||
include($ENV{IDF_PATH}/tools/cmake/idf.cmake)
|
||||
# Create idf::esp32 and idf::freertos static libraries
|
||||
idf_build_process(esp32
|
||||
# Create idf::{target} and idf::freertos static libraries
|
||||
idf_build_process("${TARGET}"
|
||||
# try and trim the build; additional components
|
||||
# will be included as needed based on dependency tree
|
||||
#
|
||||
# although esptool_py does not generate static library,
|
||||
# processing the component is needed for flashing related
|
||||
# targets and file generation
|
||||
COMPONENTS esp32 freertos esptool_py
|
||||
COMPONENTS "${TARGET}" freertos esptool_py
|
||||
SDKCONFIG ${CMAKE_CURRENT_LIST_DIR}/sdkconfig
|
||||
BUILD_DIR ${CMAKE_BINARY_DIR})
|
||||
else()
|
||||
message(WARNING "Unknown target ${TARGET}, creating stubs for esp32 instead")
|
||||
# Create stubs for esp32 and freertos, stub::esp32 and stub::freertos
|
||||
add_subdirectory(stubs/esp32)
|
||||
add_subdirectory(stubs/freertos)
|
||||
@@ -29,8 +32,8 @@ set(elf_file ${CMAKE_PROJECT_NAME}.elf)
|
||||
add_executable(${elf_file} main.c)
|
||||
|
||||
# Link the static libraries to the executable
|
||||
if("${TARGET}" STREQUAL "esp32")
|
||||
target_link_libraries(${elf_file} idf::esp32 idf::freertos idf::spi_flash)
|
||||
if("${TARGET}" IN_LIST targets)
|
||||
target_link_libraries(${elf_file} "idf::${TARGET}" idf::freertos idf::spi_flash)
|
||||
# Attach additional targets to the executable file for flashing,
|
||||
# linker script generation, partition_table generation, etc.
|
||||
idf_build_executable(${elf_file})
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_TOOLCHAIN_FILE=$IDF_PATH/tools/cmake/toolchain-esp32.cmake -DTARGET=esp32 -GNinja
|
||||
cmake --build .
|
||||
1
examples/build_system/cmake/idf_as_lib/build-esp32.sh
Symbolic link
1
examples/build_system/cmake/idf_as_lib/build-esp32.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
build.sh
|
||||
1
examples/build_system/cmake/idf_as_lib/build-esp32c3.sh
Symbolic link
1
examples/build_system/cmake/idf_as_lib/build-esp32c3.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
build.sh
|
||||
1
examples/build_system/cmake/idf_as_lib/build-esp32h2.sh
Symbolic link
1
examples/build_system/cmake/idf_as_lib/build-esp32h2.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
build.sh
|
||||
1
examples/build_system/cmake/idf_as_lib/build-esp32s2.sh
Symbolic link
1
examples/build_system/cmake/idf_as_lib/build-esp32s2.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
build.sh
|
||||
1
examples/build_system/cmake/idf_as_lib/build-esp32s3.sh
Symbolic link
1
examples/build_system/cmake/idf_as_lib/build-esp32s3.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
build.sh
|
||||
1
examples/build_system/cmake/idf_as_lib/build-esp8684.sh
Symbolic link
1
examples/build_system/cmake/idf_as_lib/build-esp8684.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
build.sh
|
||||
@@ -1,4 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Retrive the target from the current filename, if no target specified,
|
||||
# the variable will be empty
|
||||
TARGET=$(echo $0 | cut -s -f2 -d- | cut -s -f1 -d.)
|
||||
if [[ -n $TARGET ]]
|
||||
then
|
||||
# Target is not null, specify the build parameters
|
||||
PARAM="-DCMAKE_TOOLCHAIN_FILE=$IDF_PATH/tools/cmake/toolchain-${TARGET}.cmake -DTARGET=${TARGET} -GNinja"
|
||||
fi
|
||||
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake ..
|
||||
cmake .. $PARAM
|
||||
cmake --build .
|
||||
|
||||
1
examples/build_system/cmake/idf_as_lib/run-esp328684.sh
Symbolic link
1
examples/build_system/cmake/idf_as_lib/run-esp328684.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
run-esp32.sh
|
||||
1
examples/build_system/cmake/idf_as_lib/run-esp32c3.sh
Symbolic link
1
examples/build_system/cmake/idf_as_lib/run-esp32c3.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
run-esp32.sh
|
||||
1
examples/build_system/cmake/idf_as_lib/run-esp32h2.sh
Symbolic link
1
examples/build_system/cmake/idf_as_lib/run-esp32h2.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
run-esp32.sh
|
||||
1
examples/build_system/cmake/idf_as_lib/run-esp32s2.sh
Symbolic link
1
examples/build_system/cmake/idf_as_lib/run-esp32s2.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
run-esp32.sh
|
||||
1
examples/build_system/cmake/idf_as_lib/run-esp32s3.sh
Symbolic link
1
examples/build_system/cmake/idf_as_lib/run-esp32s3.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
run-esp32.sh
|
||||
1
examples/build_system/cmake/idf_as_lib/run-esp8684.sh
Symbolic link
1
examples/build_system/cmake/idf_as_lib/run-esp8684.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
run-esp32.sh
|
||||
Reference in New Issue
Block a user