From fb16fd44d715b3f70664c90036333e4b35688376 Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Fri, 28 Feb 2020 00:49:01 +0800 Subject: [PATCH] [build] move hdlc to lib/hdlc (#4590) This commit moves hdlc from src/ncp to src/lib/hdlc, src/spinel is also moved to src/lib/spinel. --- Android.mk | 10 ++-- BUILD.gn | 8 ++-- configure.ac | 4 +- src/CMakeLists.txt | 2 +- src/Makefile.am | 6 +-- src/lib/CMakeLists.txt | 30 ++++++++++++ src/lib/Makefile.am | 36 ++++++++++++++ src/lib/common.am | 29 ++++++++++++ src/lib/hdlc/CMakeLists.txt | 47 +++++++++++++++++++ src/lib/hdlc/Makefile.am | 43 +++++++++++++++++ src/{ncp => lib/hdlc}/hdlc.cpp | 4 -- src/{ncp => lib/hdlc}/hdlc.hpp | 3 +- src/{ => lib}/spinel/CMakeLists.txt | 0 src/{ => lib}/spinel/Makefile.am | 1 - .../spinel/openthread-spinel-config.h | 0 src/{ => lib}/spinel/spinel.c | 0 src/{ => lib}/spinel/spinel.h | 0 src/{ => lib}/spinel/spinel_buffer.cpp | 0 src/{ => lib}/spinel/spinel_buffer.hpp | 0 src/{ => lib}/spinel/spinel_decoder.cpp | 0 src/{ => lib}/spinel/spinel_decoder.hpp | 0 src/{ => lib}/spinel/spinel_encoder.cpp | 0 src/{ => lib}/spinel/spinel_encoder.hpp | 0 src/{ => lib}/spinel/spinel_encrypter.hpp | 0 src/{ => lib}/spinel/spinel_platform.h | 0 src/ncp/CMakeLists.txt | 18 +++++-- src/ncp/Makefile.am | 20 ++++---- src/ncp/changed_props_set.hpp | 2 +- src/ncp/ncp_base.hpp | 8 ++-- src/ncp/ncp_uart.hpp | 2 +- src/posix/platform/CMakeLists.txt | 7 ++- src/posix/platform/hdlc_interface.hpp | 2 +- src/posix/platform/radio_spinel.cpp | 2 +- src/posix/platform/radio_spinel.hpp | 2 +- src/posix/platform/spi_interface.hpp | 2 +- src/posix/platform/spinel_interface.hpp | 2 +- tests/unit/test_hdlc.cpp | 2 +- tests/unit/test_spinel_buffer.cpp | 2 +- tests/unit/test_spinel_decoder.cpp | 2 +- tests/unit/test_spinel_encoder.cpp | 2 +- 40 files changed, 244 insertions(+), 54 deletions(-) create mode 100644 src/lib/CMakeLists.txt create mode 100644 src/lib/Makefile.am create mode 100644 src/lib/common.am create mode 100644 src/lib/hdlc/CMakeLists.txt create mode 100644 src/lib/hdlc/Makefile.am rename src/{ncp => lib/hdlc}/hdlc.cpp (98%) rename src/{ncp => lib/hdlc}/hdlc.hpp (99%) rename src/{ => lib}/spinel/CMakeLists.txt (100%) rename src/{ => lib}/spinel/Makefile.am (99%) rename src/{ => lib}/spinel/openthread-spinel-config.h (100%) rename src/{ => lib}/spinel/spinel.c (100%) rename src/{ => lib}/spinel/spinel.h (100%) rename src/{ => lib}/spinel/spinel_buffer.cpp (100%) rename src/{ => lib}/spinel/spinel_buffer.hpp (100%) rename src/{ => lib}/spinel/spinel_decoder.cpp (100%) rename src/{ => lib}/spinel/spinel_decoder.hpp (100%) rename src/{ => lib}/spinel/spinel_encoder.cpp (100%) rename src/{ => lib}/spinel/spinel_encoder.hpp (100%) rename src/{ => lib}/spinel/spinel_encrypter.hpp (100%) rename src/{ => lib}/spinel/spinel_platform.h (100%) diff --git a/Android.mk b/Android.mk index ca22a7fed..5ab410b5b 100644 --- a/Android.mk +++ b/Android.mk @@ -240,7 +240,10 @@ LOCAL_SRC_FILES := \ src/core/utils/jam_detector.cpp \ src/core/utils/parse_cmdline.cpp \ src/core/utils/slaac_address.cpp \ - src/ncp/hdlc.cpp \ + src/lib/hdlc/hdlc.cpp \ + src/lib/spinel/spinel.c \ + src/lib/spinel/spinel_decoder.cpp \ + src/lib/spinel/spinel_encoder.cpp \ src/posix/platform/alarm.cpp \ src/posix/platform/entropy.cpp \ src/posix/platform/hdlc_interface.cpp \ @@ -253,9 +256,6 @@ LOCAL_SRC_FILES := \ src/posix/platform/system.cpp \ src/posix/platform/uart.cpp \ src/posix/platform/udp.cpp \ - src/spinel/spinel.c \ - src/spinel/spinel_decoder.cpp \ - src/spinel/spinel_encoder.cpp \ third_party/mbedtls/repo/library/md.c \ third_party/mbedtls/repo/library/md_wrap.c \ third_party/mbedtls/repo/library/memory_buffer_alloc.c \ @@ -395,13 +395,13 @@ LOCAL_CPPFLAGS := \ $(NULL) LOCAL_SRC_FILES := \ + src/lib/spinel/spinel_buffer.cpp \ src/ncp/changed_props_set.cpp \ src/ncp/ncp_base.cpp \ src/ncp/ncp_base_mtd.cpp \ src/ncp/ncp_base_ftd.cpp \ src/ncp/ncp_base_dispatcher.cpp \ src/ncp/ncp_uart.cpp \ - src/spinel/spinel_buffer.cpp \ $(NULL) include $(BUILD_STATIC_LIBRARY) diff --git a/BUILD.gn b/BUILD.gn index a8f9dc462..033120c35 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -161,10 +161,10 @@ static_library("lib-ot-core") { "src/core/utils/jam_detector.cpp", "src/core/utils/parse_cmdline.cpp", "src/core/utils/slaac_address.cpp", - "src/ncp/hdlc.cpp", - "src/spinel/spinel.c", - "src/spinel/spinel_decoder.cpp", - "src/spinel/spinel_encoder.cpp", + "src/lib/hdlc/hdlc.cpp", + "src/lib/spinel/spinel.c", + "src/lib/spinel/spinel_decoder.cpp", + "src/lib/spinel/spinel_encoder.cpp", "third_party/mbedtls/repo/library/md.c", "third_party/mbedtls/repo/library/md_wrap.c", "third_party/mbedtls/repo/library/memory_buffer_alloc.c", diff --git a/configure.ac b/configure.ac index 253d0bb52..e1869f439 100644 --- a/configure.ac +++ b/configure.ac @@ -1065,7 +1065,9 @@ src/ncp/Makefile src/core/Makefile src/posix/Makefile src/posix/platform/Makefile -src/spinel/Makefile +src/lib/Makefile +src/lib/hdlc/Makefile +src/lib/spinel/Makefile third_party/Makefile third_party/jlink/Makefile third_party/mbedtls/Makefile diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6b724c10b..9b6bc0249 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -28,5 +28,5 @@ add_subdirectory(cli) add_subdirectory(core) +add_subdirectory(lib) add_subdirectory(ncp) -add_subdirectory(spinel) diff --git a/src/Makefile.am b/src/Makefile.am index 75197cdc4..742551b18 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,16 +33,16 @@ include $(abs_top_nlbuild_autotools_dir)/automake/pre.am DIST_SUBDIRS = \ core \ cli \ + lib \ ncp \ posix \ - spinel \ $(NULL) # Always build (e.g. for 'make all') these subdirectories. SUBDIRS = \ core \ - spinel \ + lib \ $(NULL) if OPENTHREAD_ENABLE_CLI @@ -64,7 +64,7 @@ PRETTY_SUBDIRS = \ core \ ncp \ posix \ - spinel \ + lib \ $(NULL) include $(abs_top_nlbuild_autotools_dir)/automake/post.am diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt new file mode 100644 index 000000000..5e68e9450 --- /dev/null +++ b/src/lib/CMakeLists.txt @@ -0,0 +1,30 @@ +# +# Copyright (c) 2020, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +add_subdirectory(hdlc) +add_subdirectory(spinel) diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am new file mode 100644 index 000000000..f9a4f7b04 --- /dev/null +++ b/src/lib/Makefile.am @@ -0,0 +1,36 @@ +# +# Copyright (c) 2020, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +include $(abs_top_nlbuild_autotools_dir)/automake/pre.am + +SUBDIRS = \ + hdlc \ + spinel \ + $(NULL) + +include $(abs_top_nlbuild_autotools_dir)/automake/post.am diff --git a/src/lib/common.am b/src/lib/common.am new file mode 100644 index 000000000..94c34de10 --- /dev/null +++ b/src/lib/common.am @@ -0,0 +1,29 @@ +# +# Copyright (c) 2020, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +ot_list_objects = $(addprefix $(dir $(1)),$(filter %.o,$(shell $(AR) t $(1)))) diff --git a/src/lib/hdlc/CMakeLists.txt b/src/lib/hdlc/CMakeLists.txt new file mode 100644 index 000000000..a56185a52 --- /dev/null +++ b/src/lib/hdlc/CMakeLists.txt @@ -0,0 +1,47 @@ +# +# Copyright (c) 2020, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +add_library(openthread-hdlc + hdlc.cpp +) + +target_include_directories(openthread-hdlc + PUBLIC + ${OT_PUBLIC_INCLUDES} + PRIVATE + ${PROJECT_SOURCE_DIR}/src/core + ${OT_PRIVATE_INCLUDES} +) + +target_compile_definitions(openthread-hdlc PRIVATE + ${OT_PRIVATE_DEFINES} +) + +target_compile_options(openthread-hdlc PRIVATE + ${OT_CFLAGS} +) diff --git a/src/lib/hdlc/Makefile.am b/src/lib/hdlc/Makefile.am new file mode 100644 index 000000000..c410f1469 --- /dev/null +++ b/src/lib/hdlc/Makefile.am @@ -0,0 +1,43 @@ +# +# Copyright (c) 2020, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +include $(abs_top_nlbuild_autotools_dir)/automake/pre.am + +noinst_LIBRARIES = libopenthread-hdlc.a + +libopenthread_hdlc_a_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/src/core \ + $(NULL) + +libopenthread_hdlc_a_SOURCES = \ + hdlc.cpp \ + hdlc.hpp \ + $(NULL) + +include $(abs_top_nlbuild_autotools_dir)/automake/post.am diff --git a/src/ncp/hdlc.cpp b/src/lib/hdlc/hdlc.cpp similarity index 98% rename from src/ncp/hdlc.cpp rename to src/lib/hdlc/hdlc.cpp index 754365d6a..ea9c5165b 100644 --- a/src/ncp/hdlc.cpp +++ b/src/lib/hdlc/hdlc.cpp @@ -36,8 +36,6 @@ #include "common/code_utils.hpp" -#if OPENTHREAD_CONFIG_NCP_UART_ENABLE || OPENTHREAD_PLATFORM_POSIX_APP - namespace ot { namespace Hdlc { @@ -300,5 +298,3 @@ void Decoder::Decode(const uint8_t *aData, uint16_t aLength) } // namespace Hdlc } // namespace ot - -#endif // OPENTHREAD_CONFIG_NCP_UART_ENABLE || OPENTHREAD_PLATFORM_POSIX_APP diff --git a/src/ncp/hdlc.hpp b/src/lib/hdlc/hdlc.hpp similarity index 99% rename from src/ncp/hdlc.hpp rename to src/lib/hdlc/hdlc.hpp index aacbd5737..4edf57845 100644 --- a/src/ncp/hdlc.hpp +++ b/src/lib/hdlc/hdlc.hpp @@ -33,13 +33,12 @@ #ifndef HDLC_HPP_ #define HDLC_HPP_ -#include "openthread-core-config.h" - #include #include #include #include + #include "common/code_utils.hpp" #include "common/debug.hpp" #include "common/encoding.hpp" diff --git a/src/spinel/CMakeLists.txt b/src/lib/spinel/CMakeLists.txt similarity index 100% rename from src/spinel/CMakeLists.txt rename to src/lib/spinel/CMakeLists.txt diff --git a/src/spinel/Makefile.am b/src/lib/spinel/Makefile.am similarity index 99% rename from src/spinel/Makefile.am rename to src/lib/spinel/Makefile.am index c9812fa74..3823aff69 100644 --- a/src/spinel/Makefile.am +++ b/src/lib/spinel/Makefile.am @@ -59,7 +59,6 @@ COMMON_SOURCES = \ spinel_encoder.cpp \ $(NULL) - include_HEADERS = \ spinel.h \ $(NULL) diff --git a/src/spinel/openthread-spinel-config.h b/src/lib/spinel/openthread-spinel-config.h similarity index 100% rename from src/spinel/openthread-spinel-config.h rename to src/lib/spinel/openthread-spinel-config.h diff --git a/src/spinel/spinel.c b/src/lib/spinel/spinel.c similarity index 100% rename from src/spinel/spinel.c rename to src/lib/spinel/spinel.c diff --git a/src/spinel/spinel.h b/src/lib/spinel/spinel.h similarity index 100% rename from src/spinel/spinel.h rename to src/lib/spinel/spinel.h diff --git a/src/spinel/spinel_buffer.cpp b/src/lib/spinel/spinel_buffer.cpp similarity index 100% rename from src/spinel/spinel_buffer.cpp rename to src/lib/spinel/spinel_buffer.cpp diff --git a/src/spinel/spinel_buffer.hpp b/src/lib/spinel/spinel_buffer.hpp similarity index 100% rename from src/spinel/spinel_buffer.hpp rename to src/lib/spinel/spinel_buffer.hpp diff --git a/src/spinel/spinel_decoder.cpp b/src/lib/spinel/spinel_decoder.cpp similarity index 100% rename from src/spinel/spinel_decoder.cpp rename to src/lib/spinel/spinel_decoder.cpp diff --git a/src/spinel/spinel_decoder.hpp b/src/lib/spinel/spinel_decoder.hpp similarity index 100% rename from src/spinel/spinel_decoder.hpp rename to src/lib/spinel/spinel_decoder.hpp diff --git a/src/spinel/spinel_encoder.cpp b/src/lib/spinel/spinel_encoder.cpp similarity index 100% rename from src/spinel/spinel_encoder.cpp rename to src/lib/spinel/spinel_encoder.cpp diff --git a/src/spinel/spinel_encoder.hpp b/src/lib/spinel/spinel_encoder.hpp similarity index 100% rename from src/spinel/spinel_encoder.hpp rename to src/lib/spinel/spinel_encoder.hpp diff --git a/src/spinel/spinel_encrypter.hpp b/src/lib/spinel/spinel_encrypter.hpp similarity index 100% rename from src/spinel/spinel_encrypter.hpp rename to src/lib/spinel/spinel_encrypter.hpp diff --git a/src/spinel/spinel_platform.h b/src/lib/spinel/spinel_platform.h similarity index 100% rename from src/spinel/spinel_platform.h rename to src/lib/spinel/spinel_platform.h diff --git a/src/ncp/CMakeLists.txt b/src/ncp/CMakeLists.txt index ca49e4cae..c887c9a87 100644 --- a/src/ncp/CMakeLists.txt +++ b/src/ncp/CMakeLists.txt @@ -76,7 +76,6 @@ set(COMMON_INCLUDES set(COMMON_SOURCES changed_props_set.cpp - hdlc.cpp ncp_base.cpp ncp_base_ftd.cpp ncp_base_mtd.cpp @@ -94,6 +93,17 @@ target_sources(openthread-ncp-ftd PRIVATE ${COMMON_SOURCES}) target_sources(openthread-ncp-mtd PRIVATE ${COMMON_SOURCES}) target_sources(openthread-rcp PRIVATE ${COMMON_SOURCES}) -target_link_libraries(openthread-ncp-ftd openthread-spinel-ncp) -target_link_libraries(openthread-ncp-mtd openthread-spinel-ncp) -target_link_libraries(openthread-rcp openthread-spinel-rcp) +target_link_libraries(openthread-ncp-ftd PRIVATE + openthread-hdlc + openthread-spinel-ncp +) + +target_link_libraries(openthread-ncp-mtd PRIVATE + openthread-hdlc + openthread-spinel-ncp +) + +target_link_libraries(openthread-rcp PRIVATE + openthread-hdlc + openthread-spinel-rcp +) diff --git a/src/ncp/Makefile.am b/src/ncp/Makefile.am index 2711b570d..7733e9f8a 100644 --- a/src/ncp/Makefile.am +++ b/src/ncp/Makefile.am @@ -27,6 +27,7 @@ # include $(abs_top_nlbuild_autotools_dir)/automake/pre.am +include $(top_srcdir)/src/lib/common.am EXTRA_DIST = \ example_vendor_hook.cpp \ @@ -82,25 +83,24 @@ libopenthread_rcp_a_CPPFLAGS = \ $(COMMON_CPPFLAGS) \ $(NULL) -list_objects = $(addprefix $(dir $(1)),$(filter %.o,$(shell $(AR) t $(1)))) - -libopenthread_ncp_mtd_a_LIBADD = \ - $(call list_objects,$(top_builddir)/src/spinel/libopenthread-spinel-ncp.a) \ +libopenthread_ncp_mtd_a_LIBADD = \ + $(call ot_list_objects,$(top_builddir)/src/lib/hdlc/libopenthread-hdlc.a) \ + $(call ot_list_objects,$(top_builddir)/src/lib/spinel/libopenthread-spinel-ncp.a) \ $(NULL) -libopenthread_ncp_ftd_a_LIBADD = \ - $(call list_objects,$(top_builddir)/src/spinel/libopenthread-spinel-ncp.a) \ +libopenthread_ncp_ftd_a_LIBADD = \ + $(call ot_list_objects,$(top_builddir)/src/lib/hdlc/libopenthread-hdlc.a ) \ + $(call ot_list_objects,$(top_builddir)/src/lib/spinel/libopenthread-spinel-ncp.a) \ $(NULL) -libopenthread_rcp_a_LIBADD = \ - $(call list_objects,$(top_builddir)/src/spinel/libopenthread-spinel-rcp.a) \ +libopenthread_rcp_a_LIBADD = \ + $(call ot_list_objects,$(top_builddir)/src/lib/hdlc/libopenthread-hdlc.a) \ + $(call ot_list_objects,$(top_builddir)/src/lib/spinel/libopenthread-spinel-rcp.a) \ $(NULL) COMMON_SOURCES = \ changed_props_set.cpp \ changed_props_set.hpp \ - hdlc.cpp \ - hdlc.hpp \ ncp_base.cpp \ ncp_base.hpp \ ncp_base_ftd.cpp \ diff --git a/src/ncp/changed_props_set.hpp b/src/ncp/changed_props_set.hpp index 75b2b3305..aa8fc0c25 100644 --- a/src/ncp/changed_props_set.hpp +++ b/src/ncp/changed_props_set.hpp @@ -39,7 +39,7 @@ #include -#include "spinel/spinel.h" +#include "lib/spinel/spinel.h" namespace ot { namespace Ncp { diff --git a/src/ncp/ncp_base.hpp b/src/ncp/ncp_base.hpp index 70ae05b16..4285c2310 100644 --- a/src/ncp/ncp_base.hpp +++ b/src/ncp/ncp_base.hpp @@ -51,10 +51,10 @@ #include "changed_props_set.hpp" #include "common/instance.hpp" #include "common/tasklet.hpp" -#include "spinel/spinel.h" -#include "spinel/spinel_buffer.hpp" -#include "spinel/spinel_decoder.hpp" -#include "spinel/spinel_encoder.hpp" +#include "lib/spinel/spinel.h" +#include "lib/spinel/spinel_buffer.hpp" +#include "lib/spinel/spinel_decoder.hpp" +#include "lib/spinel/spinel_encoder.hpp" #include "utils/static_assert.hpp" namespace ot { diff --git a/src/ncp/ncp_uart.hpp b/src/ncp/ncp_uart.hpp index 5aa9dd9a5..52214032f 100644 --- a/src/ncp/ncp_uart.hpp +++ b/src/ncp/ncp_uart.hpp @@ -35,7 +35,7 @@ #include "openthread-core-config.h" -#include "ncp/hdlc.hpp" +#include "lib/hdlc/hdlc.hpp" #include "ncp/ncp_base.hpp" #if OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER diff --git a/src/posix/platform/CMakeLists.txt b/src/posix/platform/CMakeLists.txt index b66022bd6..eef952411 100644 --- a/src/posix/platform/CMakeLists.txt +++ b/src/posix/platform/CMakeLists.txt @@ -62,10 +62,9 @@ target_link_libraries(openthread-posix PUBLIC util ) -target_compile_definitions(openthread-posix PUBLIC - ${OT_PRIVATE_DEFINES} - ${OT_PUBLIC_DEFINES} - ${OT_PLATFORM_DEFINES} +target_compile_definitions(openthread-posix + PUBLIC ${OT_PLATFORM_DEFINES} + PRIVATE ${OT_PRIVATE_DEFINES} ) target_compile_options(openthread-posix PRIVATE diff --git a/src/posix/platform/hdlc_interface.hpp b/src/posix/platform/hdlc_interface.hpp index 34948ea2c..dcd2b7514 100644 --- a/src/posix/platform/hdlc_interface.hpp +++ b/src/posix/platform/hdlc_interface.hpp @@ -37,7 +37,7 @@ #include "openthread-posix-config.h" #include "platform-posix.h" #include "spinel_interface.hpp" -#include "ncp/hdlc.hpp" +#include "lib/hdlc/hdlc.hpp" #if OPENTHREAD_POSIX_RCP_UART_ENABLE diff --git a/src/posix/platform/radio_spinel.cpp b/src/posix/platform/radio_spinel.cpp index cdb74c01c..9273603be 100644 --- a/src/posix/platform/radio_spinel.cpp +++ b/src/posix/platform/radio_spinel.cpp @@ -34,7 +34,7 @@ #include "radio_spinel.hpp" #include "platform-posix.h" -#include "spinel/spinel_decoder.hpp" +#include "lib/spinel/spinel_decoder.hpp" #include #include diff --git a/src/posix/platform/radio_spinel.hpp b/src/posix/platform/radio_spinel.hpp index cf04fcf7b..1a7727039 100644 --- a/src/posix/platform/radio_spinel.hpp +++ b/src/posix/platform/radio_spinel.hpp @@ -51,8 +51,8 @@ #endif #include "spinel_interface.hpp" +#include "lib/spinel/spinel.h" #include "ncp/ncp_config.h" -#include "spinel/spinel.h" namespace ot { namespace PosixApp { diff --git a/src/posix/platform/spi_interface.hpp b/src/posix/platform/spi_interface.hpp index 621c313b4..d2a54f21a 100644 --- a/src/posix/platform/spi_interface.hpp +++ b/src/posix/platform/spi_interface.hpp @@ -37,7 +37,7 @@ #include "openthread-posix-config.h" #include "spinel_interface.hpp" -#include "ncp/hdlc.hpp" +#include "lib/hdlc/hdlc.hpp" #include diff --git a/src/posix/platform/spinel_interface.hpp b/src/posix/platform/spinel_interface.hpp index decfefb2c..adce2f975 100644 --- a/src/posix/platform/spinel_interface.hpp +++ b/src/posix/platform/spinel_interface.hpp @@ -37,7 +37,7 @@ #include "openthread-posix-config.h" -#include "ncp/hdlc.hpp" +#include "lib/hdlc/hdlc.hpp" namespace ot { namespace PosixApp { diff --git a/tests/unit/test_hdlc.cpp b/tests/unit/test_hdlc.cpp index a4785316d..8721052b4 100644 --- a/tests/unit/test_hdlc.cpp +++ b/tests/unit/test_hdlc.cpp @@ -30,7 +30,7 @@ #include "common/code_utils.hpp" #include "common/instance.hpp" -#include "ncp/hdlc.hpp" +#include "lib/hdlc/hdlc.hpp" #include "test_util.h" diff --git a/tests/unit/test_spinel_buffer.cpp b/tests/unit/test_spinel_buffer.cpp index 7bc898d46..626a0e4b7 100644 --- a/tests/unit/test_spinel_buffer.cpp +++ b/tests/unit/test_spinel_buffer.cpp @@ -32,7 +32,7 @@ #include "common/instance.hpp" #include "common/message.hpp" #include "common/random.hpp" -#include "spinel/spinel_buffer.hpp" +#include "lib/spinel/spinel_buffer.hpp" #include "test_platform.h" #include "test_util.hpp" diff --git a/tests/unit/test_spinel_decoder.cpp b/tests/unit/test_spinel_decoder.cpp index 615c228e9..36a8f0cb1 100644 --- a/tests/unit/test_spinel_decoder.cpp +++ b/tests/unit/test_spinel_decoder.cpp @@ -28,7 +28,7 @@ #include "common/code_utils.hpp" #include "common/instance.hpp" -#include "spinel/spinel_decoder.hpp" +#include "lib/spinel/spinel_decoder.hpp" #include "test_util.hpp" diff --git a/tests/unit/test_spinel_encoder.cpp b/tests/unit/test_spinel_encoder.cpp index b4fc03deb..65dccd187 100644 --- a/tests/unit/test_spinel_encoder.cpp +++ b/tests/unit/test_spinel_encoder.cpp @@ -28,7 +28,7 @@ #include "common/code_utils.hpp" #include "common/instance.hpp" -#include "spinel/spinel_encoder.hpp" +#include "lib/spinel/spinel_encoder.hpp" #include "test_util.hpp"