From 5058500e5d63e1755b89ec25ce3a8b5705f595a5 Mon Sep 17 00:00:00 2001 From: Zhanglong Xia Date: Fri, 3 Nov 2023 00:11:26 +0800 Subject: [PATCH] [build] move `radio_spinel.cpp` to new lib `openthread-radio-spinel` (#9530) The lib `openthread-spinel-ncp` is used by the NCP build, it doesn't need the file `radio_spinel.cpp`. This commit changes the CMake file to make only the lib `openthread-spinel-rcp` include the file `radio_spinel.cpp`. --- src/lib/spinel/CMakeLists.txt | 23 ++++++++++++----------- src/posix/cli.cmake | 1 + src/posix/daemon.cmake | 1 + src/posix/platform/CMakeLists.txt | 1 + 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/lib/spinel/CMakeLists.txt b/src/lib/spinel/CMakeLists.txt index de68fc25a6a..e6cf16f58fd 100644 --- a/src/lib/spinel/CMakeLists.txt +++ b/src/lib/spinel/CMakeLists.txt @@ -26,27 +26,22 @@ # POSSIBILITY OF SUCH DAMAGE. # +add_library(openthread-radio-spinel) add_library(openthread-spinel-ncp) add_library(openthread-spinel-rcp) target_compile_definitions(openthread-spinel-ncp PRIVATE - OPENTHREAD_FTD=1 PUBLIC OPENTHREAD_SPINEL_CONFIG_OPENTHREAD_MESSAGE_ENABLE=1 ) -if (OT_NCP_SPI) - target_compile_definitions(openthread-spinel-ncp PRIVATE OPENTHREAD_CONFIG_NCP_HDLC_ENABLE=0) - target_compile_definitions(openthread-spinel-rcp PRIVATE OPENTHREAD_CONFIG_NCP_HDLC_ENABLE=0) -else() - target_compile_definitions(openthread-spinel-ncp PRIVATE OPENTHREAD_CONFIG_NCP_HDLC_ENABLE=1) - target_compile_definitions(openthread-spinel-rcp PRIVATE OPENTHREAD_CONFIG_NCP_HDLC_ENABLE=1) -endif() - target_compile_definitions(openthread-spinel-rcp PRIVATE - OPENTHREAD_RADIO=1 PUBLIC OPENTHREAD_SPINEL_CONFIG_OPENTHREAD_MESSAGE_ENABLE=0 ) +target_compile_options(openthread-radio-spinel PRIVATE + ${OT_CFLAGS} +) + target_compile_options(openthread-spinel-ncp PRIVATE ${OT_CFLAGS} ) @@ -61,19 +56,25 @@ set(COMMON_INCLUDES ) set(COMMON_SOURCES - radio_spinel.cpp spinel.c spinel_buffer.cpp spinel_decoder.cpp spinel_encoder.cpp ) +target_include_directories(openthread-radio-spinel PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES}) target_include_directories(openthread-spinel-ncp PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES}) target_include_directories(openthread-spinel-rcp PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES}) +target_sources(openthread-radio-spinel PRIVATE radio_spinel.cpp) target_sources(openthread-spinel-ncp PRIVATE ${COMMON_SOURCES}) target_sources(openthread-spinel-rcp PRIVATE ${COMMON_SOURCES}) +target_link_libraries(openthread-radio-spinel + PRIVATE + ot-config +) + target_link_libraries(openthread-spinel-ncp PRIVATE ot-config-ftd diff --git a/src/posix/cli.cmake b/src/posix/cli.cmake index 4b7347b4039..a11ef0b8545 100644 --- a/src/posix/cli.cmake +++ b/src/posix/cli.cmake @@ -50,6 +50,7 @@ target_link_libraries(ot-cli PRIVATE openthread-posix openthread-cli-ftd openthread-hdlc + openthread-radio-spinel openthread-spinel-rcp ${OT_MBEDTLS} ${READLINE_LINK_LIBRARIES} diff --git a/src/posix/daemon.cmake b/src/posix/daemon.cmake index dd726df27b7..dd19a22806a 100644 --- a/src/posix/daemon.cmake +++ b/src/posix/daemon.cmake @@ -42,6 +42,7 @@ target_link_libraries(ot-daemon PRIVATE openthread-ftd openthread-posix openthread-hdlc + openthread-radio-spinel openthread-spinel-rcp ${OT_MBEDTLS} ot-posix-config diff --git a/src/posix/platform/CMakeLists.txt b/src/posix/platform/CMakeLists.txt index b367d8758d6..dfc62408eba 100644 --- a/src/posix/platform/CMakeLists.txt +++ b/src/posix/platform/CMakeLists.txt @@ -154,6 +154,7 @@ target_link_libraries(openthread-posix openthread-cli-ftd openthread-ftd openthread-hdlc + openthread-radio-spinel openthread-spinel-rcp openthread-url ot-config-ftd