[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.
This commit is contained in:
Yakun Xu
2020-02-27 08:49:01 -08:00
committed by GitHub
parent acc24cef18
commit fb16fd44d7
40 changed files with 244 additions and 54 deletions
+5 -5
View File
@@ -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)
+4 -4
View File
@@ -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",
+3 -1
View File
@@ -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
+1 -1
View File
@@ -28,5 +28,5 @@
add_subdirectory(cli)
add_subdirectory(core)
add_subdirectory(lib)
add_subdirectory(ncp)
add_subdirectory(spinel)
+3 -3
View File
@@ -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
+30
View File
@@ -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)
+36
View File
@@ -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
+29
View File
@@ -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))))
+47
View File
@@ -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}
)
+43
View File
@@ -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
@@ -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
+1 -2
View File
@@ -33,13 +33,12 @@
#ifndef HDLC_HPP_
#define HDLC_HPP_
#include "openthread-core-config.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <openthread/error.h>
#include "common/code_utils.hpp"
#include "common/debug.hpp"
#include "common/encoding.hpp"
@@ -59,7 +59,6 @@ COMMON_SOURCES = \
spinel_encoder.cpp \
$(NULL)
include_HEADERS = \
spinel.h \
$(NULL)
+14 -4
View File
@@ -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
)
+10 -10
View File
@@ -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 \
+1 -1
View File
@@ -39,7 +39,7 @@
#include <openthread/error.h>
#include "spinel/spinel.h"
#include "lib/spinel/spinel.h"
namespace ot {
namespace Ncp {
+4 -4
View File
@@ -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 {
+1 -1
View File
@@ -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
+3 -4
View File
@@ -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
+1 -1
View File
@@ -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
+1 -1
View File
@@ -34,7 +34,7 @@
#include "radio_spinel.hpp"
#include "platform-posix.h"
#include "spinel/spinel_decoder.hpp"
#include "lib/spinel/spinel_decoder.hpp"
#include <assert.h>
#include <errno.h>
+1 -1
View File
@@ -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 {
+1 -1
View File
@@ -37,7 +37,7 @@
#include "openthread-posix-config.h"
#include "spinel_interface.hpp"
#include "ncp/hdlc.hpp"
#include "lib/hdlc/hdlc.hpp"
#include <openthread/openthread-system.h>
+1 -1
View File
@@ -37,7 +37,7 @@
#include "openthread-posix-config.h"
#include "ncp/hdlc.hpp"
#include "lib/hdlc/hdlc.hpp"
namespace ot {
namespace PosixApp {
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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"