Skip to content

Commit

Permalink
Remove the config.h.in and do things through compile defs
Browse files Browse the repository at this point in the history
  • Loading branch information
erlingrj committed Oct 26, 2024
1 parent dedbf16 commit 84e8027
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
cmake-build-debug
cmake-build-release
.idea
include/reactor-uc/config.h
!lfc/bin

16 changes: 8 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ set(BUILD_UNIT_TESTS OFF CACHE BOOL "Build unit tests")
set(TEST_COVERAGE OFF CACHE BOOL "Compute test coverage")
set(ASAN OFF CACHE BOOL "Compile with AddressSanitizer")
set(PLATFORM "POSIX" CACHE STRING "Platform to target")
set(EVENT_QUEUE_SIZE 10 CACHE STRING "Static size of the event queue")
set(REACTION_QUEUE_SIZE 10 CACHE STRING "Static size of the reaction queue")
set(EVENT_QUEUE_SIZE 32 CACHE STRING "Static size of the event queue")
set(REACTION_QUEUE_SIZE 32 CACHE STRING "Static size of the reaction queue")
set(NETWORK_POSIX_TCP OFF CACHE BOOL "Use POSIX TCP NetworkChannel")

# Code coverage setup
Expand Down Expand Up @@ -68,8 +68,13 @@ else ()
message(FATAL_ERROR "No valid platform specified")
endif ()

# Add compile definitions for platform and network channel specifics.
add_compile_definitions("PLATFORM_${PLATFORM}")
# TODO: Improve this here

# Add compile definitions for event and reaction queue sizes.
target_compile_definitions(reactor-uc PRIVATE EVENT_QUEUE_SIZE=${EVENT_QUEUE_SIZE})
target_compile_definitions(reactor-uc PRIVATE REACTION_QUEUE_SIZE=${REACTION_QUEUE_SIZE})

if(NETWORK_POSIX_TCP)
target_compile_definitions(reactor-uc PRIVATE NETWORK_POSIX_TCP)
endif()
Expand All @@ -78,11 +83,6 @@ target_compile_options(reactor-uc PRIVATE -Wall -Wextra -Werror)
add_compile_options (-fdiagnostics-color=always)
target_include_directories(reactor-uc PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include ${CMAKE_CURRENT_LIST_DIR}/external)

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/include/reactor-uc/config.h.in
${CMAKE_CURRENT_SOURCE_DIR}/include/reactor-uc/config.h
)

if(BUILD_UNIT_TESTS)
set(UNITY_DIR ${CMAKE_CURRENT_LIST_DIR}/external/Unity)
include(CTest)
Expand Down
9 changes: 0 additions & 9 deletions include/reactor-uc/config.h.in

This file was deleted.

1 change: 0 additions & 1 deletion include/reactor-uc/queues.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef REACTOR_UC_QUEUES_H
#define REACTOR_UC_QUEUES_H

#include "reactor-uc/config.h"
#include "reactor-uc/error.h"
#include "reactor-uc/event.h"
#include "reactor-uc/reaction.h"
Expand Down
22 changes: 21 additions & 1 deletion src/network_channel.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
#if defined(PLATFORM_POSIX)
#ifdef NETWORK_POSIX_TCP
#include "platform/posix/tcp_ip_channel.c"
#endif
#endif

#elif defined(PLATFORM_ZEPHYR)
#ifdef NETWORK_POSIX_TCP
#include "platform/posix/tcp_ip_channel.c"
#endif

#elif defined(PLATFORM_RIOT)
#ifdef NETWORK_POSIX_TCP
#include "platform/posix/tcp_ip_channel.c"
#endif

#elif defined(PLATFORM_PICO)
#ifdef NETWORK_POSIX_TCP
#error "NETWORK_POSIC_TCP not supported on PICO"
#endif

#else
#error "Platform not supported"
#endif

0 comments on commit 84e8027

Please sign in to comment.