1#!/bin/bash 2# 3# Copyright (c) 2020, The OpenThread Authors. 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions are met: 8# 1. Redistributions of source code must retain the above copyright 9# notice, this list of conditions and the following disclaimer. 10# 2. Redistributions in binary form must reproduce the above copyright 11# notice, this list of conditions and the following disclaimer in the 12# documentation and/or other materials provided with the distribution. 13# 3. Neither the name of the copyright holder nor the 14# names of its contributors may be used to endorse or promote products 15# derived from this software without specific prior written permission. 16# 17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27# POSSIBILITY OF SUCH DAMAGE. 28# 29 30set -euxo pipefail 31 32: "${CFLAGS:=}" 33: "${CXXFLAGS:=}" 34 35OT_BUILDDIR="$(pwd)/build" 36readonly OT_BUILDDIR 37 38reset_source() 39{ 40 rm -rf "$OT_BUILDDIR" 41} 42 43build_all_features() 44{ 45 local cppflags=( 46 "-DOPENTHREAD_CONFIG_ANNOUNCE_SENDER_ENABLE=1" 47 "-DOPENTHREAD_CONFIG_ANYCAST_LOCATOR=1" 48 "-DOPENTHREAD_CONFIG_BORDER_AGENT_ENABLE=1" 49 "-DOPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE=1" 50 "-DOPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE=1" 51 "-DOPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE=1" 52 "-DOPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=1" 53 "-DOPENTHREAD_CONFIG_COAP_API_ENABLE=1" 54 "-DOPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE=1" 55 "-DOPENTHREAD_CONFIG_COMMISSIONER_ENABLE=1" 56 "-DOPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE=1" 57 "-DOPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE=1" 58 "-DOPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE=1" 59 "-DOPENTHREAD_CONFIG_DIAG_ENABLE=1" 60 "-DOPENTHREAD_CONFIG_DNS_CLIENT_ENABLE=1" 61 "-DOPENTHREAD_CONFIG_DNS_DSO_ENABLE=1" 62 "-DOPENTHREAD_CONFIG_ECDSA_ENABLE=1" 63 "-DOPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE=1" 64 "-DOPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE=1" 65 "-DOPENTHREAD_CONFIG_IP6_FRAGMENTATION_ENABLE=1" 66 "-DOPENTHREAD_CONFIG_IP6_SLAAC_ENABLE=1" 67 "-DOPENTHREAD_CONFIG_JAM_DETECTION_ENABLE=1" 68 "-DOPENTHREAD_CONFIG_JOINER_ENABLE=1" 69 "-DOPENTHREAD_CONFIG_LINK_RAW_ENABLE=1" 70 "-DOPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1" 71 "-DOPENTHREAD_CONFIG_MAC_BEACON_RSP_WHEN_JOINABLE_ENABLE=1" 72 "-DOPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1" 73 "-DOPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE=1" 74 "-DOPENTHREAD_CONFIG_MAC_SOFTWARE_ACK_TIMEOUT_ENABLE=1" 75 "-DOPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE=1" 76 "-DOPENTHREAD_CONFIG_MAC_SOFTWARE_ENERGY_SCAN_ENABLE=1" 77 "-DOPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE=1" 78 "-DOPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE=1" 79 "-DOPENTHREAD_CONFIG_MLE_ATTACH_BACKOFF_ENABLE=1" 80 "-DOPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE=1" 81 "-DOPENTHREAD_CONFIG_MPL_DYNAMIC_INTERVAL_ENABLE" 82 "-DOPENTHREAD_CONFIG_NCP_HDLC_ENABLE=1" 83 "-DOPENTHREAD_CONFIG_NCP_SPI_ENABLE=1" 84 "-DOPENTHREAD_CONFIG_PING_SENDER_ENABLE=1" 85 "-DOPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE=1" 86 "-DOPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE=1" 87 "-DOPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE=1" 88 "-DOPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE=1" 89 "-DOPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE=1" 90 "-DOPENTHREAD_CONFIG_SRP_CLIENT_ENABLE=1" 91 "-DOPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE=1" 92 "-DOPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE=1" 93 "-DOPENTHREAD_CONFIG_UDP_FORWARD_ENABLE=1" 94 "-DOPENTHREAD_CONFIG_MAC_BEACON_PAYLOAD_PARSING_ENABLE=1" 95 "-DOPENTHREAD_CONFIG_MAC_OUTGOING_BEACON_PAYLOAD_ENABLE=1" 96 ) 97 98 # Build Thread 1.1 with full features 99 reset_source 100 CFLAGS="${cppflags[*]} ${CFLAGS}" CXXFLAGS="${cppflags[*]} ${CXXFLAGS}" \ 101 "$(dirname "$0")"/cmake-build simulation \ 102 -DOT_THREAD_VERSION=1.1 103 104 # Build Thread 1.1 with full features and no log 105 reset_source 106 CFLAGS="${cppflags[*]} ${CFLAGS}" CXXFLAGS="${cppflags[*]} ${CXXFLAGS}" \ 107 "$(dirname "$0")"/cmake-build simulation \ 108 -DOT_THREAD_VERSION=1.1 \ 109 -DOT_LOG_OUTPUT=NONE 110 111 # Build Thread 1.1 with full features and full logs 112 reset_source 113 CFLAGS="${cppflags[*]} ${CFLAGS}" CXXFLAGS="${cppflags[*]} ${CXXFLAGS}" \ 114 "$(dirname "$0")"/cmake-build simulation \ 115 -DOT_THREAD_VERSION=1.1 \ 116 -DOT_FULL_LOGS=ON 117 118 # Build Thread 1.1 cli-radio 119 reset_source 120 "$(dirname "$0")"/cmake-build simulation \ 121 -DOT_THREAD_VERSION=1.1 \ 122 -DOT_DIAGNOSTIC=ON \ 123 -DOT_APP_CLI=ON \ 124 -DOT_APP_NCP=OFF \ 125 -DOT_APP_RCP=OFF \ 126 -DOT_FTD=OFF \ 127 -DOT_MTD=OFF 128 129 # Build Thread 1.1 with ASSERT disabled 130 reset_source 131 CFLAGS="${cppflags[*]} ${CFLAGS}" CXXFLAGS="${cppflags[*]} ${CXXFLAGS}" \ 132 "$(dirname "$0")"/cmake-build simulation \ 133 -DOT_THREAD_VERSION=1.1 \ 134 -DOT_SIMULATION_VIRTUAL_TIME=ON \ 135 -DOT_ASSERT=OFF 136 137 # Build Thread 1.1 OTNS 138 reset_source 139 CFLAGS="${cppflags[*]} ${CFLAGS}" CXXFLAGS="${cppflags[*]} ${CXXFLAGS}" \ 140 "$(dirname "$0")"/cmake-build simulation \ 141 -DOT_THREAD_VERSION=1.1 \ 142 -DOT_SIMULATION_VIRTUAL_TIME=ON \ 143 -DOT_OTNS=ON 144 145 # Thread 1.3 options 146 local options=( 147 "-DOT_BACKBONE_ROUTER=ON" 148 "-DOT_BORDER_ROUTING=ON" 149 "-DOT_NAT64_BORDER_ROUTING=ON" 150 "-DOT_NAT64_TRANSLATOR=ON" 151 "-DOT_CSL_RECEIVER=ON" 152 "-DOT_MLR=ON" 153 "-DOT_OTNS=ON" 154 "-DOT_SIMULATION_VIRTUAL_TIME=ON" 155 "-DOT_THREAD_VERSION=1.3" 156 ) 157 158 # Build Thread 1.3 with full features 159 reset_source 160 CFLAGS="${cppflags[*]} ${CFLAGS}" CXXFLAGS="${cppflags[*]} ${CXXFLAGS}" \ 161 "$(dirname "$0")"/cmake-build simulation "${options[@]}" -DOT_DUA=ON 162 163 # Build Thread 1.3 with external heap and msg pool using heap 164 reset_source 165 CFLAGS="${cppflags[*]} ${CFLAGS} -DOPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE=1" \ 166 CXXFLAGS="${cppflags[*]} ${CXXFLAGS} -DOPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE=1" \ 167 "$(dirname "$0")"/cmake-build simulation "${options[@]}" -DOT_DUA=ON 168 169 # Build Thread 1.3 with full features and no log 170 reset_source 171 CFLAGS="${cppflags[*]} ${CFLAGS}" CXXFLAGS="${cppflags[*]} ${CXXFLAGS}" \ 172 "$(dirname "$0")"/cmake-build simulation "${options[@]}" -DOT_DUA=ON -DOT_LOG_OUTPUT=NONE 173 174 # Build Thread 1.3 with full features and full logs 175 reset_source 176 CFLAGS="${cppflags[*]} ${CFLAGS}" CXXFLAGS="${cppflags[*]} ${CXXFLAGS}" \ 177 "$(dirname "$0")"/cmake-build simulation "${options[@]}" -DOT_DUA=ON -DOT_FULL_LOGS=ON 178 179 # Build Thread 1.3 Backbone Router without DUA ND Proxying 180 reset_source 181 "$(dirname "$0")"/cmake-build simulation "${options[@]}" -DOT_BACKBONE_ROUTER_DUA_NDPROXYING=OFF 182 183 # Build Thread 1.3 Backbone Router without Multicast Routing 184 reset_source 185 "$(dirname "$0")"/cmake-build simulation "${options[@]}" -DOT_BACKBONE_ROUTER_MULTICAST_ROUTING=OFF 186 187 # Build with Vendor Extension 188 reset_source 189 "$(dirname "$0")"/cmake-build simulation \ 190 -DOT_THREAD_VERSION=1.1 \ 191 -DOT_VENDOR_EXTENSION=../../src/core/common/extension_example.cpp 192 193 # Build Thread 1.3 with no additional features 194 reset_source 195 "$(dirname "$0")"/cmake-build simulation -DOT_THREAD_VERSION=1.3 196 197 # Build Thread 1.3 with full features and OT_ASSERT=OFF 198 reset_source 199 "$(dirname "$0")"/cmake-build simulation "${options[@]}" -DOT_DUA=ON -DOT_ASSERT=OFF 200 201 # Build with RAM settings 202 reset_source 203 "$(dirname "$0")"/cmake-build simulation -DOT_SETTINGS_RAM=ON 204} 205 206build_nest_common() 207{ 208 local cppflags=( 209 "-DOPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE=1" 210 "-DOPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE=1" 211 "-DOPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=1" 212 "-DOPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE=1" 213 "-DOPENTHREAD_CONFIG_DIAG_ENABLE=1" 214 "-DOPENTHREAD_CONFIG_JAM_DETECTION_ENABLE=1" 215 "-DOPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1" 216 "-DOPENTHREAD_CONFIG_PING_SENDER_ENABLE=1" 217 "-DOPENTHREAD_CONFIG_NCP_SPI_ENABLE=1" 218 "-DOPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE=1" 219 "-DOPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE=1" 220 ) 221 222 reset_source 223 mkdir build && cd build 224 CFLAGS="${cppflags[*]} ${CFLAGS}" CXXFLAGS="${cppflags[*]} ${CXXFLAGS}" \ 225 cmake -GNinja -DOT_PLATFORM=simulation .. 226 ninja 227 cd .. 228 229 cppflags=( 230 "-DOPENTHREAD_CONFIG_ANOUNCE_SENDER_ENABLE=1" 231 "-DOPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE=1" 232 "-DOPENTHREAD_CONFIG_TIME_SYNC_ENABLE=1" 233 "-DOPENTHREAD_CONFIG_NCP_HDLC_ENABLE=1" 234 ) 235 236 reset_source 237 mkdir build && cd build 238 CFLAGS="${cppflags[*]} ${CFLAGS}" CXXFLAGS="${cppflags[*]} ${CXXFLAGS}" \ 239 cmake -GNinja -DOT_PLATFORM=simulation .. 240 ninja 241 cd .. 242 243 cppflags=( 244 "-DOPENTHREAD_CONFIG_NCP_HDLC_ENABLE=1" 245 "-DOPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE=1" 246 ) 247 248 reset_source 249 mkdir build && cd build 250 CFLAGS="${cppflags[*]} ${CFLAGS}" CXXFLAGS="${cppflags[*]} ${CXXFLAGS}" \ 251 cmake -GNinja -DOT_PLATFORM=simulation \ 252 -DOT_VENDOR_EXTENSION=common/extension_example.cpp \ 253 -DOT_NCP_VENDOR_HOOK_SOURCE=example_vendor_hook.cpp \ 254 .. 255 ninja 256 cd .. 257} 258 259build_multi_radio_links() 260{ 261 # TREL radio link only. 262 reset_source 263 ./script/cmake-build simulation -DOT_LOG_LEVEL=DEBG \ 264 -DOT_TREL=OFF -DOT_15_4=ON 265 266 # Multi radio link - 15.4 and TREL. 267 reset_source 268 ./script/cmake-build simulation -DOT_LOG_LEVEL=DEBG \ 269 -DOT_TREL=ON -DOT_15_4=ON 270} 271main() 272{ 273 build_all_features 274 build_nest_common 275 build_multi_radio_links 276} 277 278main "$@" 279