Skip to content

Commit

Permalink
Refactor examples structure
Browse files Browse the repository at this point in the history
  • Loading branch information
erlingrj committed Oct 25, 2024
1 parent 43a4c9c commit de1e232
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 33 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/posix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Posix examples

on:
pull_request:

jobs:
ci:
name: Build zephyr examples
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Build and run Posix examples
run: |
cd examples/posix
./buildAll.sh
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 3.9)
project(reactor-uc LANGUAGES C)

# Command line options for the build
set(BUILD_EXAMPLES OFF CACHE BOOL "Build examples")
set(BUILD_TESTS OFF CACHE BOOL "Build all tests")
set(BUILD_LF_TESTS OFF CACHE BOOL "Build lf tests")
set(BUILD_UNIT_TESTS OFF CACHE BOOL "Build unit tests")
Expand Down Expand Up @@ -52,9 +51,6 @@ if (PLATFORM STREQUAL "POSIX")
set_target_properties(nanopb PROPERTIES C_CLANG_TIDY "") # Disable clang-tidy for this external lib.

target_link_libraries(reactor-uc PRIVATE pthread nanopb)
if(BUILD_EXAMPLES)
add_subdirectory(examples/posix)
endif ()
elseif (PLATFORM STREQUAL "ZEPHYR")
zephyr_library_named(reactor-uc)
zephyr_library_sources(${SOURCES})
Expand Down
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ lib:
cmake --build build
make -C build

# Build examples
# Build federated example
examples:
cmake -Bbuild -DBUILD_EXAMPLES=ON .
cmake --build build
make examples -C build
cmake -Bbuild/posix/federated/ examples/posix/federated
make -C build/posix/federated/

# Build and run the unit tests
unit-test:
Expand Down
25 changes: 0 additions & 25 deletions examples/posix/CMakeLists.txt

This file was deleted.

14 changes: 14 additions & 0 deletions examples/posix/buildAll.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -e

# List of folders
FOLDERS=("hello" "federated")

# Iterate over each folder and execute the command
for dir in "${FOLDERS[@]}"; do
echo "Entering $dir"
pushd $dir
cmake -Bbuild
make -C build
popd
done
12 changes: 12 additions & 0 deletions examples/posix/federated/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.20.0)
project(reactor-uc-posix-hello)

set(PLATFORM "POSIX" CACHE STRING "")
set(NETWORK_POSIX_TCP ON CACHE STRING "")
add_subdirectory(../../../ reactor-uc)

add_executable(sender sender.c)
target_link_libraries(sender PRIVATE reactor-uc)

add_executable(receiver receiver.c)
target_link_libraries(receiver PRIVATE reactor-uc)
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions examples/posix/hello/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.20.0)
project(reactor-uc-posix-hello)

set(PLATFORM "POSIX" CACHE STRING "Platform to target")
add_subdirectory(../../../ reactor-uc)

add_executable(app timer_ex.c)
target_link_libraries(app PRIVATE reactor-uc)
File renamed without changes.

0 comments on commit de1e232

Please sign in to comment.