From 4cb09ec637e80e45a0c4891a919259fc24696dbb Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Tue, 24 Mar 2020 20:45:19 -0700 Subject: [PATCH] [continuous-integration] initial migration to GitHub actions (#4728) --- .github/workflows/build.yml | 220 +++++++++++++++++++ script/check-arm-build | 38 ++++ script/check-arm-build-autotools | 269 ++++++++++++++++++++++++ script/check-arm-build-cmake | 63 ++++++ script/check-scan-build | 113 ++++++++++ script/check-simulation-build | 38 ++++ script/check-simulation-build-autotools | 178 ++++++++++++++++ script/check-simulation-build-cmake | 97 +++++++++ 8 files changed, 1016 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100755 script/check-arm-build create mode 100755 script/check-arm-build-autotools create mode 100755 script/check-arm-build-cmake create mode 100755 script/check-scan-build create mode 100755 script/check-simulation-build create mode 100755 script/check-simulation-build-autotools create mode 100755 script/check-simulation-build-cmake diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..915a81fd4 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,220 @@ +# +# 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. +# + +name: Build + +on: [push, pull_request] + +jobs: + + cancel-previous-runs: + runs-on: ubuntu-latest + steps: + - uses: rokroskar/workflow-run-cleanup-action@master + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + if: "github.ref != 'refs/heads/master'" + + pretty: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - name: Bootstrap + run: | + sudo apt-get update + sudo apt-get remove -y clang-6.0 libclang-common-6.0-dev libclang1-6.0 libllvm6.0 + sudo apt-get autoremove + sudo apt-get --no-install-recommends install -y clang-tools clang-format-6.0 + clang-format-6.0 --version + python3 -m pip install yapf + - name: Check + run: script/make-pretty check + + package: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - name: Package + run: script/test package + + scan-build: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - name: Bootstrap + run: | + sudo apt-get update + sudo apt-get remove -y clang-6.0 libclang-common-6.0-dev libclang1-6.0 libllvm6.0 + sudo apt-get autoremove + sudo apt-get --no-install-recommends install -y clang-tools + - name: Run + run: script/check-scan-build + + arm-gcc-4: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - name: Bootstrap + run: | + cd /tmp + sudo apt-get --no-install-recommends install -y lib32z1 ninja-build + wget https://launchpad.net/gcc-arm-embedded/4.9/4.9-2015-q3-update/+download/gcc-arm-none-eabi-4_9-2015q3-20150921-linux.tar.bz2 + tar xjf gcc-arm-none-eabi-4_9-2015q3-20150921-linux.tar.bz2 + - name: Build + run: | + export PATH=/tmp/gcc-arm-none-eabi-4_9-2015q3/bin:$PATH + script/check-arm-build + + arm-gcc-5: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - name: Bootstrap + run: | + cd /tmp + sudo apt-get --no-install-recommends install -y lib32z1 ninja-build + wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/5_4-2016q3/gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2 + tar xjf gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2 + - name: Build + run: | + export PATH=/tmp/gcc-arm-none-eabi-5_4-2016q3/bin:$PATH + script/check-arm-build + + arm-gcc-6: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - name: Bootstrap + run: | + cd /tmp + sudo apt-get --no-install-recommends install -y ninja-build + wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/6-2017q2/gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2 + tar xjf gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2 + - name: Build + run: | + export PATH=/tmp/gcc-arm-none-eabi-6-2017-q2-update/bin:$PATH + script/check-arm-build + + arm-gcc-7: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - name: Bootstrap + run: | + cd /tmp + sudo apt-get --no-install-recommends install -y ninja-build + wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/7-2018q2/gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2 + tar xjf gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2 + - name: Build + run: | + export PATH=/tmp/gcc-arm-none-eabi-7-2018-q2-update/bin:$PATH + script/check-arm-build + + arm-gcc-9: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - name: Bootstrap + run: | + cd /tmp + sudo apt-get --no-install-recommends install -y ninja-build + wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/RC2.1/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2 + tar xjf gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2 + - name: Build + run: | + export PATH=/tmp/gcc-arm-none-eabi-9-2019-q4-major/bin:$PATH + script/check-arm-build + + gcc-5: + runs-on: ubuntu-18.04 + env: + CC: gcc-5 + CXX: g++-5 + steps: + - uses: actions/checkout@v2 + - name: Bootstrap + run: sudo apt-get --no-install-recommends install -y gcc-5 g++-5 ninja-build + - name: Build + run: script/check-simulation-build + + gcc-6: + runs-on: ubuntu-18.04 + env: + CC: gcc-6 + CXX: g++-6 + steps: + - uses: actions/checkout@v2 + - name: Bootstrap + run: sudo apt-get --no-install-recommends install -y gcc-6 g++-6 ninja-build + - name: Build + run: script/check-simulation-build + + gcc-7: + runs-on: ubuntu-18.04 + env: + CC: gcc-7 + CXX: g++-7 + steps: + - uses: actions/checkout@v2 + - name: Bootstrap + run: sudo apt-get --no-install-recommends install -y gcc-7 g++-7 ninja-build + - name: Build + run: script/check-simulation-build + + gcc-8: + runs-on: ubuntu-18.04 + env: + CC: gcc-8 + CXX: g++-8 + steps: + - uses: actions/checkout@v2 + - name: Bootstrap + run: sudo apt-get --no-install-recommends install -y gcc-8 g++-8 ninja-build + - name: Build + run: script/check-simulation-build + + gcc-9: + runs-on: ubuntu-18.04 + env: + CC: gcc-9 + CXX: g++-9 + steps: + - uses: actions/checkout@v2 + - name: Bootstrap + run: sudo apt-get --no-install-recommends install -y gcc-9 g++-9 ninja-build + - name: Build + run: script/check-simulation-build + + macos: + runs-on: macos-10.15 + steps: + - uses: actions/checkout@v2 + - name: Bootstrap + run: brew install automake ninja + - name: Build + run: script/check-simulation-build diff --git a/script/check-arm-build b/script/check-arm-build new file mode 100755 index 000000000..2f302d625 --- /dev/null +++ b/script/check-arm-build @@ -0,0 +1,38 @@ +#!/bin/bash +# +# 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. +# + +set -euxo pipefail + +main() +{ + "$(dirname "$0")"/check-arm-build-autotools + "$(dirname "$0")"/check-arm-build-cmake +} + +main "$@" diff --git a/script/check-arm-build-autotools b/script/check-arm-build-autotools new file mode 100755 index 000000000..762d1f1bd --- /dev/null +++ b/script/check-arm-build-autotools @@ -0,0 +1,269 @@ +#!/bin/bash +# +# 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. +# + +set -euxo pipefail + +reset_source() +{ + rm -rf build output tmp +} + +build_cc1352() +{ + local options=( + "COMMISSIONER=1" + "DHCP6_CLIENT=1" + "DHCP6_SERVER=1" + "DNS_CLIENT=1" + "JOINER=1" + "SLAAC=1" + ) + + reset_source + make -f examples/Makefile-cc1352 "${options[@]}" +} + +build_cc2538() +{ + local options=( + "COMMISSIONER=1" + "DHCP6_CLIENT=1" + "DHCP6_SERVER=1" + "DNS_CLIENT=1" + "JOINER=1" + "SLAAC=1" + ) + + reset_source + make -f examples/Makefile-cc2538 "${options[@]}" +} + +build_cc2650() +{ + reset_source + make -f examples/Makefile-cc2650 +} + +build_cc2652() +{ + local options=( + "COMMISSIONER=1" + "DHCP6_CLIENT=1" + "DHCP6_SERVER=1" + "DNS_CLIENT=1" + "JOINER=1" + "SLAAC=1" + ) + + reset_source + make -f examples/Makefile-cc2652 "${options[@]}" +} + +build_kw41z() +{ + local options=( + "COMMISSIONER=1" + "DHCP6_CLIENT=1" + "DHCP6_SERVER=1" + "DNS_CLIENT=1" + "JOINER=1" + "SLAAC=1" + ) + + reset_source + make -f examples/Makefile-kw41z "${options[@]}" +} + +build_nrf52811() +{ + local options=( + "BORDER_ROUTER=1" + "COAP=1" + "DNS_CLIENT=1" + "LINK_RAW=1" + "MAC_FILTER=1" + "MTD_NETDIAG=1" + ) + + # UART transport + reset_source + make -f examples/Makefile-nrf52811 "${options[@]}" + + # SPI transport for NCP + reset_source + make -f examples/Makefile-nrf52811 "${options[@]}" NCP_SPI=1 + + # Build without transport (no CLI or NCP applications) + reset_source + make -f examples/Makefile-nrf52811 DISABLE_TRANSPORTS=1 +} + +build_nrf52833() +{ + local options=( + "BORDER_AGENT=1" + "BORDER_ROUTER=1" + "COAP=1" + "COAPS=1" + "COMMISSIONER=1" + "DHCP6_CLIENT=1" + "DHCP6_SERVER=1" + "DNS_CLIENT=1" + "ECDSA=1" + "FULL_LOGS=1" + "IP6_FRAGM=1" + "JOINER=1" + "LINK_RAW=1" + "MAC_FILTER=1" + "MTD_NETDIAG=1" + "SERVICE=1" + "SLAAC=1" + "SNTP_CLIENT=1" + "UDP_FORWARD=1" + ) + + # UART transport + reset_source + make -f examples/Makefile-nrf52833 "${options[@]}" + + # USB transport + reset_source + make -f examples/Makefile-nrf52833 "${options[@]}" USB=1 + + # SPI transport for NCP + reset_source + make -f examples/Makefile-nrf52833 "${options[@]}" NCP_SPI=1 + + # Build without transport (no CLI or NCP applications) + reset_source + make -f examples/Makefile-nrf52833 "${options[@]}" DISABLE_TRANSPORTS=1 +} + +build_nrf52840() +{ + local options=( + "BORDER_AGENT=1" + "BORDER_ROUTER=1" + "COAP=1" + "COAPS=1" + "COMMISSIONER=1" + "DEBUG=1" + "DHCP6_CLIENT=1" + "DHCP6_SERVER=1" + "DNS_CLIENT=1" + "ECDSA=1" + "FULL_LOGS=1" + "IP6_FRAGM=1" + "JOINER=1" + "LINK_RAW=1" + "MAC_FILTER=1" + "MTD_NETDIAG=1" + "SERVICE=1" + "SLAAC=1" + "SNTP_CLIENT=1" + "UDP_FORWARD=1" + ) + + # UART transport + reset_source + make -f examples/Makefile-nrf52840 "${options[@]}" + + # USB transport with bootloader e.g. to support PCA10059 dongle + reset_source + make -f examples/Makefile-nrf52840 "${options[@]}" BOOTLOADER=1 USB=1 + + # SPI transport for NCP + reset_source + make -f examples/Makefile-nrf52840 "${options[@]}" NCP_SPI=1 + + # Build without transport (no CLI or NCP applications) + reset_source + make -f examples/Makefile-nrf52840 "${options[@]}" DISABLE_TRANSPORTS=1 + + # Software cryptography + reset_source + make -f examples/Makefile-nrf52840 "${options[@]}" DISABLE_BUILTIN_MBEDTLS=0 + + # Software cryptography with threading support + reset_source + make -f examples/Makefile-nrf52840 "${options[@]}" DISABLE_BUILTIN_MBEDTLS=0 MBEDTLS_THREADING=1 +} + +build_qpg6095() +{ + local options=( + "COMMISSIONER=1" + "DHCP6_CLIENT=1" + "DHCP6_SERVER=1" + "DNS_CLIENT=1" + "JOINER=1" + "SLAAC=1" + ) + + reset_source + make -f examples/Makefile-qpg6095 "${options[@]}" +} + +build_samr21() +{ + local options=( + "COMMISSIONER=1" + "DHCP6_CLIENT=1" + "DHCP6_SERVER=1" + "DNS_CLIENT=1" + "JOINER=1" + "SLAAC=1" + ) + + reset_source + + wget http://ww1.microchip.com/downloads/en/DeviceDoc/asf-standalone-archive-3.45.0.85.zip + unzip -qq asf-standalone-archive-3.45.0.85.zip + mv xdk-asf-3.45.0 third_party/microchip/asf + + make -f examples/Makefile-samr21 "${options[@]}" +} + +main() +{ + ./bootstrap + + build_cc1352 + build_cc2538 + build_cc2650 + build_cc2652 + build_kw41z + build_nrf52811 + build_nrf52833 + build_nrf52840 + build_qpg6095 + build_samr21 +} + +main "$@" diff --git a/script/check-arm-build-cmake b/script/check-arm-build-cmake new file mode 100755 index 000000000..52b65050d --- /dev/null +++ b/script/check-arm-build-cmake @@ -0,0 +1,63 @@ +#!/bin/bash +# +# 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. +# + +set -euxo pipefail + +readonly OT_COMMON_OPTIONS=( + "-DOT_COMPILE_WARNING_AS_ERROR=ON" +) + +reset_source() +{ + git checkout -- . + git clean -xfd +} + +build_cc2538() +{ + local options=("${OT_COMMON_OPTIONS[@]}") + + options+=( + "-DOT_PLATFORM=cc2538" + "-DCMAKE_TOOLCHAIN_FILE=examples/platforms/cc2538/arm-none-eabi.cmake" + ) + + reset_source + mkdir build + cd build + cmake -GNinja "${options[@]}" .. + ninja +} + +main() +{ + build_cc2538 +} + +main "$@" diff --git a/script/check-scan-build b/script/check-scan-build new file mode 100755 index 000000000..97bd6fd6e --- /dev/null +++ b/script/check-scan-build @@ -0,0 +1,113 @@ +#!/bin/bash +# +# 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. +# + +set -euxo pipefail + +readonly OT_BUILD_JOBS=$(getconf _NPROCESSORS_ONLN) + +do_scan_build() +{ + local options=( + "-DOPENTHREAD_CONFIG_ANNOUNCE_SENDER_ENABLE=1" + "-DOPENTHREAD_CONFIG_BORDER_AGENT_ENABLE=1" + "-DOPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE=1" + "-DOPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE=1" + "-DOPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=1" + "-DOPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE=1" + "-DOPENTHREAD_CONFIG_COAP_API_ENABLE=1" + "-DOPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE=1" + "-DOPENTHREAD_CONFIG_COMMISSIONER_ENABLE=1" + "-DOPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE=1" + "-DOPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE=1" + "-DOPENTHREAD_CONFIG_DIAG_ENABLE=1" + "-DOPENTHREAD_CONFIG_DNS_CLIENT_ENABLE=1" + "-DOPENTHREAD_CONFIG_ECDSA_ENABLE=1" + "-DOPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE=1" + "-DOPENTHREAD_CONFIG_IP6_FRAGMENTATION_ENABLE=1" + "-DOPENTHREAD_CONFIG_IP6_SLAAC_ENABLE=1" + "-DOPENTHREAD_CONFIG_LEGACY_ENABLE=1" + "-DOPENTHREAD_CONFIG_MAC_BEACON_RSP_WHEN_JOINABLE_ENABLE=1" + "-DOPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE=1" + "-DOPENTHREAD_CONFIG_MLE_ATTACH_BACKOFF_ENABLE=1" + "-DOPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE=1" + "-DOPENTHREAD_CONFIG_MPL_DYNAMIC_INTERVAL_ENABLE" + "-DOPENTHREAD_CONFIG_JAM_DETECTION_ENABLE=1" + "-DOPENTHREAD_CONFIG_JOINER_ENABLE=1" + "-DOPENTHREAD_CONFIG_LINK_RAW_ENABLE=1" + "-DOPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1" + "-DOPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1" + "-DOPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE=1" + "-DOPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE=1" + "-DOPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE=1" + "-DOPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE=1" + "-DOPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE=1" + "-DOPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE=1" + "-DOPENTHREAD_CONFIG_SOFTWARE_ACK_TIMEOUT_ENABLE=1" + "-DOPENTHREAD_CONFIG_SOFTWARE_CSMA_BACKOFF_ENABLE=1" + "-DOPENTHREAD_CONFIG_SOFTWARE_ENERGY_SCAN_ENABLE=1" + "-DOPENTHREAD_CONFIG_SOFTWARE_RETRANSMIT_ENABLE=1" + "-DOPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE=1" + "-DOPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE=1" + "-DOPENTHREAD_CONFIG_UDP_FORWARD_ENABLE=1" + ) + options+=( + "-DMBEDTLS_DEBUG_C" + "-I$(pwd)/third_party/mbedtls" + "-I$(pwd)/third_party/mbedtls/repo/include" + "-DMBEDTLS_CONFIG_FILE=\\\"mbedtls-config.h\\\"" + ) + + configure_options=( + "--enable-builtin-mbedtls=no" + "--enable-cli" + "--enable-executable=no" + "--enable-ftd" + "--enable-mtd" + "--enable-ncp" + "--enable-radio-only" + "--with-examples=simulation" + ) + + export CPPFLAGS="${options[*]} -DOPENTHREAD_CONFIG_NCP_SPI_ENABLE=1" + scan-build ./configure "${configure_options[@]}" + scan-build --status-bugs -analyze-headers -v make -j"${OT_BUILD_JOBS}" + + export CPPFLAGS="${options[*]} -DOPENTHREAD_CONFIG_NCP_UART_ENABLE=1" + scan-build ./configure "${configure_options[@]}" + scan-build --status-bugs -analyze-headers -v make -j"${OT_BUILD_JOBS}" +} + +main() +{ + ./bootstrap + + do_scan_build +} + +main "$@" diff --git a/script/check-simulation-build b/script/check-simulation-build new file mode 100755 index 000000000..4c31fd9f6 --- /dev/null +++ b/script/check-simulation-build @@ -0,0 +1,38 @@ +#!/bin/bash +# +# 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. +# + +set -euxo pipefail + +main() +{ + "$(dirname "$0")"/check-simulation-build-autotools + "$(dirname "$0")"/check-simulation-build-cmake +} + +main "$@" diff --git a/script/check-simulation-build-autotools b/script/check-simulation-build-autotools new file mode 100755 index 000000000..ae3d16629 --- /dev/null +++ b/script/check-simulation-build-autotools @@ -0,0 +1,178 @@ +#!/bin/bash +# +# 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. +# + +set -euxo pipefail + +readonly OT_BUILD_JOBS=$(getconf _NPROCESSORS_ONLN) + +reset_source() +{ + rm -rf build output tmp +} + +build_all_features() +{ + local options=( + "-DOPENTHREAD_CONFIG_ANNOUNCE_SENDER_ENABLE=1" + "-DOPENTHREAD_CONFIG_BORDER_AGENT_ENABLE=1" + "-DOPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE=1" + "-DOPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE=1" + "-DOPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=1" + "-DOPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE=1" + "-DOPENTHREAD_CONFIG_COAP_API_ENABLE=1" + "-DOPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE=1" + "-DOPENTHREAD_CONFIG_COMMISSIONER_ENABLE=1" + "-DOPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE=1" + "-DOPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE=1" + "-DOPENTHREAD_CONFIG_DIAG_ENABLE=1" + "-DOPENTHREAD_CONFIG_DNS_CLIENT_ENABLE=1" + "-DOPENTHREAD_CONFIG_ECDSA_ENABLE=1" + "-DOPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE=1" + "-DOPENTHREAD_CONFIG_IP6_FRAGMENTATION_ENABLE=1" + "-DOPENTHREAD_CONFIG_IP6_SLAAC_ENABLE=1" + "-DOPENTHREAD_CONFIG_LEGACY_ENABLE=1" + "-DOPENTHREAD_CONFIG_MAC_BEACON_RSP_WHEN_JOINABLE_ENABLE=1" + "-DOPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE=1" + "-DOPENTHREAD_CONFIG_MLE_ATTACH_BACKOFF_ENABLE=1" + "-DOPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE=1" + "-DOPENTHREAD_CONFIG_MPL_DYNAMIC_INTERVAL_ENABLE" + "-DOPENTHREAD_CONFIG_JAM_DETECTION_ENABLE=1" + "-DOPENTHREAD_CONFIG_JOINER_ENABLE=1" + "-DOPENTHREAD_CONFIG_LINK_RAW_ENABLE=1" + "-DOPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1" + "-DOPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1" + "-DOPENTHREAD_CONFIG_NCP_UART_ENABLE=1" + "-DOPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE=1" + "-DOPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE=1" + "-DOPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE=1" + "-DOPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE=1" + "-DOPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE=1" + "-DOPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE=1" + "-DOPENTHREAD_CONFIG_SOFTWARE_ACK_TIMEOUT_ENABLE=1" + "-DOPENTHREAD_CONFIG_SOFTWARE_CSMA_BACKOFF_ENABLE=1" + "-DOPENTHREAD_CONFIG_SOFTWARE_ENERGY_SCAN_ENABLE=1" + "-DOPENTHREAD_CONFIG_SOFTWARE_RETRANSMIT_ENABLE=1" + "-DOPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE=1" + "-DOPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE=1" + "-DOPENTHREAD_CONFIG_UDP_FORWARD_ENABLE=1" + ) + + export CPPFLAGS="${options[*]} -DOPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_NONE" + reset_source + make -f examples/Makefile-simulation + + export CPPFLAGS="${options[*]} -DOPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_DEBG" + reset_source + make -f examples/Makefile-simulation + + export CPPFLAGS="${options[*]} -DOPENTHREAD_CONFIG_ASSERT_ENABLE=0" + reset_source + make -f examples/Makefile-simulation +} + +build_nest_common() +{ + local options=( + "-DOPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE=1" + "-DOPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE=1" + "-DOPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=1" + "-DOPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE=1" + "-DOPENTHREAD_CONFIG_DIAG_ENABLE=1" + "-DOPENTHREAD_CONFIG_JAM_DETECTION_ENABLE=1" + "-DOPENTHREAD_CONFIG_LEGACY_ENABLE=1" + "-DOPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1" + "-DOPENTHREAD_CONFIG_NCP_SPI_ENABLE=1" + "-DOPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE=1" + "-DOPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE=1" + ) + export CPPFLAGS="${options[*]}" + + reset_source + mkdir build && cd build + ../configure \ + --enable-cli \ + --enable-mtd \ + --with-examples=simulation \ + --disable-docs \ + --disable-tests + make -j"${OT_BUILD_JOBS}" + cd .. + + options=( + "-DOPENTHREAD_CONFIG_ANOUNCE_SENDER_ENABLE=1" + "-DOPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE=1" + "-DOPENTHREAD_CONFIG_TIME_SYNC_ENABLE=1" + "-DOPENTHREAD_CONFIG_NCP_UART_ENABLE=1" + ) + export CPPFLAGS="${options[*]}" + + reset_source + mkdir build && cd build + ../configure \ + --enable-cli \ + --enable-ftd \ + --enable-mtd \ + --enable-ncp \ + --enable-radio-only \ + --disable-docs \ + --disable-tests \ + --with-examples=simulation + make -j"${OT_BUILD_JOBS}" + cd .. + + options=( + "-DOPENTHREAD_CONFIG_NCP_UART_ENABLE=1" + "-DOPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE=1" + ) + export CPPFLAGS="${options[*]}" + + reset_source + mkdir build && cd build + ../configure \ + --enable-ftd \ + --enable-mtd \ + --enable-ncp \ + --with-examples=simulation \ + --disable-docs \ + --disable-tests \ + --with-vendor-extension=../src/core/common/extension_example.cpp \ + --with-ncp-vendor-hook-source=../src/ncp/example_vendor_hook.cpp + make -j"${OT_BUILD_JOBS}" + cd .. +} + +main() +{ + ./bootstrap + + build_all_features + build_nest_common +} + +main "$@" diff --git a/script/check-simulation-build-cmake b/script/check-simulation-build-cmake new file mode 100755 index 000000000..92f278813 --- /dev/null +++ b/script/check-simulation-build-cmake @@ -0,0 +1,97 @@ +#!/bin/bash +# +# 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. +# + +set -euxo pipefail + +readonly OT_COMMON_OPTIONS=( + "-DOT_COMPILE_WARNING_AS_ERROR=on" + "-DOT_PLATFORM=simulation" +) + +reset_source() +{ + git checkout -- . + git clean -xfd +} + +build_all_features() +{ + local options=("${OT_COMMON_OPTIONS[@]}") + + options+=( + "-DOT_BORDER_AGENT=on" + "-DOT_BORDER_ROUTER=on" + "-DOT_COAP=on" + "-DOT_COAPS=on" + "-DOT_COMMISSIONER=on" + "-DOT_CHANNEL_MANAGER=on" + "-DOT_CHANNEL_MONITOR=on" + "-DOT_CHILD_SUPERVISION=on" + "-DOT_DHCP6_CLIENT=on" + "-DOT_DHCP6_SERVER=on" + "-DOT_DIAGNOSTIC=on" + "-DOT_DNS_CLIENT=on" + "-DOT_ECDSA=on" + "-DOT_IP6_FRAGM=on" + "-DOT_JAM_DETECTION=on" + "-DOT_JOINER=on" + "-DOT_LINK_RAW=on" + "-DOT_MAC_FILTER=on" + "-DOT_MTD_NETDIAG=on" + "-DOT_SERVICE=on" + "-DOT_SLAAC=on" + "-DOT_SNTP_CLIENT=on" + ) + + reset_source + + git checkout -- . + git clean -xfd + mkdir build && cd build + cmake -GNinja "${options[@]}" .. + ninja + cd .. +} + +build_toranj() +{ + reset_source + ./tests/toranj/build.sh cmake + + reset_source + ./tests/toranj/build.sh cmake-posix +} + +main() +{ + build_all_features + build_toranj +} + +main "$@"