[toranj] update build.sh script to use CMake for all builds (#9115)

This commit is contained in:
Abtin Keshavarzian
2023-06-01 21:39:45 -07:00
committed by GitHub
parent 9bff9f0807
commit 80eb7f512f
4 changed files with 85 additions and 161 deletions
+10 -1
View File
@@ -71,6 +71,8 @@ jobs:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y ninja-build lcov
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build & Run
run: |
top_builddir=$(pwd)/build/toranj ./tests/toranj/start.sh
@@ -138,8 +140,15 @@ jobs:
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build & Run
run: |
./tests/toranj/build.sh cmake
./tests/toranj/build.sh all
ninja test
# Validate posix builds with different radio configs
git clean -dfx
./tests/toranj/build.sh posix-15.4
git clean -dfx
./tests/toranj/build.sh posix-15.4+trel
git clean -dfx
./tests/toranj/build.sh posix-trel
upload-coverage:
needs:
-9
View File
@@ -42,15 +42,6 @@ build()
if [[ $OSTYPE != "darwin"* ]]; then
reset_source
make -f src/posix/Makefile-posix RCP_RESTORATION_MAX_COUNT=2 RCP_BUS=spi
reset_source
./tests/toranj/build.sh posix
reset_source
./tests/toranj/build.sh posix-15.4+trel
reset_source
./tests/toranj/build.sh posix-trel
fi
}
+1 -15
View File
@@ -14,21 +14,7 @@
To build OpenThread with `toranj` configuration, the `test/toranj/build.sh` script can be used:
```bash
$ ./tests/toranj/build.sh cmake
====================================================================================================
Building OpenThread (NCP/CLI for FTD/MTD/RCP mode) with simulation platform using cmake
====================================================================================================
-- OpenThread Source Directory: /Users/abtink/GitHub/openthread
-- OpenThread CMake build type: Debug
-- Package Name: OPENTHREAD
...
```
Or to build using autoconf/make we can use:
```bash
$ ./tests/toranj/build.sh cli
$ ./tests/toranj/build.sh all
====================================================================================================
Building OpenThread (NCP/CLI for FTD/MTD/RCP mode) with simulation platform using cmake
====================================================================================================
+74 -136
View File
@@ -34,25 +34,23 @@ display_usage()
echo ""
echo "Usage: $(basename "$0") [options] <config>"
echo " <config> can be:"
echo " ncp : Build OpenThread NCP FTD mode with simulation platform"
echo " ncp-15.4 : Build OpenThread NCP FTD mode with simulation platform - 15.4 radio"
echo " ncp-trel : Build OpenThread NCP FTD mode with simulation platform - TREL radio "
echo " ncp-15.4+trel : Build OpenThread NCP FTD mode with simulation platform - multi radio (15.4+TREL)"
echo " cli : Build OpenThread CLI FTD mode with simulation platform"
echo " cli-15.4 : Build OpenThread CLI FTD mode with simulation platform - 15.4 radio"
echo " cli-trel : Build OpenThread CLI FTD mode with simulation platform - TREL radio "
echo " cli-15.4+trel : Build OpenThread CLI FTD mode with simulation platform - multi radio (15.4+TREL)"
echo " all : Build OpenThread NCP, CLI, and RCP with simulation platform"
echo " ncp : Build OpenThread NCP mode with simulation platform"
echo " ncp-15.4 : Build OpenThread NCP mode with simulation platform - 15.4 radio"
echo " ncp-trel : Build OpenThread NCP mode with simulation platform - TREL radio "
echo " ncp-15.4+trel : Build OpenThread NCP mode with simulation platform - multi radio (15.4+TREL)"
echo " cli : Build OpenThread CLI mode with simulation platform"
echo " cli-15.4 : Build OpenThread CLI mode with simulation platform - 15.4 radio"
echo " cli-trel : Build OpenThread CLI mode with simulation platform - TREL radio "
echo " cli-15.4+trel : Build OpenThread CLI mode with simulation platform - multi radio (15.4+TREL)"
echo " rcp : Build OpenThread RCP (NCP in radio mode) with simulation platform"
echo " posix : Build OpenThread POSIX NCP"
echo " posix-15.4 : Build OpenThread POSIX NCP - 15.4 radio"
echo " posix-trel : Build OpenThread POSIX NCP - TREL radio "
echo " posix-15.4+trel : Build OpenThread POSIX NCP - multi radio (15.4+TREL)"
echo " cmake : Configure and build OpenThread using cmake/ninja (RCP and NCP) only"
echo " cmake-posix: : Configure and build OpenThread POSIX using cmake/ninja"
echo " posix : Build OpenThread POSIX"
echo " posix-15.4 : Build OpenThread POSIX - 15.4 radio"
echo " posix-trel : Build OpenThread POSIX - TREL radio "
echo " posix-15.4+trel : Build OpenThread POSIX - multi radio (15.4+TREL)"
echo ""
echo "Options:"
echo " -c/--enable-coverage Enable code coverage"
echo " -t/--enable-tests Enable tests"
echo ""
}
@@ -65,20 +63,15 @@ die()
cd "$(dirname "$0")" || die "cd failed"
cd ../.. || die "cd failed"
coverage=no
tests=no
ot_coverage=OFF
while [ $# -ge 2 ]; do
case $1 in
-c | --enable-coverage)
coverage=yes
ot_coverage=ON
shift
;;
-t | --enable-tests)
tests=yes
shift
;;
"")
@@ -99,22 +92,6 @@ fi
build_config=$1
ncp_configure_options=(
"--disable-docs"
"--enable-tests=$tests"
"--enable-coverage=$coverage"
"--enable-ftd"
"--enable-ncp"
)
posix_configure_options=(
"--disable-docs"
"--enable-tests=$tests"
"--enable-coverage=$coverage"
"--enable-ftd"
"--enable-cli"
)
if [ -n "${top_builddir}" ]; then
top_srcdir=$(pwd)
mkdir -p "${top_builddir}"
@@ -126,72 +103,61 @@ fi
case ${build_config} in
ncp | ncp-)
echo "==================================================================================================="
echo "Building OpenThread NCP FTD mode with simulation platform (radios determined by config)"
echo "Building OpenThread NCP with simulation platform (radios determined by config)"
echo "==================================================================================================="
./bootstrap || die "bootstrap failed"
cd "${top_builddir}" || die "cd failed"
cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config-simulation.h\"'
${top_srcdir}/configure \
CPPFLAGS="$cppflags_config" \
--with-examples=simulation \
"${ncp_configure_options[@]}" || die
make -j 8 || die
cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_APP_CLI=OFF -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \
-DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \
"${top_srcdir}" || die
ninja || die
;;
ncp-15.4)
echo "==================================================================================================="
echo "Building OpenThread NCP FTD mode with simulation platform - 15.4 radio"
echo "Building OpenThread NCP with simulation platform - 15.4 radio"
echo "==================================================================================================="
cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config-simulation.h\"'
cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE=1"
cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE=0"
./bootstrap || die "bootstrap failed"
cd "${top_builddir}" || die "cd failed"
${top_srcdir}/configure \
CPPFLAGS="$cppflags_config" \
--with-examples=simulation \
"${ncp_configure_options[@]}" || die
make -j 8 || die
cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_APP_CLI=OFF -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \
-DOT_15_4=ON -DOT_TREL=OFF \
-DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \
"${top_srcdir}" || die
ninja || die
cp -p ${top_builddir}/examples/apps/ncp/ot-ncp-ftd ${top_builddir}/examples/apps/ncp/ot-ncp-ftd-15.4
;;
ncp-trel)
echo "==================================================================================================="
echo "Building OpenThread NCP FTD mode with simulation platform - TREL radio"
echo "Building OpenThread NCP with simulation platform - TREL radio"
echo "==================================================================================================="
cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config-simulation.h\"'
cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE=0"
cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE=1"
./bootstrap || die "bootstrap failed"
cd "${top_builddir}" || die "cd failed"
${top_srcdir}/configure \
CPPFLAGS="$cppflags_config" \
--with-examples=simulation \
"${ncp_configure_options[@]}" || die
make -j 8 || die
cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_APP_CLI=OFF -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \
-DOT_15_4=OFF -DOT_TREL=ON \
-DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \
"${top_srcdir}" || die
ninja || die
cp -p ${top_builddir}/examples/apps/ncp/ot-ncp-ftd ${top_builddir}/examples/apps/ncp/ot-ncp-ftd-trel
;;
ncp-15.4+trel | ncp-trel+15.4)
echo "==================================================================================================="
echo "Building OpenThread NCP FTD mode with simulation platform - multi radio (15.4 + TREL)"
echo "Building OpenThread NCP with simulation platform - multi radio (15.4 + TREL)"
echo "==================================================================================================="
cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config-simulation.h\"'
cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE=1"
cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE=1"
./bootstrap || die "bootstrap failed"
cd "${top_builddir}" || die "cd failed"
${top_srcdir}/configure \
CPPFLAGS="$cppflags_config" \
--with-examples=simulation \
"${ncp_configure_options[@]}" || die
make -j 8 || die
cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_APP_CLI=OFF -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \
-DOT_15_4=ON -DOT_TREL=ON \
-DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \
"${top_srcdir}" || die
ninja || die
cp -p ${top_builddir}/examples/apps/ncp/ot-ncp-ftd ${top_builddir}/examples/apps/ncp/ot-ncp-ftd-15.4-trel
;;
cli | cli-)
echo "==================================================================================================="
echo "Building OpenThread CLI FTD mode with simulation platform (radios determined by config)"
echo "Building OpenThread CLI with simulation platform (radios determined by config)"
echo "==================================================================================================="
cd "${top_builddir}" || die "cd failed"
cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
@@ -203,7 +169,7 @@ case ${build_config} in
cli-15.4)
echo "==================================================================================================="
echo "Building OpenThread CLI FTD mode with simulation platform - 15.4 radio"
echo "Building OpenThread CLI with simulation platform - 15.4 radio"
echo "==================================================================================================="
cd "${top_builddir}" || die "cd failed"
cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
@@ -217,7 +183,7 @@ case ${build_config} in
cli-trel)
echo "==================================================================================================="
echo "Building OpenThread CLI FTD mode with simulation platform - TREL radio"
echo "Building OpenThread CLI with simulation platform - TREL radio"
echo "==================================================================================================="
cd "${top_builddir}" || die "cd failed"
cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
@@ -231,7 +197,7 @@ case ${build_config} in
cli-15.4+trel | cli-trel+15.4)
echo "==================================================================================================="
echo "Building OpenThread NCP FTD mode with simulation platform - multi radio (15.4 + TREL)"
echo "Building OpenThread NCP with simulation platform - multi radio (15.4 + TREL)"
echo "==================================================================================================="
cd "${top_builddir}" || die "cd failed"
cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
@@ -247,83 +213,66 @@ case ${build_config} in
echo "===================================================================================================="
echo "Building OpenThread RCP (NCP in radio mode) with simulation platform"
echo "===================================================================================================="
./bootstrap || die "bootstrap failed"
cd "${top_builddir}" || die "cd failed"
cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config-simulation.h\"'
${top_srcdir}/configure \
CPPFLAGS="$cppflags_config " \
--enable-coverage=${coverage} \
--enable-ncp \
--enable-radio-only \
--with-examples=simulation \
--disable-docs \
--enable-tests=$tests || die
make -j 8 || die
cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_APP_CLI=OFF -DOT_APP_NCP=OFF -DOT_APP_RCP=ON \
-DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \
"${top_srcdir}" || die
ninja || die
;;
posix | posix-)
posix | posix- | cmake-posix-host | cmake-posix | cmake-p)
echo "===================================================================================================="
echo "Building OpenThread POSIX (radios determined by config)"
echo "===================================================================================================="
cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config-posix.h\"'
./bootstrap || die "bootstrap failed"
cd "${top_builddir}" || die "cd failed"
${top_srcdir}/configure \
CPPFLAGS="$cppflags_config" \
--with-platform=posix \
"${posix_configure_options[@]}" || die
make -j 8 || die
cmake -GNinja -DOT_PLATFORM=posix -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_APP_CLI=ON -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \
-DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-posix.h \
"${top_srcdir}" || die
ninja || die
;;
posix-15.4)
echo "===================================================================================================="
echo "Building OpenThread POSIX - 15.4 radio"
echo "===================================================================================================="
cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config-posix.h\"'
cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE=1"
cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE=0"
./bootstrap || die "bootstrap failed"
cd "${top_builddir}" || die "cd failed"
${top_srcdir}/configure \
CPPFLAGS="$cppflags_config" \
--with-platform=posix \
"${posix_configure_options[@]}" || die
make -j 8 || die
cmake -GNinja -DOT_PLATFORM=posix -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_APP_CLI=ON -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \
-DOT_15_4=ON -DOT_TREL=OFF \
-DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-posix.h \
"${top_srcdir}" || die
ninja || die
;;
posix-trel)
echo "===================================================================================================="
echo "Building OpenThread POSIX - TREL radio"
echo "===================================================================================================="
cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config-posix.h\"'
cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE=0"
cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE=1"
./bootstrap || die "bootstrap failed"
cd "${top_builddir}" || die "cd failed"
${top_srcdir}/configure \
CPPFLAGS="$cppflags_config" \
--with-platform=posix \
"${posix_configure_options[@]}" || die
make -j 8 || die
cmake -GNinja -DOT_PLATFORM=posix -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_APP_CLI=ON -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \
-DOT_15_4=OFF -DOT_TREL=ON \
-DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-posix.h \
"${top_srcdir}" || die
ninja || die
;;
posix-trel+15.4 | posix-15.4+trel)
echo "===================================================================================================="
echo "Building OpenThread POSIX - multi radio link (15.4 + TREL)"
echo "===================================================================================================="
cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config-posix.h\"'
cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE=1"
cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE=1"
./bootstrap || die "bootstrap failed"
cd "${top_builddir}" || die "cd failed"
${top_srcdir}/configure \
CPPFLAGS="$cppflags_config" \
--with-platform=posix \
"${posix_configure_options[@]}" || die
make -j 8 || die
cmake -GNinja -DOT_PLATFORM=posix -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_APP_CLI=ON -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \
-DOT_15_4=ON -DOT_TREL=ON \
-DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-posix.h \
"${top_srcdir}" || die
ninja || die
;;
cmake)
all | cmake)
echo "===================================================================================================="
echo "Building OpenThread (NCP/CLI for FTD/MTD/RCP mode) with simulation platform using cmake"
echo "===================================================================================================="
@@ -335,17 +284,6 @@ case ${build_config} in
ninja || die
;;
cmake-posix-host | cmake-posix | cmake-p)
echo "===================================================================================================="
echo "Building OpenThread POSIX using cmake"
echo "===================================================================================================="
cd "${top_builddir}" || die "cd failed"
cmake -GNinja -DOT_PLATFORM=posix -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_APP_CLI=OFF \
-DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-posix.h \
"${top_srcdir}" || die
ninja || die
;;
*)
echo "Error: Unknown configuration \"$1\""
display_usage