From b598fa337c62a95e3528cb6a14ab366f1189b8a8 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Fri, 16 Aug 2019 15:44:43 -0700 Subject: [PATCH] [cmake] initial implementation (#4112) --- .gitignore | 7 +- CMakeLists.txt | 94 ++++++++ etc/cmake/checks.cmake | 35 +++ etc/cmake/openthread-config-generic.h.in | 36 +++ etc/cmake/options.cmake | 166 ++++++++++++++ examples/CMakeLists.txt | 33 +++ examples/apps/CMakeLists.txt | 30 +++ examples/apps/cli/CMakeLists.txt | 63 +++++ examples/apps/ncp/CMakeLists.txt | 76 +++++++ examples/platforms/CMakeLists.txt | 29 +++ examples/platforms/cc2538/CMakeLists.txt | 47 ++++ examples/platforms/cc2538/arm-none-eabi.cmake | 52 +++++ examples/platforms/cc2538/platform.cmake | 43 ++++ examples/platforms/posix/CMakeLists.txt | 55 +++++ examples/platforms/posix/README.md | 21 +- examples/platforms/posix/platform.cmake | 40 ++++ examples/platforms/utils/CMakeLists.txt | 49 ++++ src/CMakeLists.txt | 31 +++ src/cli/CMakeLists.txt | 65 ++++++ src/core/CMakeLists.txt | 215 ++++++++++++++++++ src/core/api/dataset_api.cpp | 1 + src/core/common/instance.hpp | 3 + src/ncp/CMakeLists.txt | 79 +++++++ src/ncp/spinel_decoder.cpp | 1 + src/ncp/spinel_encoder.cpp | 1 + third_party/CMakeLists.txt | 31 +++ third_party/mbedtls/CMakeLists.txt | 80 +++++++ 27 files changed, 1378 insertions(+), 5 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 etc/cmake/checks.cmake create mode 100644 etc/cmake/openthread-config-generic.h.in create mode 100644 etc/cmake/options.cmake create mode 100644 examples/CMakeLists.txt create mode 100644 examples/apps/CMakeLists.txt create mode 100644 examples/apps/cli/CMakeLists.txt create mode 100644 examples/apps/ncp/CMakeLists.txt create mode 100644 examples/platforms/CMakeLists.txt create mode 100644 examples/platforms/cc2538/CMakeLists.txt create mode 100644 examples/platforms/cc2538/arm-none-eabi.cmake create mode 100644 examples/platforms/cc2538/platform.cmake create mode 100644 examples/platforms/posix/CMakeLists.txt create mode 100644 examples/platforms/posix/platform.cmake create mode 100644 examples/platforms/utils/CMakeLists.txt create mode 100644 src/CMakeLists.txt create mode 100644 src/cli/CMakeLists.txt create mode 100644 src/core/CMakeLists.txt create mode 100644 src/ncp/CMakeLists.txt create mode 100644 third_party/CMakeLists.txt create mode 100644 third_party/mbedtls/CMakeLists.txt diff --git a/.gitignore b/.gitignore index 2635a74c2..5bbdeab7d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ *.o *.lo *.la +*.ninja* *.opendb *.orig *.pyc @@ -25,13 +26,15 @@ aclocal.m4 autom4te.cache build +CMakeCache.txt +CMakeFiles +cmake_install.cmake configure config.log config.status doc/Doxyfile doc/html -etc/visual-studio/BundleArtifacts -etc/visual-studio/Generated Files +etc/cmake/openthread-config-generic.h include/openthread-config.h include/openthread-config.h.in include/openthread-config-generic.h diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..f55bb4fd8 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,94 @@ +# +# Copyright (c) 2019, 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. +# + +cmake_minimum_required(VERSION 3.13.1) +project(openthread) + +option(OT_BUILD_EXECUTABLES "Build executables" ON) +option(OT_BUILTIN_MBEDTLS "Enable builtin mbedTLS" ON) + +set(OT_ROOT_DIR ${PROJECT_SOURCE_DIR} CACHE INTERNAL "OpenThread source root.") + +include("${OT_ROOT_DIR}/etc/cmake/checks.cmake") +include("${OT_ROOT_DIR}/etc/cmake/options.cmake") + +execute_process( + COMMAND "${OT_ROOT_DIR}/third_party/nlbuild-autotools/repo/scripts/mkversion" "-b" "`cat .default-version`" "." + OUTPUT_VARIABLE __version OUTPUT_STRIP_TRAILING_WHITESPACE +) +set(OT_VERSION "${__version}") + +add_definitions( + -DPACKAGE_NAME="OPENTHREAD" + -DPACKAGE_VERSION="${OT_VERSION}" +) + +set(OT_PLATFORM "none" CACHE STRING "Target platform chosen by the user at configure time") + +function(ot_get_platforms arg_platforms) + set(result "none") + set(platforms_dir "${OT_ROOT_DIR}/examples/platforms") + file(GLOB platforms RELATIVE "${platforms_dir}" "${platforms_dir}/*") + foreach(platform IN LISTS platforms) + if(IS_DIRECTORY "${platforms_dir}/${platform}") + list(APPEND result "${platform}") + endif() + endforeach() + + set(${arg_platforms} "${result}" PARENT_SCOPE) +endfunction() + +ot_get_platforms(OT_EXAMPLE_PLATFORMS) +set_property(CACHE OT_PLATFORM PROPERTY STRINGS ${OT_EXAMPLE_PLATFORMS}) +if(NOT OT_PLATFORM IN_LIST OT_EXAMPLE_PLATFORMS) + message(FATAL_ERROR "Platform unknown: ${OT_PLATFORM}") +endif() + +list(APPEND OT_PUBLIC_INCLUDES ${OT_ROOT_DIR}/etc/cmake) +list(APPEND OT_PUBLIC_INCLUDES ${OT_ROOT_DIR}/include) + +if(NOT OT_PLATFORM MATCHES "none") + list(APPEND OT_PRIVATE_INCLUDES ${OT_ROOT_DIR}/examples/platforms/${OT_PLATFORM}) + include("${OT_ROOT_DIR}/examples/platforms/${OT_PLATFORM}/platform.cmake") +endif() + +if(OT_BUILTIN_MBEDTLS) + list(APPEND OT_PRIVATE_INCLUDES ${OT_ROOT_DIR}/third_party/mbedtls) + list(APPEND OT_PRIVATE_INCLUDES ${OT_ROOT_DIR}/third_party/mbedtls/repo/include) + + add_definitions( + -DMBEDTLS_CONFIG_FILE="mbedtls-config.h" + ) +endif() + +if(NOT OT_PLATFORM MATCHES "none") + add_subdirectory(examples) +endif() + +add_subdirectory(src) +add_subdirectory(third_party) diff --git a/etc/cmake/checks.cmake b/etc/cmake/checks.cmake new file mode 100644 index 000000000..727721cdf --- /dev/null +++ b/etc/cmake/checks.cmake @@ -0,0 +1,35 @@ +# +# Copyright (c) 2019, 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(CheckFunctionExists) + +check_function_exists("strlcat" HAVE_STRLCAT) +check_function_exists("strlcpy" HAVE_STRLCPY) +check_function_exists("strnlen" HAVE_STRNLEN) + +configure_file(${OT_ROOT_DIR}/etc/cmake/openthread-config-generic.h.in ${OT_ROOT_DIR}/etc/cmake/openthread-config-generic.h) diff --git a/etc/cmake/openthread-config-generic.h.in b/etc/cmake/openthread-config-generic.h.in new file mode 100644 index 000000000..95c8b5a51 --- /dev/null +++ b/etc/cmake/openthread-config-generic.h.in @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2019, 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. + */ + +/* Define if strlcat exists. */ +#cmakedefine01 HAVE_STRLCAT + +/* Define if strlcpy exists. */ +#cmakedefine01 HAVE_STRLCPY + +/* Define if strnlen exists. */ +#cmakedefine01 HAVE_STRNLEN diff --git a/etc/cmake/options.cmake b/etc/cmake/options.cmake new file mode 100644 index 000000000..43ae1c395 --- /dev/null +++ b/etc/cmake/options.cmake @@ -0,0 +1,166 @@ +# +# Copyright (c) 2019, 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. +# + +if($ENV{BIG_ENDIAN} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "BYTE_ORDER_BIG_ENDIAN=1") +endif() + +if($ENV{BORDER_AGENT} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE=1") +endif() + +if($ENV{BORDER_ROUTER} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE=1") +endif() + +if($ENV{COAP} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_COAP_API_ENABLE=1") +endif() + +if($ENV{COAPS} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE=1") +endif() + +if($ENV{COMMISSIONER} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_COMMISSIONER_ENABLE=1") +endif() + +if($ENV{CHANNEL_MANAGER} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE=1") +endif() + +if($ENV{CHANNEL_MONITOR} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=1") +endif() + +if($ENV{CHILD_SUPERVISION} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE=1") +endif() + +if($ENV{DHCP6_CLIENT} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE=1") +endif() + +if($ENV{DHCP6_SERVER} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE=1") +endif() + +if($ENV{DIAGNOSTIC} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_DIAG_ENABLE=1") +endif() + +if($ENV{DNS_CLIENT} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE=1") +endif() + +if($ENV{ECDSA} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_ECDSA_ENABLE=1") +endif() + +if($ENV{EXTERNAL_HEAP} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_EXTERNAL_HEAP_ENABLE=1") +endif() + +if($ENV{IP6_FRAGM} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_IP6_FRAGM_ENABLE=1") +endif() + +if($ENV{JAM_DETECTION} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE=1") +endif() + +if($ENV{JOINER} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_JOINER_ENABLE=1") +endif() + +if($ENV{LEGACY} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LEGACY_ENABLE=1") +endif() + +if($ENV{LINK_RAW} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LINK_RAW_ENABLE=1") +endif() + +if($ENV{MAC_FILTER} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1") +endif() + +if($ENV{MTD_NETDIAG} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE=1") +endif() + +if($ENV{PLATFORM_UDP} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE=1") +endif() + +if($ENV{REFERENCE_DEVICE} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE=1") +endif() + +if($ENV{SERVICE} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE=1") +endif() + +if($ENV{SETTINGS_RAM} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_SETTINGS_RAM=1") +endif() + +if($ENV{SLAAC} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE=1") +endif() + +if($ENV{SNTP_CLIENT} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE=1") +endif() + +if($ENV{TIME_SYNC} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_TIME_SYNC_ENABLE=1") +endif() + +if($ENV{UDP_FORWARD} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE=1") +endif() + +if($ENV{FULL_LOGS} MATCHES "1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_DEBG") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_API=1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_ARP=1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_CLI=1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_COAP=1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_ICMP=1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_IP6=1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_MAC=1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_MEM=1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_MLE=1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_NETDATA=1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_NETDIAG=1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_PKT_DUMP=1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_PLATFORM=1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL=1") + list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_LOG_PREPEND_REGION=1") +endif() \ No newline at end of file diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 000000000..928e58fc9 --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,33 @@ +# +# Copyright (c) 2019, 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(platforms) + +if(OT_BUILD_EXECUTABLES) + add_subdirectory(apps) +endif() diff --git a/examples/apps/CMakeLists.txt b/examples/apps/CMakeLists.txt new file mode 100644 index 000000000..8200d57a1 --- /dev/null +++ b/examples/apps/CMakeLists.txt @@ -0,0 +1,30 @@ +# +# Copyright (c) 2019, 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(cli) +add_subdirectory(ncp) diff --git a/examples/apps/cli/CMakeLists.txt b/examples/apps/cli/CMakeLists.txt new file mode 100644 index 000000000..d4bd9f377 --- /dev/null +++ b/examples/apps/cli/CMakeLists.txt @@ -0,0 +1,63 @@ +# +# Copyright (c) 2019, 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_executable(ot-cli-ftd + main.c +) + +add_executable(ot-cli-mtd + main.c +) + +set(COMMON_INCLUDES + ${OT_PUBLIC_INCLUDES} + ${OT_PRIVATE_INCLUDES} + ${OT_ROOT_DIR}/examples/platforms + ${OT_ROOT_DIR}/src/core +) + +target_include_directories(ot-cli-ftd PRIVATE ${COMMON_INCLUDES}) +target_include_directories(ot-cli-mtd PRIVATE ${COMMON_INCLUDES}) + +target_link_libraries(ot-cli-ftd + openthread-cli-ftd + ${OT_PLATFORM_LIB} + openthread-ftd + openthread-platform-utils + ${OT_PLATFORM_LIB} + mbedcrypto +) + +target_link_libraries(ot-cli-mtd + openthread-cli-mtd + ${OT_PLATFORM_LIB} + openthread-mtd + openthread-platform-utils + ${OT_PLATFORM_LIB} + mbedcrypto +) diff --git a/examples/apps/ncp/CMakeLists.txt b/examples/apps/ncp/CMakeLists.txt new file mode 100644 index 000000000..b966d0b20 --- /dev/null +++ b/examples/apps/ncp/CMakeLists.txt @@ -0,0 +1,76 @@ +# +# Copyright (c) 2019, 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_executable(ot-ncp-ftd + main.c +) + +add_executable(ot-ncp-mtd + main.c +) + +add_executable(ot-rcp + main.c +) + +set(COMMON_INCLUDES + ${OT_PUBLIC_INCLUDES} + ${OT_PRIVATE_INCLUDES} + ${OT_ROOT_DIR}/examples/platforms + ${OT_ROOT_DIR}/src/core +) + +target_include_directories(ot-ncp-ftd PRIVATE ${COMMON_INCLUDES}) +target_include_directories(ot-ncp-mtd PRIVATE ${COMMON_INCLUDES}) +target_include_directories(ot-rcp PRIVATE ${COMMON_INCLUDES}) + +target_link_libraries(ot-ncp-ftd + openthread-ncp-ftd + ${OT_PLATFORM_LIB} + openthread-ftd + openthread-platform-utils + ${OT_PLATFORM_LIB} + mbedcrypto +) + +target_link_libraries(ot-ncp-mtd + openthread-ncp-mtd + ${OT_PLATFORM_LIB} + openthread-mtd + openthread-platform-utils + ${OT_PLATFORM_LIB} + mbedcrypto +) + +target_link_libraries(ot-rcp + openthread-rcp + ${OT_PLATFORM_LIB} + openthread-radio + openthread-platform-utils + ${OT_PLATFORM_LIB} +) diff --git a/examples/platforms/CMakeLists.txt b/examples/platforms/CMakeLists.txt new file mode 100644 index 000000000..c384bb1ab --- /dev/null +++ b/examples/platforms/CMakeLists.txt @@ -0,0 +1,29 @@ +# +# Copyright (c) 2019, 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(utils) diff --git a/examples/platforms/cc2538/CMakeLists.txt b/examples/platforms/cc2538/CMakeLists.txt new file mode 100644 index 000000000..e1db93fbc --- /dev/null +++ b/examples/platforms/cc2538/CMakeLists.txt @@ -0,0 +1,47 @@ +# +# Copyright (c) 2019, 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-cc2538 + alarm.c + diag.c + entropy.c + flash.c + misc.c + radio.c + startup-gcc.c + system.c + logging.c + uart.c +) + +target_include_directories(openthread-cc2538 PRIVATE + ${OT_PUBLIC_INCLUDES} + ${OT_PRIVATE_INCLUDES} + ${OT_ROOT_DIR}/examples/platforms + ${OT_ROOT_DIR}/src/core +) diff --git a/examples/platforms/cc2538/arm-none-eabi.cmake b/examples/platforms/cc2538/arm-none-eabi.cmake new file mode 100644 index 000000000..173166d8f --- /dev/null +++ b/examples/platforms/cc2538/arm-none-eabi.cmake @@ -0,0 +1,52 @@ +# +# Copyright (c) 2019, 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. +# + +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_PROCESSOR ARM) + +set(CMAKE_C_COMPILER arm-none-eabi-gcc) +set(CMAKE_CXX_COMPILER arm-none-eabi-g++) +set(CMAKE_ASM_COMPILER arm-none-eabi-as) +set(CMAKE_RANLIB arm-none-eabi-ranlib) + +set(COMMON_C_FLAGS "-mthumb -fno-builtin -Wall -fdata-sections -ffunction-sections -mabi=aapcs") + +set(CMAKE_C_FLAGS "${COMMON_C_FLAGS} -std=gnu99") +set(CMAKE_CXX_FLAGS "${COMMON_C_FLAGS} -fno-exceptions -fno-rtti") +set(CMAKE_ASM_FLAGS "${COMMON_C_FLAGS}") +set(CMAKE_EXE_LINKER_FLAGS "-Wl,--gc-sections -specs=nano.specs -specs=nosys.specs -mthumb -mabi=aapcs -Wl,-Map=${CMAKE_PROJECT_NAME}.map") + +set(CMAKE_C_FLAGS_DEBUG "-Og -g") +set(CMAKE_CXX_FLAGS_DEBUG "-Og -g") +set(CMAKE_ASM_FLAGS_DEBUG "-g") +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") + +set(CMAKE_C_FLAGS_RELEASE "-Os") +set(CMAKE_CXX_FLAGS_RELEASE "-Os") +set(CMAKE_ASM_FLAGS_RELEASE "") +set(CMAKE_EXE_LINKER_FLAGS_RELEASE "") diff --git a/examples/platforms/cc2538/platform.cmake b/examples/platforms/cc2538/platform.cmake new file mode 100644 index 000000000..7236492cb --- /dev/null +++ b/examples/platforms/cc2538/platform.cmake @@ -0,0 +1,43 @@ +# +# Copyright (c) 2019, 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_definitions( + -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE="openthread-core-cc2538-config.h" + -DOPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE="openthread-core-cc2538-config-check.h" + -DOPENTHREAD_CONFIG_NCP_UART_ENABLE=1 +) + +set(common_c_flags "-mcpu=cortex-m3 -mfloat-abi=soft") + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${common_c_flags}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${common_c_flags}") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${common_c_flags} -nostartfiles -T${OT_ROOT_DIR}/examples/platforms/cc2538/cc2538.ld") + +set(OT_PLATFORM_LIB "openthread-cc2538") + +add_subdirectory("${OT_ROOT_DIR}/examples/platforms/cc2538") diff --git a/examples/platforms/posix/CMakeLists.txt b/examples/platforms/posix/CMakeLists.txt new file mode 100644 index 000000000..3ac789a1c --- /dev/null +++ b/examples/platforms/posix/CMakeLists.txt @@ -0,0 +1,55 @@ +# +# Copyright (c) 2019, 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. +# + +find_library(LIBRT rt) + +add_library(openthread-posix + alarm.c + diag.c + entropy.c + flash.c + logging.c + misc.c + radio.c + spi-stubs.c + system.c + uart-posix.c + sim/alarm-sim.c + sim/platform-sim.c +) + +if(LIBRT) + target_link_libraries(openthread-posix PRIVATE ${LIBRT}) +endif() + +target_include_directories(openthread-posix PRIVATE + ${OT_PUBLIC_INCLUDES} + ${OT_PRIVATE_INCLUDES} + ${OT_ROOT_DIR}/examples/platforms + ${OT_ROOT_DIR}/src/core +) diff --git a/examples/platforms/posix/README.md b/examples/platforms/posix/README.md index 24c6fe656..7f4bae0e6 100644 --- a/examples/platforms/posix/README.md +++ b/examples/platforms/posix/README.md @@ -4,16 +4,31 @@ This directory contains example platform drivers for POSIX emulation. ## Build Examples +### Build using autotools + ```bash $ cd $ ./bootstrap $ make -f examples/Makefile-posix ``` -After a successful build, the `elf` files are found in -`/output//bin`. +After a successful build, the `elf` files are found in: -## +- `/output//bin` + +### Build using cmake/ninja + +```bash +$ cd +$ mkdir build && cd build +$ cmake -GNinja -DOT_PLATFORM=posix .. +$ ninja +``` + +After a successful build, the `elf` files are found in: + +- `/build/examples/apps/cli` +- `/build/examples/apps/ncp` ## Interact diff --git a/examples/platforms/posix/platform.cmake b/examples/platforms/posix/platform.cmake new file mode 100644 index 000000000..e2893a461 --- /dev/null +++ b/examples/platforms/posix/platform.cmake @@ -0,0 +1,40 @@ +# +# Copyright (c) 2019, 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_definitions( + -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE="openthread-core-posix-config.h" + -DOPENTHREAD_EXAMPLES_POSIX=1 + -DOPENTHREAD_CONFIG_NCP_UART_ENABLE=1 +) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOPENTHREAD_POSIX=1") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOPENTHREAD_EXAMPLES_POSIX=1") + +set(OT_PLATFORM_LIB "openthread-posix") + +add_subdirectory("${OT_ROOT_DIR}/examples/platforms/posix") diff --git a/examples/platforms/utils/CMakeLists.txt b/examples/platforms/utils/CMakeLists.txt new file mode 100644 index 000000000..b99dac922 --- /dev/null +++ b/examples/platforms/utils/CMakeLists.txt @@ -0,0 +1,49 @@ +# +# Copyright (c) 2019, 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-platform-utils + debug_uart.c + logging_rtt.c + mac_frame.cpp + settings_ram.c + settings_flash.c + soft_source_match_table.c +) + +target_compile_definitions(openthread-platform-utils PRIVATE + ${OT_PRIVATE_DEFINES} +) + +target_include_directories(openthread-platform-utils PRIVATE + ${OT_PUBLIC_INCLUDES} + ${OT_PRIVATE_INCLUDES} + ${OT_ROOT_DIR}/examples/platforms + ${OT_ROOT_DIR}/examples/platforms/utils + ${OT_ROOT_DIR}/src/core + ${OT_ROOT_DIR}/third_party/jlink/SEGGER_RTT_V640/RTT +) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 000000000..71a61436f --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,31 @@ +# +# Copyright (c) 2019, 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(cli) +add_subdirectory(core) +add_subdirectory(ncp) diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt new file mode 100644 index 000000000..765312a9d --- /dev/null +++ b/src/cli/CMakeLists.txt @@ -0,0 +1,65 @@ +# +# Copyright (c) 2019, 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-cli-ftd) +add_library(openthread-cli-mtd) + +target_compile_definitions(openthread-cli-ftd PRIVATE + ${OT_PRIVATE_DEFINES} + OPENTHREAD_FTD=1 +) + +target_compile_definitions(openthread-cli-mtd PRIVATE + ${OT_PRIVATE_DEFINES} + OPENTHREAD_MTD=1 +) + +set(COMMON_INCLUDES + ${OT_PRIVATE_INCLUDES} + ${OT_ROOT_DIR}/src + ${OT_ROOT_DIR}/src/core +) + +set(COMMON_SOURCES + cli.cpp + cli_coap.cpp + cli_coap_secure.cpp + cli_commissioner.cpp + cli_console.cpp + cli_dataset.cpp + cli_joiner.cpp + cli_server.cpp + cli_uart.cpp + cli_udp.cpp +) + +target_include_directories(openthread-cli-ftd PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES}) +target_include_directories(openthread-cli-mtd PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES}) + +target_sources(openthread-cli-ftd PRIVATE ${COMMON_SOURCES}) +target_sources(openthread-cli-mtd PRIVATE ${COMMON_SOURCES}) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt new file mode 100644 index 000000000..cc5634ec4 --- /dev/null +++ b/src/core/CMakeLists.txt @@ -0,0 +1,215 @@ +# +# Copyright (c) 2019, 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-ftd) +add_library(openthread-mtd) +add_library(openthread-radio) + +target_compile_definitions(openthread-ftd PRIVATE + ${OT_PRIVATE_DEFINES} + OPENTHREAD_FTD=1 +) + +target_compile_definitions(openthread-mtd PRIVATE + ${OT_PRIVATE_DEFINES} + OPENTHREAD_MTD=1 +) + +target_compile_definitions(openthread-radio PRIVATE + ${OT_PRIVATE_DEFINES} + OPENTHREAD_RADIO=1 +) + +set(COMMON_INCLUDES + ${OT_PRIVATE_INCLUDES} + ${OT_ROOT_DIR}/src/core +) + +set(COMMON_SOURCES + api/border_router_api.cpp + api/channel_manager_api.cpp + api/channel_monitor_api.cpp + api/child_supervision_api.cpp + api/coap_api.cpp + api/coap_secure_api.cpp + api/commissioner_api.cpp + api/crypto_api.cpp + api/dataset_api.cpp + api/dataset_ftd_api.cpp + api/diags_api.cpp + api/dns_api.cpp + api/entropy_api.cpp + api/heap_api.cpp + api/icmp6_api.cpp + api/instance_api.cpp + api/ip6_api.cpp + api/jam_detection_api.cpp + api/joiner_api.cpp + api/link_api.cpp + api/link_raw_api.cpp + api/logging_api.cpp + api/message_api.cpp + api/netdata_api.cpp + api/network_time_api.cpp + api/random_crypto_api.cpp + api/random_noncrypto_api.cpp + api/server_api.cpp + api/sntp_api.cpp + api/tasklet_api.cpp + api/thread_api.cpp + api/thread_ftd_api.cpp + api/udp_api.cpp + coap/coap.cpp + coap/coap_message.cpp + coap/coap_secure.cpp + common/crc16.cpp + common/instance.cpp + common/logging.cpp + common/message.cpp + common/notifier.cpp + common/random_manager.cpp + common/settings.cpp + common/string.cpp + common/tasklet.cpp + common/timer.cpp + common/tlvs.cpp + common/trickle_timer.cpp + crypto/aes_ccm.cpp + crypto/aes_ecb.cpp + crypto/ecdsa.cpp + crypto/hmac_sha256.cpp + crypto/mbedtls.cpp + crypto/pbkdf2_cmac.cpp + crypto/sha256.cpp + diags/factory_diags.cpp + mac/channel_mask.cpp + mac/data_poll_handler.cpp + mac/data_poll_sender.cpp + mac/link_raw.cpp + mac/mac.cpp + mac/mac_filter.cpp + mac/mac_frame.cpp + mac/mac_types.cpp + mac/sub_mac.cpp + mac/sub_mac_callbacks.cpp + meshcop/announce_begin_client.cpp + meshcop/border_agent.cpp + meshcop/commissioner.cpp + meshcop/dataset.cpp + meshcop/dataset_local.cpp + meshcop/dataset_manager.cpp + meshcop/dataset_manager_ftd.cpp + meshcop/dtls.cpp + meshcop/energy_scan_client.cpp + meshcop/joiner.cpp + meshcop/joiner_router.cpp + meshcop/leader.cpp + meshcop/meshcop.cpp + meshcop/meshcop_tlvs.cpp + meshcop/panid_query_client.cpp + meshcop/timestamp.cpp + net/dhcp6_client.cpp + net/dhcp6_server.cpp + net/dns_client.cpp + net/icmp6.cpp + net/ip6.cpp + net/ip6_address.cpp + net/ip6_filter.cpp + net/ip6_headers.cpp + net/ip6_mpl.cpp + net/netif.cpp + net/sntp_client.cpp + net/udp6.cpp + radio/radio_callbacks.cpp + radio/radio_platform.cpp + thread/address_resolver.cpp + thread/announce_begin_server.cpp + thread/announce_sender.cpp + thread/child_table.cpp + thread/device_mode.cpp + thread/energy_scan_server.cpp + thread/indirect_sender.cpp + thread/key_manager.cpp + thread/link_quality.cpp + thread/lowpan.cpp + thread/mesh_forwarder.cpp + thread/mesh_forwarder_ftd.cpp + thread/mesh_forwarder_mtd.cpp + thread/mle.cpp + thread/mle_router.cpp + thread/network_data.cpp + thread/network_data_leader.cpp + thread/network_data_leader_ftd.cpp + thread/network_data_local.cpp + thread/network_diagnostic.cpp + thread/panid_query_server.cpp + thread/router_table.cpp + thread/src_match_controller.cpp + thread/thread_netif.cpp + thread/time_sync_service.cpp + thread/topology.cpp + utils/channel_manager.cpp + utils/channel_monitor.cpp + utils/child_supervision.cpp + utils/heap.cpp + utils/jam_detector.cpp + utils/parse_cmdline.cpp + utils/slaac_address.cpp +) + +target_include_directories(openthread-ftd PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES}) +target_include_directories(openthread-mtd PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES}) +target_include_directories(openthread-radio PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES}) + +target_sources(openthread-ftd PRIVATE ${COMMON_SOURCES}) +target_sources(openthread-mtd PRIVATE ${COMMON_SOURCES}) + +target_sources(openthread-radio PRIVATE + api/diags_api.cpp + api/instance_api.cpp + api/link_raw_api.cpp + api/logging_api.cpp + api/random_noncrypto_api.cpp + api/tasklet_api.cpp + common/instance.cpp + common/logging.cpp + common/random_manager.cpp + common/string.cpp + common/tasklet.cpp + common/timer.cpp + diags/factory_diags.cpp + mac/link_raw.cpp + mac/mac_frame.cpp + mac/mac_types.cpp + mac/sub_mac.cpp + mac/sub_mac_callbacks.cpp + radio/radio_callbacks.cpp + radio/radio_platform.cpp + thread/link_quality.cpp + utils/parse_cmdline.cpp +) diff --git a/src/core/api/dataset_api.cpp b/src/core/api/dataset_api.cpp index 7b95323ef..e3573de2b 100644 --- a/src/core/api/dataset_api.cpp +++ b/src/core/api/dataset_api.cpp @@ -37,6 +37,7 @@ #include "common/instance.hpp" #include "common/locator-getters.hpp" +#include "meshcop/dataset_manager.hpp" using namespace ot; diff --git a/src/core/common/instance.hpp b/src/core/common/instance.hpp index a9b240373..b0fc8b9b7 100644 --- a/src/core/common/instance.hpp +++ b/src/core/common/instance.hpp @@ -44,7 +44,10 @@ #include #include "common/random_manager.hpp" +#include "common/tasklet.hpp" +#include "common/timer.hpp" #include "diags/factory_diags.hpp" +#include "radio/radio.hpp" #if OPENTHREAD_RADIO || OPENTHREAD_CONFIG_LINK_RAW_ENABLE #include "common/message.hpp" diff --git a/src/ncp/CMakeLists.txt b/src/ncp/CMakeLists.txt new file mode 100644 index 000000000..3b05b8e3a --- /dev/null +++ b/src/ncp/CMakeLists.txt @@ -0,0 +1,79 @@ +# +# Copyright (c) 2019, 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-ncp-ftd) +add_library(openthread-ncp-mtd) +add_library(openthread-rcp) + +target_compile_definitions(openthread-ncp-ftd PRIVATE + ${OT_PRIVATE_DEFINES} + OPENTHREAD_FTD=1 + OPENTHREAD_CONFIG_NCP_UART_ENABLE=1 +) + +target_compile_definitions(openthread-ncp-mtd PRIVATE + ${OT_PRIVATE_DEFINES} + OPENTHREAD_MTD=1 + OPENTHREAD_CONFIG_NCP_UART_ENABLE=1 +) + +target_compile_definitions(openthread-rcp PRIVATE + ${OT_PRIVATE_DEFINES} + OPENTHREAD_RADIO=1 + OPENTHREAD_CONFIG_NCP_UART_ENABLE=1 +) + +set(COMMON_INCLUDES + ${OT_PRIVATE_INCLUDES} + ${OT_ROOT_DIR}/src + ${OT_ROOT_DIR}/src/core +) + +set(COMMON_SOURCES + changed_props_set.cpp + hdlc.cpp + ncp_base.cpp + ncp_base_ftd.cpp + ncp_base_mtd.cpp + ncp_base_radio.cpp + ncp_base_dispatcher.cpp + ncp_buffer.cpp + ncp_spi.cpp + ncp_uart.cpp + spinel.c + spinel_decoder.cpp + spinel_encoder.cpp +) + +target_include_directories(openthread-ncp-ftd PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES}) +target_include_directories(openthread-ncp-mtd PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES}) +target_include_directories(openthread-rcp PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES}) + +target_sources(openthread-ncp-ftd PRIVATE ${COMMON_SOURCES}) +target_sources(openthread-ncp-mtd PRIVATE ${COMMON_SOURCES}) +target_sources(openthread-rcp PRIVATE ${COMMON_SOURCES}) diff --git a/src/ncp/spinel_decoder.cpp b/src/ncp/spinel_decoder.cpp index 5535e687e..d9af675ba 100644 --- a/src/ncp/spinel_decoder.cpp +++ b/src/ncp/spinel_decoder.cpp @@ -35,6 +35,7 @@ #include "spinel_decoder.hpp" #include "common/code_utils.hpp" +#include "utils/wrap_string.h" namespace ot { namespace Ncp { diff --git a/src/ncp/spinel_encoder.cpp b/src/ncp/spinel_encoder.cpp index 91ab7c3d4..75657aa59 100644 --- a/src/ncp/spinel_encoder.cpp +++ b/src/ncp/spinel_encoder.cpp @@ -33,6 +33,7 @@ #include "spinel_encoder.hpp" #include "common/code_utils.hpp" +#include "utils/wrap_string.h" namespace ot { namespace Ncp { diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt new file mode 100644 index 000000000..56bf9c7c9 --- /dev/null +++ b/third_party/CMakeLists.txt @@ -0,0 +1,31 @@ +# +# Copyright (c) 2019, 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. +# + +if(OT_BUILTIN_MBEDTLS) + add_subdirectory(mbedtls) +endif() diff --git a/third_party/mbedtls/CMakeLists.txt b/third_party/mbedtls/CMakeLists.txt new file mode 100644 index 000000000..026145441 --- /dev/null +++ b/third_party/mbedtls/CMakeLists.txt @@ -0,0 +1,80 @@ +# +# Copyright (c) 2019, 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(mbedcrypto) + +target_compile_definitions(mbedcrypto PRIVATE + ${OT_PRIVATE_DEFINES} +) + +target_include_directories(mbedcrypto PRIVATE + ${OT_PUBLIC_INCLUDES} + ${OT_PRIVATE_INCLUDES} + ${OT_ROOT_DIR}/src/core +) + +target_sources(mbedcrypto PRIVATE + repo/library/aes.c + repo/library/asn1parse.c + repo/library/asn1write.c + repo/library/base64.c + repo/library/bignum.c + repo/library/ccm.c + repo/library/cipher.c + repo/library/cipher_wrap.c + repo/library/cmac.c + repo/library/ctr_drbg.c + repo/library/debug.c + repo/library/ecdh.c + repo/library/ecdsa.c + repo/library/ecjpake.c + repo/library/ecp.c + repo/library/ecp_curves.c + repo/library/entropy.c + repo/library/entropy_poll.c + repo/library/md.c + repo/library/md_wrap.c + repo/library/memory_buffer_alloc.c + repo/library/oid.c + repo/library/pem.c + repo/library/pk.c + repo/library/pk_wrap.c + repo/library/pkparse.c + repo/library/platform.c + repo/library/platform_util.c + repo/library/sha256.c + repo/library/ssl_cookie.c + repo/library/ssl_ciphersuites.c + repo/library/ssl_cli.c + repo/library/ssl_srv.c + repo/library/ssl_ticket.c + repo/library/ssl_tls.c + repo/library/threading.c + repo/library/x509.c + repo/library/x509_crt.c +)