Skip to content

Commit

Permalink
[cmake] enhancements for supporting cmake in ot-br-posix (openthread#…
Browse files Browse the repository at this point in the history
  • Loading branch information
bukepo authored Apr 24, 2020
1 parent 7e5dce0 commit 32f8274
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ jobs:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo apt update
sudo apt --no-install-recommends install -y ninja-build
- name: Package
run: |
script/test package
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ endif()
list(APPEND OT_PRIVATE_DEFINES ${OT_PLATFORM_DEFINES})

if(OT_PLATFORM STREQUAL "posix")
add_subdirectory(src/posix)
if(OT_BUILD_EXECUTABLES)
add_subdirectory(src/posix)
endif()
elseif(NOT OT_PLATFORM MATCHES "none")
add_subdirectory(examples)
endif()
Expand Down
10 changes: 10 additions & 0 deletions etc/cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ if(OT_MTD_NETDIAG)
list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE=1")
endif()

option(OT_PLATFORM_NETIF "enable platform netif support")
if(OT_PLATFORM_NETIF)
list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE=1")
endif()

option(OT_PLATFORM_UDP "enable platform UDP support")
if(OT_PLATFORM_UDP)
list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE=1")
Expand Down Expand Up @@ -224,3 +229,8 @@ option(OT_OTNS "enable OTNS support")
if(OT_OTNS)
list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_OTNS_ENABLE=1")
endif()

# Checks
if(OT_PLATFORM_UDP AND OT_UDP_FORWARD)
message(FATAL_ERROR "OT_PLATFORM_UDP and OT_UDP_FORWARD are exclusive")
endif()
28 changes: 21 additions & 7 deletions script/test
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

set -euo pipefail

readonly OT_BUILD_JOBS=$(getconf _NPROCESSORS_ONLN)
readonly OT_BUILDDIR="$(pwd)/build"
readonly OT_SRCDIR="$(pwd)"
readonly OT_TEST_COMMON_OPTIONS=(
Expand Down Expand Up @@ -317,24 +316,39 @@ EXAMPLES:

do_package() {
local builddir="${OT_BUILDDIR}/cmake/openthread-sim"
local options=(
"-DOT_BORDER_AGENT=ON"
"-DOT_BORDER_ROUTER=ON"
"-DOT_CHILD_SUPERVISION=ON"
"-DOT_COMMISSIONER=ON"
"-DOT_DIAGNOSTIC=ON"
"-DOT_IP6_FRAGM=ON"
"-DOT_JAM_DETECTION=ON"
"-DOT_JOINER=ON"
"-DOT_LOG_LEVEL_DYNAMIC=ON"
"-DOT_MAC_FILTER=ON"
"-DOT_SERVICE=ON"
"-DOT_SLAAC=ON"
)
(mkdir -p "${builddir}" \
&& cd "${builddir}" \
&& cmake "${OT_SRCDIR}" -DOT_PLATFORM="simulation" \
&& make -j"${OT_BUILD_JOBS}" package \
&& cmake -GNinja "${OT_SRCDIR}" -DOT_PLATFORM="simulation" "${options[@]}" \
&& ninja package \
&& ls "${builddir}"/openthread-simulation-*.deb)

builddir="${OT_BUILDDIR}/cmake/openthread-host"
(mkdir -p "${builddir}" \
&& cd "${builddir}" \
&& cmake "${OT_SRCDIR}" -DOT_PLATFORM="posix" \
&& make -j"${OT_BUILD_JOBS}" package \
&& cmake -GNinja "${OT_SRCDIR}" -DOT_PLATFORM="posix" "${options[@]}" \
&& ninja package \
&& ls "${builddir}"/openthread-standalone-*.deb)

builddir="${OT_BUILDDIR}/cmake/openthread-daemon"
(mkdir -p "${builddir}" \
&& cd "${builddir}" \
&& cmake "${OT_SRCDIR}" -DOT_PLATFORM="posix" -DOT_DAEMON=1 -DOT_PLATFORM_NETIF=1 -DOT_PLATFORM_UDP=1 \
&& make -j"${OT_BUILD_JOBS}" package \
&& cmake -GNinja "${OT_SRCDIR}" -DOT_PLATFORM="posix" \
-DOT_DAEMON=1 -DOT_PLATFORM_NETIF=1 -DOT_PLATFORM_UDP=1 "${options[@]}" \
&& ninja package \
&& ls "${builddir}"/openthread-daemon-*.deb)
}

Expand Down

0 comments on commit 32f8274

Please sign in to comment.