2023-08-28 14:02:08 +08:00
|
|
|
idf_build_get_property(target IDF_TARGET)
|
2024-10-16 13:32:12 +05:30
|
|
|
idf_build_get_property(non_os_build NON_OS_BUILD)
|
2023-08-28 14:02:08 +08:00
|
|
|
|
|
|
|
if(${target} STREQUAL "linux")
|
|
|
|
return() # This component is not supported by the POSIX/Linux simulator
|
|
|
|
endif()
|
|
|
|
|
2024-03-15 12:35:27 +04:00
|
|
|
set(include_dirs "platform_include")
|
|
|
|
|
2024-10-16 13:32:12 +05:30
|
|
|
if(non_os_build)
|
2021-02-18 10:05:42 +11:00
|
|
|
# Bootloader builds need the platform_include directory (for assert.h), but nothing else
|
|
|
|
idf_component_register(INCLUDE_DIRS platform_include)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2020-11-10 18:40:01 +11:00
|
|
|
set(srcs
|
2024-09-26 13:13:20 +07:00
|
|
|
"src/init.c"
|
|
|
|
"src/abort.c"
|
|
|
|
"src/assert.c"
|
|
|
|
"src/heap.c"
|
|
|
|
"src/locks.c"
|
|
|
|
"src/poll.c"
|
|
|
|
"src/pthread.c"
|
|
|
|
"src/random.c"
|
|
|
|
"src/getentropy.c"
|
|
|
|
"src/termios.c"
|
|
|
|
"src/stdatomic.c"
|
|
|
|
"src/time.c"
|
|
|
|
"src/sysconf.c"
|
|
|
|
"src/realpath.c"
|
|
|
|
"src/scandir.c"
|
|
|
|
"src/syscalls.c"
|
|
|
|
"src/reent_syscalls.c"
|
|
|
|
"src/port/esp_time_impl.c")
|
2018-01-12 13:49:13 +11:00
|
|
|
|
2024-01-01 14:13:02 +04:00
|
|
|
if(CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND)
|
2024-09-26 13:13:20 +07:00
|
|
|
list(APPEND srcs "src/port/xtensa/stdatomic_s32c1i.c")
|
2024-01-01 14:13:02 +04:00
|
|
|
endif()
|
|
|
|
|
2024-09-26 13:13:20 +07:00
|
|
|
if(CONFIG_LIBC_NEWLIB)
|
|
|
|
list(APPEND srcs
|
|
|
|
"src/flockfile.c"
|
|
|
|
"src/reent_init.c"
|
|
|
|
"src/newlib_init.c")
|
|
|
|
else()
|
|
|
|
list(APPEND srcs
|
|
|
|
"src/picolibc/picolibc_init.c"
|
|
|
|
"src/picolibc/rand.c"
|
|
|
|
"src/picolibc/open_memstream.c")
|
2019-03-08 15:07:50 +08:00
|
|
|
endif()
|
2019-04-28 11:27:30 +08:00
|
|
|
|
2024-09-26 13:13:20 +07:00
|
|
|
list(APPEND ldfragments "src/newlib.lf" "src/system_libs.lf")
|
|
|
|
|
|
|
|
if(CONFIG_SPIRAM_CACHE_WORKAROUND)
|
|
|
|
if(CONFIG_LIBC_NEWLIB)
|
|
|
|
list(APPEND ldfragments src/esp32-spiram-rom-functions-c.lf)
|
|
|
|
else()
|
|
|
|
list(APPEND ldfragments src/picolibc/esp32-spiram-rom-functions-c.lf)
|
|
|
|
endif()
|
|
|
|
endif()
|
2018-03-22 17:27:10 +11:00
|
|
|
|
2019-04-28 15:38:23 +08:00
|
|
|
idf_component_register(SRCS "${srcs}"
|
2024-09-26 13:13:20 +07:00
|
|
|
INCLUDE_DIRS platform_include
|
2020-06-23 11:53:58 +08:00
|
|
|
PRIV_INCLUDE_DIRS priv_include
|
2021-05-26 18:48:57 +05:30
|
|
|
PRIV_REQUIRES soc spi_flash
|
2020-11-10 18:40:01 +11:00
|
|
|
LDFRAGMENTS "${ldfragments}")
|
2018-01-12 13:49:13 +11:00
|
|
|
|
2019-11-05 12:20:26 +01:00
|
|
|
# Toolchain libraries require code defined in this component
|
|
|
|
idf_component_get_property(newlib newlib COMPONENT_LIB)
|
2022-11-23 15:00:11 +03:00
|
|
|
target_link_libraries(${COMPONENT_LIB} INTERFACE c m ${CONFIG_COMPILER_RT_LIB_NAME} "$<TARGET_FILE:${newlib}>")
|
2018-11-22 12:19:49 +08:00
|
|
|
|
2019-04-01 15:21:12 +08:00
|
|
|
set_source_files_properties(heap.c PROPERTIES COMPILE_FLAGS -fno-builtin)
|
2019-03-18 11:47:00 +08:00
|
|
|
|
2024-01-01 14:13:02 +04:00
|
|
|
if(CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND)
|
2024-09-26 13:13:20 +07:00
|
|
|
set_source_files_properties("src/port/xtensa/stdatomic_s32c1i.c"
|
2024-01-01 14:13:02 +04:00
|
|
|
PROPERTIES COMPILE_FLAGS "-mno-disable-hardware-atomics")
|
|
|
|
endif()
|
|
|
|
|
2021-05-26 18:48:57 +05:30
|
|
|
# Forces the linker to include heap, syscall, pthread, assert, and retargetable locks from this component,
|
2019-11-05 12:20:26 +01:00
|
|
|
# instead of the implementations provided by newlib.
|
2024-09-26 13:13:20 +07:00
|
|
|
list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_include_heap_impl")
|
|
|
|
list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_include_reent_syscalls_impl")
|
|
|
|
list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_include_syscalls_impl")
|
|
|
|
list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_include_pthread_impl")
|
|
|
|
list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_include_assert_impl")
|
|
|
|
list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_include_getentropy_impl")
|
|
|
|
list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_include_init_funcs")
|
|
|
|
list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_init_funcs")
|
2019-11-05 12:20:26 +01:00
|
|
|
target_link_libraries(${COMPONENT_LIB} INTERFACE "${EXTRA_LINK_FLAGS}")
|
2020-01-02 15:52:13 +01:00
|
|
|
|
|
|
|
if(CONFIG_NEWLIB_NANO_FORMAT)
|
2022-11-11 22:46:34 +03:00
|
|
|
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
|
|
|
set(libc_dir_cmd ${CMAKE_C_COMPILER})
|
|
|
|
string(REPLACE " " ";" cflags_list ${CMAKE_C_FLAGS})
|
|
|
|
list(APPEND libc_dir_cmd ${cflags_list} "-print-file-name=libc.a")
|
|
|
|
execute_process(
|
|
|
|
COMMAND ${libc_dir_cmd}
|
|
|
|
OUTPUT_VARIABLE libc_dir
|
|
|
|
)
|
|
|
|
get_filename_component(libc_dir ${libc_dir} DIRECTORY)
|
|
|
|
target_link_directories(${COMPONENT_LIB} INTERFACE "${libc_dir}/nano")
|
|
|
|
else()
|
|
|
|
target_link_libraries(${COMPONENT_LIB} INTERFACE "--specs=nano.specs")
|
|
|
|
endif()
|
2020-01-02 15:52:13 +01:00
|
|
|
endif()
|
2020-06-23 11:53:58 +08:00
|
|
|
|
2024-09-26 13:13:20 +07:00
|
|
|
add_subdirectory(src/port)
|
2022-04-14 20:03:56 +02:00
|
|
|
|
|
|
|
# if lwip is included in the build, add it as a public requirement so that
|
|
|
|
# #include <sys/socket.h> works without any special provisions.
|
|
|
|
idf_component_optional_requires(PUBLIC lwip)
|