2023-08-28 06:02:08 +00:00
|
|
|
idf_build_get_property(target IDF_TARGET)
|
|
|
|
|
|
|
|
if(${target} STREQUAL "linux")
|
|
|
|
return() # This component is not supported by the POSIX/Linux simulator
|
|
|
|
endif()
|
|
|
|
|
2024-03-15 08:35:27 +00:00
|
|
|
set(include_dirs "platform_include")
|
|
|
|
if(CMAKE_C_COMPILER_ID MATCHES "Clang") # TODO LLVM-330
|
|
|
|
list(APPEND include_dirs "clang_include")
|
|
|
|
endif()
|
|
|
|
|
2021-02-17 23:05:42 +00:00
|
|
|
if(BOOTLOADER_BUILD)
|
|
|
|
# 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 07:40:01 +00:00
|
|
|
set(srcs
|
2020-02-02 15:18:29 +00:00
|
|
|
"abort.c"
|
2021-05-26 13:18:57 +00:00
|
|
|
"assert.c"
|
2019-06-21 06:29:32 +00:00
|
|
|
"heap.c"
|
2019-04-28 07:38:23 +00:00
|
|
|
"locks.c"
|
|
|
|
"poll.c"
|
|
|
|
"pthread.c"
|
|
|
|
"random.c"
|
2023-08-03 13:25:53 +00:00
|
|
|
"getentropy.c"
|
2019-04-28 07:38:23 +00:00
|
|
|
"reent_init.c"
|
2020-12-30 01:31:16 +00:00
|
|
|
"newlib_init.c"
|
2019-04-28 07:38:23 +00:00
|
|
|
"syscalls.c"
|
|
|
|
"termios.c"
|
2021-02-19 13:41:26 +00:00
|
|
|
"stdatomic.c"
|
2021-11-03 08:26:45 +00:00
|
|
|
"time.c"
|
|
|
|
"sysconf.c"
|
2023-12-21 17:38:35 +00:00
|
|
|
"realpath.c"
|
|
|
|
"scandir.c"
|
|
|
|
)
|
2018-01-12 02:49:13 +00:00
|
|
|
|
2024-01-01 10:13:02 +00:00
|
|
|
if(CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND)
|
|
|
|
list(APPEND srcs "port/xtensa/stdatomic_s32c1i.c")
|
|
|
|
endif()
|
|
|
|
|
2019-11-05 11:20:26 +00:00
|
|
|
if(CONFIG_SPIRAM_CACHE_WORKAROUND)
|
2021-03-10 11:44:58 +00:00
|
|
|
set(ldfragments "esp32-spiram-rom-functions-c.lf")
|
2019-03-08 07:07:50 +00:00
|
|
|
endif()
|
2019-04-28 03:27:30 +00:00
|
|
|
|
2021-03-10 11:44:58 +00:00
|
|
|
list(APPEND ldfragments "newlib.lf" "system_libs.lf")
|
2018-03-22 06:27:10 +00:00
|
|
|
|
2019-04-28 07:38:23 +00:00
|
|
|
idf_component_register(SRCS "${srcs}"
|
2024-03-15 08:35:27 +00:00
|
|
|
INCLUDE_DIRS "${include_dirs}"
|
2020-06-23 03:53:58 +00:00
|
|
|
PRIV_INCLUDE_DIRS priv_include
|
2021-05-26 13:18:57 +00:00
|
|
|
PRIV_REQUIRES soc spi_flash
|
2020-11-10 07:40:01 +00:00
|
|
|
LDFRAGMENTS "${ldfragments}")
|
2018-01-12 02:49:13 +00:00
|
|
|
|
2019-11-05 11:20:26 +00:00
|
|
|
# Toolchain libraries require code defined in this component
|
|
|
|
idf_component_get_property(newlib newlib COMPONENT_LIB)
|
2022-11-23 12:00:11 +00:00
|
|
|
target_link_libraries(${COMPONENT_LIB} INTERFACE c m ${CONFIG_COMPILER_RT_LIB_NAME} "$<TARGET_FILE:${newlib}>")
|
2018-11-22 04:19:49 +00:00
|
|
|
|
2019-04-01 07:21:12 +00:00
|
|
|
set_source_files_properties(heap.c PROPERTIES COMPILE_FLAGS -fno-builtin)
|
2019-03-18 03:47:00 +00:00
|
|
|
|
2024-01-01 10:13:02 +00:00
|
|
|
if(CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND)
|
|
|
|
set_source_files_properties("port/xtensa/stdatomic_s32c1i.c"
|
|
|
|
PROPERTIES COMPILE_FLAGS "-mno-disable-hardware-atomics")
|
|
|
|
endif()
|
|
|
|
|
2021-05-26 13:18:57 +00:00
|
|
|
# Forces the linker to include heap, syscall, pthread, assert, and retargetable locks from this component,
|
2019-11-05 11:20:26 +00:00
|
|
|
# instead of the implementations provided by newlib.
|
|
|
|
list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_heap_impl")
|
|
|
|
list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_syscalls_impl")
|
|
|
|
list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_pthread_impl")
|
2021-05-26 13:18:57 +00:00
|
|
|
list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_assert_impl")
|
2019-11-05 11:20:26 +00:00
|
|
|
target_link_libraries(${COMPONENT_LIB} INTERFACE "${EXTRA_LINK_FLAGS}")
|
2020-01-02 14:52:13 +00:00
|
|
|
|
2023-11-24 06:56:08 +00:00
|
|
|
# Forces the linker to include newlib_init.c
|
|
|
|
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u newlib_include_init_funcs")
|
|
|
|
|
2020-01-02 14:52:13 +00:00
|
|
|
if(CONFIG_NEWLIB_NANO_FORMAT)
|
2022-11-11 19:46:34 +00: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 14:52:13 +00:00
|
|
|
endif()
|
2020-06-23 03:53:58 +00:00
|
|
|
|
|
|
|
add_subdirectory(port)
|
2022-04-14 18:03:56 +00: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)
|