diff --git a/etc/cmake/options.cmake b/etc/cmake/options.cmake index b03bdc68f..ce0c180fe 100644 --- a/etc/cmake/options.cmake +++ b/etc/cmake/options.cmake @@ -30,6 +30,10 @@ option(OT_APP_CLI "enable CLI app" ON) option(OT_APP_NCP "enable NCP app" ON) option(OT_APP_RCP "enable RCP app" ON) +option(OT_FTD "enable FTD" ON) +option(OT_MTD "enable MTD" ON) +option(OT_RCP "enable RCP" ON) + option(OT_ASSERT "enable assert function OT_ASSERT()" ON) if(OT_ASSERT) target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ASSERT_ENABLE=1") diff --git a/examples/apps/cli/CMakeLists.txt b/examples/apps/cli/CMakeLists.txt index 05e1acdbf..063610ee9 100644 --- a/examples/apps/cli/CMakeLists.txt +++ b/examples/apps/cli/CMakeLists.txt @@ -26,40 +26,16 @@ # POSSIBILITY OF SUCH DAMAGE. # -add_executable(ot-cli-ftd - main.c -) - -add_executable(ot-cli-mtd - main.c -) - set(COMMON_INCLUDES ${OT_PUBLIC_INCLUDES} ${PROJECT_SOURCE_DIR}/examples/platforms ${PROJECT_SOURCE_DIR}/src/core ) -target_include_directories(ot-cli-ftd PRIVATE ${COMMON_INCLUDES}) -target_include_directories(ot-cli-mtd PRIVATE ${COMMON_INCLUDES}) +if(OT_FTD) + include(ftd.cmake) +endif() -target_link_libraries(ot-cli-ftd PRIVATE - openthread-cli-ftd - ${OT_PLATFORM_LIB} - openthread-ftd - ${OT_PLATFORM_LIB} - mbedcrypto - ot-config -) - -target_link_libraries(ot-cli-mtd PRIVATE - openthread-cli-mtd - ${OT_PLATFORM_LIB} - openthread-mtd - ${OT_PLATFORM_LIB} - mbedcrypto - ot-config -) - -install(TARGETS ot-cli-ftd ot-cli-mtd - DESTINATION bin) +if(OT_MTD) + include(mtd.cmake) +endif() diff --git a/examples/apps/cli/ftd.cmake b/examples/apps/cli/ftd.cmake new file mode 100644 index 000000000..b5bd7533a --- /dev/null +++ b/examples/apps/cli/ftd.cmake @@ -0,0 +1,45 @@ +# +# 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_executable(ot-cli-ftd + main.c +) + +target_include_directories(ot-cli-ftd PRIVATE ${COMMON_INCLUDES}) + +target_link_libraries(ot-cli-ftd PRIVATE + openthread-cli-ftd + ${OT_PLATFORM_LIB} + openthread-ftd + ${OT_PLATFORM_LIB} + mbedcrypto + ot-config +) + +install(TARGETS ot-cli-ftd + DESTINATION bin) diff --git a/examples/apps/cli/mtd.cmake b/examples/apps/cli/mtd.cmake new file mode 100644 index 000000000..0186760bf --- /dev/null +++ b/examples/apps/cli/mtd.cmake @@ -0,0 +1,45 @@ +# +# 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_executable(ot-cli-mtd + main.c +) + +target_include_directories(ot-cli-mtd PRIVATE ${COMMON_INCLUDES}) + +target_link_libraries(ot-cli-mtd PRIVATE + openthread-cli-mtd + ${OT_PLATFORM_LIB} + openthread-mtd + ${OT_PLATFORM_LIB} + mbedcrypto + ot-config +) + +install(TARGETS ot-cli-mtd + DESTINATION bin) diff --git a/examples/apps/ncp/CMakeLists.txt b/examples/apps/ncp/CMakeLists.txt index d6a2d02e8..5fce73726 100644 --- a/examples/apps/ncp/CMakeLists.txt +++ b/examples/apps/ncp/CMakeLists.txt @@ -33,9 +33,18 @@ set(COMMON_INCLUDES ) if(OT_APP_NCP) - include(ncp.cmake) + if(OT_FTD) + include(ftd.cmake) + endif() + if(OT_MTD) + include(mtd.cmake) + endif() endif() if(OT_APP_RCP) - include(rcp.cmake) + if(OT_RCP) + include(rcp.cmake) + else() + message(FATAL_ERROR "OT_RCP is not enabled") + endif() endif() diff --git a/examples/apps/ncp/ncp.cmake b/examples/apps/ncp/ftd.cmake similarity index 85% rename from examples/apps/ncp/ncp.cmake rename to examples/apps/ncp/ftd.cmake index 4f7ca1afd..61afb274f 100644 --- a/examples/apps/ncp/ncp.cmake +++ b/examples/apps/ncp/ftd.cmake @@ -30,12 +30,7 @@ add_executable(ot-ncp-ftd main.c ) -add_executable(ot-ncp-mtd - main.c -) - target_include_directories(ot-ncp-ftd PRIVATE ${COMMON_INCLUDES}) -target_include_directories(ot-ncp-mtd PRIVATE ${COMMON_INCLUDES}) target_link_libraries(ot-ncp-ftd PRIVATE openthread-ncp-ftd @@ -46,13 +41,4 @@ target_link_libraries(ot-ncp-ftd PRIVATE ot-config ) -target_link_libraries(ot-ncp-mtd PRIVATE - openthread-ncp-mtd - ${OT_PLATFORM_LIB} - openthread-mtd - ${OT_PLATFORM_LIB} - mbedcrypto - ot-config -) - -install(TARGETS ot-ncp-ftd ot-ncp-mtd DESTINATION bin) +install(TARGETS ot-ncp-ftd DESTINATION bin) diff --git a/examples/apps/ncp/mtd.cmake b/examples/apps/ncp/mtd.cmake new file mode 100644 index 000000000..7566e68d5 --- /dev/null +++ b/examples/apps/ncp/mtd.cmake @@ -0,0 +1,44 @@ +# +# 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_executable(ot-ncp-mtd + main.c +) + +target_include_directories(ot-ncp-mtd PRIVATE ${COMMON_INCLUDES}) + +target_link_libraries(ot-ncp-mtd PRIVATE + openthread-ncp-mtd + ${OT_PLATFORM_LIB} + openthread-mtd + ${OT_PLATFORM_LIB} + mbedcrypto + ot-config +) + +install(TARGETS ot-ncp-mtd DESTINATION bin) diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt index 55db02599..2a1456e5f 100644 --- a/src/cli/CMakeLists.txt +++ b/src/cli/CMakeLists.txt @@ -26,9 +26,6 @@ # POSSIBILITY OF SUCH DAMAGE. # -add_library(openthread-cli-ftd) -add_library(openthread-cli-mtd) - set(OT_CLI_TRANSPORT "UART" CACHE STRING "set the CLI transport") set(OT_CLI_TRANSPORT_VALUES "UART" @@ -36,35 +33,6 @@ set(OT_CLI_TRANSPORT_VALUES ) set_property(CACHE OT_CLI_TRANSPORT PROPERTY STRINGS ${OT_CLI_TRANSPORT_VALUES}) -set_target_properties( - openthread-cli-ftd openthread-cli-mtd - PROPERTIES - C_STANDARD 99 - CXX_STANDARD 11 -) - -target_compile_definitions(openthread-cli-ftd - PRIVATE - OPENTHREAD_FTD=1 - PUBLIC - "OPENTHREAD_CONFIG_CLI_TRANSPORT=OT_CLI_TRANSPORT_${OT_CLI_TRANSPORT}" -) - -target_compile_definitions(openthread-cli-mtd - PRIVATE - OPENTHREAD_MTD=1 - PUBLIC - "OPENTHREAD_CONFIG_CLI_TRANSPORT=OT_CLI_TRANSPORT_${OT_CLI_TRANSPORT}" -) - -target_compile_options(openthread-cli-ftd PRIVATE - ${OT_CFLAGS} -) - -target_compile_options(openthread-cli-mtd PRIVATE - ${OT_CFLAGS} -) - set(COMMON_INCLUDES ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/src/core @@ -83,24 +51,10 @@ set(COMMON_SOURCES 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}) +if(OT_FTD) + include(ftd.cmake) +endif() -target_sources(openthread-cli-ftd PRIVATE ${COMMON_SOURCES}) -target_sources(openthread-cli-mtd PRIVATE ${COMMON_SOURCES}) - -target_link_libraries(openthread-cli-ftd - PUBLIC - openthread-ftd - PRIVATE - ${OT_MBEDTLS} - ot-config -) - -target_link_libraries(openthread-cli-mtd - PUBLIC - openthread-mtd - PRIVATE - ${OT_MBEDTLS} - ot-config -) +if(OT_MTD) + include(mtd.cmake) +endif() diff --git a/src/cli/ftd.cmake b/src/cli/ftd.cmake new file mode 100644 index 000000000..e0385bbe7 --- /dev/null +++ b/src/cli/ftd.cmake @@ -0,0 +1,59 @@ +# +# 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-cli-ftd) + +set_target_properties( + openthread-cli-ftd + PROPERTIES + C_STANDARD 99 + CXX_STANDARD 11 +) + +target_compile_definitions(openthread-cli-ftd + PRIVATE + OPENTHREAD_FTD=1 + PUBLIC + "OPENTHREAD_CONFIG_CLI_TRANSPORT=OT_CLI_TRANSPORT_${OT_CLI_TRANSPORT}" +) + +target_compile_options(openthread-cli-ftd PRIVATE + ${OT_CFLAGS} +) + +target_include_directories(openthread-cli-ftd PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES}) + +target_sources(openthread-cli-ftd PRIVATE ${COMMON_SOURCES}) + +target_link_libraries(openthread-cli-ftd + PUBLIC + openthread-ftd + PRIVATE + ${OT_MBEDTLS} + ot-config +) diff --git a/src/cli/mtd.cmake b/src/cli/mtd.cmake new file mode 100644 index 000000000..dabb8b155 --- /dev/null +++ b/src/cli/mtd.cmake @@ -0,0 +1,59 @@ +# +# 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-cli-mtd) + +set_target_properties( + openthread-cli-mtd + PROPERTIES + C_STANDARD 99 + CXX_STANDARD 11 +) + +target_compile_definitions(openthread-cli-mtd + PRIVATE + OPENTHREAD_MTD=1 + PUBLIC + "OPENTHREAD_CONFIG_CLI_TRANSPORT=OT_CLI_TRANSPORT_${OT_CLI_TRANSPORT}" +) + +target_compile_options(openthread-cli-mtd PRIVATE + ${OT_CFLAGS} +) + +target_include_directories(openthread-cli-mtd PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES}) + +target_sources(openthread-cli-mtd PRIVATE ${COMMON_SOURCES}) + +target_link_libraries(openthread-cli-mtd + PUBLIC + openthread-mtd + PRIVATE + ${OT_MBEDTLS} + ot-config +) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 7fb38e816..3f8d74f09 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -26,41 +26,6 @@ # POSSIBILITY OF SUCH DAMAGE. # -add_library(openthread-ftd) -add_library(openthread-mtd) -add_library(openthread-radio) - -set_target_properties( - openthread-ftd openthread-mtd openthread-radio - PROPERTIES - C_STANDARD 99 - CXX_STANDARD 11 -) - -target_compile_definitions(openthread-ftd PRIVATE - OPENTHREAD_FTD=1 -) - -target_compile_definitions(openthread-mtd PRIVATE - OPENTHREAD_MTD=1 -) - -target_compile_definitions(openthread-radio PRIVATE - OPENTHREAD_RADIO=1 -) - -target_compile_options(openthread-ftd PRIVATE - ${OT_CFLAGS} -) - -target_compile_options(openthread-mtd PRIVATE - ${OT_CFLAGS} -) - -target_compile_options(openthread-radio PRIVATE - ${OT_CFLAGS} -) - set(COMMON_INCLUDES ${PROJECT_SOURCE_DIR}/src/core ) @@ -222,65 +187,20 @@ set(COMMON_SOURCES 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}) - set(OT_VENDOR_EXTENSION "" CACHE STRING "specify a C++ source file built as part of OpenThread core library") if(OT_VENDOR_EXTENSION) target_compile_definitions(ot-config INTERFACE "OPENTHREAD_ENABLE_VENDOR_EXTENSION=1") list(APPEND COMMON_SOURCES ${OT_VENDOR_EXTENSION}) endif() -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 - crypto/aes_ccm.cpp - crypto/aes_ecb.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.cpp - radio/radio_callbacks.cpp - radio/radio_platform.cpp - thread/link_quality.cpp - utils/lookup_table.cpp - utils/parse_cmdline.cpp -) - -if(OT_VENDOR_EXTENSION) - target_sources(openthread-radio PRIVATE ${OT_VENDOR_EXTENSION}) +if(OT_FTD) + include(ftd.cmake) endif() -target_link_libraries(openthread-ftd - PRIVATE - ${OT_MBEDTLS} - ot-config -) +if(OT_MTD) + include(mtd.cmake) +endif() -target_link_libraries(openthread-mtd - PRIVATE - ${OT_MBEDTLS} - ot-config -) - -target_link_libraries(openthread-radio - PRIVATE - ${OT_MBEDTLS} - ot-config -) +if(OT_RCP) + include(radio.cmake) +endif() diff --git a/src/core/ftd.cmake b/src/core/ftd.cmake new file mode 100644 index 000000000..dc0b10427 --- /dev/null +++ b/src/core/ftd.cmake @@ -0,0 +1,54 @@ +# +# 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-ftd) + +set_target_properties( + openthread-ftd + PROPERTIES + C_STANDARD 99 + CXX_STANDARD 11 +) + +target_compile_definitions(openthread-ftd PRIVATE + OPENTHREAD_FTD=1 +) + +target_compile_options(openthread-ftd PRIVATE + ${OT_CFLAGS} +) + +target_include_directories(openthread-ftd PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES}) + +target_sources(openthread-ftd PRIVATE ${COMMON_SOURCES}) + +target_link_libraries(openthread-ftd + PRIVATE + ${OT_MBEDTLS} + ot-config +) diff --git a/src/core/mtd.cmake b/src/core/mtd.cmake new file mode 100644 index 000000000..3ac334bf2 --- /dev/null +++ b/src/core/mtd.cmake @@ -0,0 +1,54 @@ +# +# 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-mtd) + +set_target_properties( + openthread-mtd + PROPERTIES + C_STANDARD 99 + CXX_STANDARD 11 +) + +target_compile_definitions(openthread-mtd PRIVATE + OPENTHREAD_MTD=1 +) + +target_compile_options(openthread-mtd PRIVATE + ${OT_CFLAGS} +) + +target_include_directories(openthread-mtd PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES}) + +target_sources(openthread-mtd PRIVATE ${COMMON_SOURCES}) + +target_link_libraries(openthread-mtd + PRIVATE + ${OT_MBEDTLS} + ot-config +) diff --git a/src/core/radio.cmake b/src/core/radio.cmake new file mode 100644 index 000000000..1a78f10f6 --- /dev/null +++ b/src/core/radio.cmake @@ -0,0 +1,85 @@ +# +# 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-radio) + +set_target_properties( + openthread-radio + PROPERTIES + C_STANDARD 99 + CXX_STANDARD 11 +) + +target_compile_definitions(openthread-radio PRIVATE + OPENTHREAD_RADIO=1 +) + +target_compile_options(openthread-radio PRIVATE + ${OT_CFLAGS} +) + +target_include_directories(openthread-radio PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES}) + +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 + crypto/aes_ccm.cpp + crypto/aes_ecb.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.cpp + radio/radio_callbacks.cpp + radio/radio_platform.cpp + thread/link_quality.cpp + utils/lookup_table.cpp + utils/parse_cmdline.cpp +) + +if(OT_VENDOR_EXTENSION) + target_sources(openthread-radio PRIVATE ${OT_VENDOR_EXTENSION}) +endif() + +target_link_libraries(openthread-radio + PRIVATE + ${OT_MBEDTLS} + ot-config +) diff --git a/src/ncp/CMakeLists.txt b/src/ncp/CMakeLists.txt index c187d8fc0..0ff1ad369 100644 --- a/src/ncp/CMakeLists.txt +++ b/src/ncp/CMakeLists.txt @@ -26,45 +26,6 @@ # POSSIBILITY OF SUCH DAMAGE. # -add_library(openthread-ncp-ftd) -add_library(openthread-ncp-mtd) -add_library(openthread-rcp) - -# We depend on C++11 to validate that NCP handlers are sorted. -set_target_properties( - openthread-ncp-ftd openthread-ncp-mtd openthread-rcp - PROPERTIES - C_STANDARD 99 - CXX_STANDARD 11 -) - -target_compile_definitions(openthread-ncp-ftd PRIVATE - OPENTHREAD_FTD=1 - OPENTHREAD_CONFIG_NCP_UART_ENABLE=1 -) - -target_compile_definitions(openthread-ncp-mtd PRIVATE - OPENTHREAD_MTD=1 - OPENTHREAD_CONFIG_NCP_UART_ENABLE=1 -) - -target_compile_definitions(openthread-rcp PRIVATE - OPENTHREAD_RADIO=1 - OPENTHREAD_CONFIG_NCP_UART_ENABLE=1 -) - -target_compile_options(openthread-ncp-ftd PRIVATE - ${OT_CFLAGS} -) - -target_compile_options(openthread-ncp-mtd PRIVATE - ${OT_CFLAGS} -) - -target_compile_options(openthread-rcp PRIVATE - ${OT_CFLAGS} -) - set(COMMON_INCLUDES ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/src/core @@ -87,50 +48,14 @@ if(OT_NCP_VENDOR_HOOK_SOURCE) list(APPEND COMMON_SOURCES ${OT_NCP_VENDOR_HOOK_SOURCE_DIR}${OT_NCP_VENDOR_HOOK_SOURCE}) endif() -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}) +if(OT_FTD) + include(ftd.cmake) +endif() -target_sources(openthread-ncp-ftd PRIVATE ${COMMON_SOURCES}) -target_sources(openthread-ncp-mtd PRIVATE ${COMMON_SOURCES}) -target_include_directories(openthread-ncp-ftd PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) -target_include_directories(openthread-ncp-mtd PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +if(OT_MTD) + include(mtd.cmake) +endif() -target_sources(openthread-rcp PRIVATE - changed_props_set.cpp - ncp_base.cpp - ncp_base_dispatcher.cpp - ncp_base_radio.cpp - ncp_spi.cpp - ncp_uart.cpp -) - -target_link_libraries(openthread-ncp-ftd - PUBLIC - openthread-ftd - PRIVATE - ${OT_PLATFORM_LIB} - ${OT_MBEDTLS} - openthread-hdlc - openthread-spinel-ncp - ot-config -) - -target_link_libraries(openthread-ncp-mtd - PUBLIC - openthread-mtd - PRIVATE - ${OT_MBEDTLS} - openthread-hdlc - openthread-spinel-ncp - ot-config -) - -target_link_libraries(openthread-rcp - PUBLIC - openthread-radio - PRIVATE - openthread-hdlc - openthread-spinel-rcp - ot-config -) +if(OT_RCP) + include(radio.cmake) +endif() diff --git a/src/ncp/ftd.cmake b/src/ncp/ftd.cmake new file mode 100644 index 000000000..f24413447 --- /dev/null +++ b/src/ncp/ftd.cmake @@ -0,0 +1,61 @@ +# +# 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-ncp-ftd) + +set_target_properties( + openthread-ncp-ftd + PROPERTIES + C_STANDARD 99 + CXX_STANDARD 11 +) + +target_compile_definitions(openthread-ncp-ftd PRIVATE + OPENTHREAD_FTD=1 + OPENTHREAD_CONFIG_NCP_UART_ENABLE=1 +) + +target_compile_options(openthread-ncp-ftd PRIVATE + ${OT_CFLAGS} +) + +target_include_directories(openthread-ncp-ftd PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES}) + +target_sources(openthread-ncp-ftd PRIVATE ${COMMON_SOURCES}) +target_include_directories(openthread-ncp-ftd PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + +target_link_libraries(openthread-ncp-ftd + PUBLIC + openthread-ftd + PRIVATE + ${OT_PLATFORM_LIB} + ${OT_MBEDTLS} + openthread-hdlc + openthread-spinel-ncp + ot-config +) diff --git a/src/ncp/mtd.cmake b/src/ncp/mtd.cmake new file mode 100644 index 000000000..bdf330afd --- /dev/null +++ b/src/ncp/mtd.cmake @@ -0,0 +1,60 @@ +# +# 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-ncp-mtd) + +set_target_properties( + openthread-ncp-mtd + PROPERTIES + C_STANDARD 99 + CXX_STANDARD 11 +) + +target_compile_definitions(openthread-ncp-mtd PRIVATE + OPENTHREAD_MTD=1 + OPENTHREAD_CONFIG_NCP_UART_ENABLE=1 +) + +target_compile_options(openthread-ncp-mtd PRIVATE + ${OT_CFLAGS} +) + +target_include_directories(openthread-ncp-mtd PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES}) + +target_sources(openthread-ncp-mtd PRIVATE ${COMMON_SOURCES}) +target_include_directories(openthread-ncp-mtd PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + +target_link_libraries(openthread-ncp-mtd + PUBLIC + openthread-mtd + PRIVATE + ${OT_MBEDTLS} + openthread-hdlc + openthread-spinel-ncp + ot-config +) diff --git a/src/ncp/radio.cmake b/src/ncp/radio.cmake new file mode 100644 index 000000000..e3e74b555 --- /dev/null +++ b/src/ncp/radio.cmake @@ -0,0 +1,65 @@ +# +# 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-rcp) + +set_target_properties( + openthread-rcp + PROPERTIES + C_STANDARD 99 + CXX_STANDARD 11 +) + +target_compile_definitions(openthread-rcp PRIVATE + OPENTHREAD_RADIO=1 + OPENTHREAD_CONFIG_NCP_UART_ENABLE=1 +) + +target_compile_options(openthread-rcp PRIVATE + ${OT_CFLAGS} +) + +target_include_directories(openthread-rcp PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES}) + +target_sources(openthread-rcp PRIVATE + changed_props_set.cpp + ncp_base.cpp + ncp_base_dispatcher.cpp + ncp_base_radio.cpp + ncp_spi.cpp + ncp_uart.cpp +) + +target_link_libraries(openthread-rcp + PUBLIC + openthread-radio + PRIVATE + openthread-hdlc + openthread-spinel-rcp + ot-config +)