Skip to content

Commit

Permalink
Refactor examples structure (#102)
Browse files Browse the repository at this point in the history
* Refactor examples structure

* Fix lcov setting

* Try to fix coverage issue
  • Loading branch information
erlingrj authored Oct 26, 2024
1 parent 43a4c9c commit dedbf16
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 35 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
5 changes: 1 addition & 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 All @@ -18,6 +17,7 @@ if(TEST_COVERAGE)
set(CMAKE_BUILD_TYPE "Debug")
include(external/cmake/CodeCoverage.cmake)
append_coverage_compiler_flags()
add_compile_options(-fprofile-update=atomic)
endif()

# Setup AddressSanitizer for chasing memory bugs.
Expand Down Expand Up @@ -52,9 +52,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.
3 changes: 1 addition & 2 deletions test/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ if(TEST_COVERAGE)
NAME coverage
EXECUTABLE ctest
EXCLUDE
"external/Unity/**"
"examples/**"
"external/**"
"test/**"
LCOV_ARGS --rc lcov_branch_coverage=1
GENHTML_ARGS --rc lcov_branch_coverage=1
Expand Down

0 comments on commit dedbf16

Please sign in to comment.