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/instance/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 reset_source 206 "$(dirname "$0")"/cmake-build simulation -DOT_BLE_TCAT=ON 207} 208 209build_nest_common() 210{ 211 local cppflags=( 212 "-DOPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE=1" 213 "-DOPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE=1" 214 "-DOPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=1" 215 "-DOPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE=1" 216 "-DOPENTHREAD_CONFIG_DIAG_ENABLE=1" 217 "-DOPENTHREAD_CONFIG_JAM_DETECTION_ENABLE=1" 218 "-DOPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1" 219 "-DOPENTHREAD_CONFIG_PING_SENDER_ENABLE=1" 220 "-DOPENTHREAD_CONFIG_NCP_SPI_ENABLE=1" 221 "-DOPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE=1" 222 "-DOPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE=1" 223 ) 224 225 reset_source 226 mkdir build && cd build 227 CFLAGS="${cppflags[*]} ${CFLAGS}" CXXFLAGS="${cppflags[*]} ${CXXFLAGS}" \ 228 cmake -GNinja -DOT_PLATFORM=simulation .. 229 ninja 230 cd .. 231 232 cppflags=( 233 "-DOPENTHREAD_CONFIG_ANOUNCE_SENDER_ENABLE=1" 234 "-DOPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE=1" 235 "-DOPENTHREAD_CONFIG_TIME_SYNC_ENABLE=1" 236 "-DOPENTHREAD_CONFIG_NCP_HDLC_ENABLE=1" 237 ) 238 239 reset_source 240 mkdir build && cd build 241 CFLAGS="${cppflags[*]} ${CFLAGS}" CXXFLAGS="${cppflags[*]} ${CXXFLAGS}" \ 242 cmake -GNinja -DOT_PLATFORM=simulation .. 243 ninja 244 cd .. 245 246 cppflags=( 247 "-DOPENTHREAD_CONFIG_NCP_HDLC_ENABLE=1" 248 "-DOPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE=1" 249 ) 250 251 reset_source 252 mkdir build && cd build 253 CFLAGS="${cppflags[*]} ${CFLAGS}" CXXFLAGS="${cppflags[*]} ${CXXFLAGS}" \ 254 cmake -GNinja -DOT_PLATFORM=simulation \ 255 -DOT_VENDOR_EXTENSION=instance/extension_example.cpp \ 256 -DOT_NCP_VENDOR_HOOK_SOURCE=example_vendor_hook.cpp \ 257 .. 258 ninja 259 cd .. 260} 261 262build_multi_radio_links() 263{ 264 # TREL radio link only. 265 reset_source 266 ./script/cmake-build simulation -DOT_LOG_LEVEL=DEBG \ 267 -DOT_TREL=OFF -DOT_15_4=ON 268 269 # Multi radio link - 15.4 and TREL. 270 reset_source 271 ./script/cmake-build simulation -DOT_LOG_LEVEL=DEBG \ 272 -DOT_TREL=ON -DOT_15_4=ON 273} 274main() 275{ 276 build_all_features 277 build_nest_common 278 build_multi_radio_links 279} 280 281main "$@" 282