Update from upstream #85

Merged
meierj merged 91 commits from mueller/update-from-upstream into develop 2022-05-16 22:08:28 +02:00
7 changed files with 305 additions and 316 deletions
Showing only changes of commit 970f039e85 - Show all commits

View File

@ -3,13 +3,15 @@ cmake_minimum_required(VERSION 3.13)
set(MSG_PREFIX "fsfw |") set(MSG_PREFIX "fsfw |")
# Add the cmake folder so the FindSphinx module is found # Add the cmake folder so the FindSphinx module is found
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake-modules/bilke") list(APPEND CMAKE_MODULE_PATH
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake-modules/rpavlik") "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake-modules/bilke")
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake-modules/rpavlik")
########################## # ##############################################################################
# Version file handling # # Version file handling #
########################## # ##############################################################################
set(FSFW_VERSION_IF_GIT_FAILS 4) set(FSFW_VERSION_IF_GIT_FAILS 4)
set(FSFW_SUBVERSION_IF_GIT_FAILS 0) set(FSFW_SUBVERSION_IF_GIT_FAILS 0)
@ -18,66 +20,75 @@ set(FSFW_REVISION_IF_GIT_FAILS 0)
set(FSFW_GIT_VER_HANDLING_OK FALSE) set(FSFW_GIT_VER_HANDLING_OK FALSE)
# Version handling # Version handling
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
message(STATUS "${MSG_PREFIX} Determining version information with git") message(STATUS "${MSG_PREFIX} Determining version information with git")
include(FsfwHelpers) include(FsfwHelpers)
determine_version_with_git("--exclude" "docker_*") determine_version_with_git("--exclude" "docker_*")
if(GIT_INFO) if(GIT_INFO)
set(FSFW_GIT_INFO ${GIT_INFO} CACHE STRING "Version information retrieved with git describe") set(FSFW_GIT_INFO
list(GET FSFW_GIT_INFO 1 FSFW_VERSION) ${GIT_INFO}
list(GET FSFW_GIT_INFO 2 FSFW_SUBVERSION) CACHE STRING "Version information retrieved with git describe")
list(GET FSFW_GIT_INFO 3 FSFW_REVISION) list(GET FSFW_GIT_INFO 1 FSFW_VERSION)
list(GET FSFW_GIT_INFO 4 FSFW_VCS_INFO) list(GET FSFW_GIT_INFO 2 FSFW_SUBVERSION)
if(NOT FSFW_VERSION) list(GET FSFW_GIT_INFO 3 FSFW_REVISION)
set(FSFW_VERSION ${FSFW_VERSION_IF_GIT_FAILS}) list(GET FSFW_GIT_INFO 4 FSFW_VCS_INFO)
endif() if(NOT FSFW_VERSION)
if(NOT FSFW_SUBVERSION) set(FSFW_VERSION ${FSFW_VERSION_IF_GIT_FAILS})
set(FSFW_SUBVERSION ${FSFW_SUBVERSION_IF_GIT_FAILS}) endif()
endif() if(NOT FSFW_SUBVERSION)
if(NOT FSFW_REVISION) set(FSFW_SUBVERSION ${FSFW_SUBVERSION_IF_GIT_FAILS})
set(FSFW_REVISION ${FSFW_REVISION_IF_GIT_FAILS}) endif()
endif() if(NOT FSFW_REVISION)
set(FSFW_GIT_VER_HANDLING_OK TRUE) set(FSFW_REVISION ${FSFW_REVISION_IF_GIT_FAILS})
else() endif()
set(FSFW_GIT_VER_HANDLING_OK FALSE) set(FSFW_GIT_VER_HANDLING_OK TRUE)
endif() else()
set(FSFW_GIT_VER_HANDLING_OK FALSE)
endif()
endif() endif()
if(NOT FSFW_GIT_VER_HANDLING_OK) if(NOT FSFW_GIT_VER_HANDLING_OK)
set(FSFW_VERSION ${FSFW_VERSION_IF_GIT_FAILS}) set(FSFW_VERSION ${FSFW_VERSION_IF_GIT_FAILS})
set(FSFW_SUBVERSION ${FSFW_SUBVERSION_IF_GIT_FAILS}) set(FSFW_SUBVERSION ${FSFW_SUBVERSION_IF_GIT_FAILS})
set(FSFW_REVISION ${FSFW_REVISION_IF_GIT_FAILS}) set(FSFW_REVISION ${FSFW_REVISION_IF_GIT_FAILS})
endif() endif()
set(LIB_FSFW_NAME fsfw) set(LIB_FSFW_NAME fsfw)
project(${LIB_FSFW_NAME} VERSION ${FSFW_VERSION}.${FSFW_SUBVERSION}.${FSFW_REVISION}) project(${LIB_FSFW_NAME}
VERSION ${FSFW_VERSION}.${FSFW_SUBVERSION}.${FSFW_REVISION})
if(NOT CMAKE_CXX_STANDARD) if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_CXX_STANDARD_REQUIRED True)
elseif(${CMAKE_CXX_STANDARD} LESS 17) elseif(${CMAKE_CXX_STANDARD} LESS 17)
message(FATAL_ERROR "${MSG_PREFIX} Compiling the FSFW requires a minimum of C++17 support") message(
FATAL_ERROR
"${MSG_PREFIX} Compiling the FSFW requires a minimum of C++17 support")
endif() endif()
set(FSFW_SOURCES_DIR "${CMAKE_SOURCE_DIR}/src/fsfw") set(FSFW_SOURCES_DIR "${CMAKE_SOURCE_DIR}/src/fsfw")
set(FSFW_ETL_LIB_NAME etl) set(FSFW_ETL_LIB_NAME etl)
set(FSFW_ETL_LIB_MAJOR_VERSION 20 CACHE STRING set(FSFW_ETL_LIB_MAJOR_VERSION
"ETL library major version requirement" 20
) CACHE STRING "ETL library major version requirement")
set(FSFW_ETL_LIB_VERSION ${FSFW_ETL_LIB_MAJOR_VERSION}.27.3 CACHE STRING set(FSFW_ETL_LIB_VERSION
"ETL library exact version requirement" ${FSFW_ETL_LIB_MAJOR_VERSION}.27.3
) CACHE STRING "ETL library exact version requirement")
set(FSFW_ETL_LINK_TARGET etl::etl) set(FSFW_ETL_LINK_TARGET etl::etl)
set(FSFW_CATCH2_LIB_MAJOR_VERSION 3 CACHE STRING set(FSFW_CATCH2_LIB_MAJOR_VERSION
"Catch2 library major version requirement" 3
) CACHE STRING "Catch2 library major version requirement")
set(FSFW_CATCH2_LIB_VERSION v${FSFW_CATCH2_LIB_MAJOR_VERSION}.0.0-preview5 CACHE STRING set(FSFW_CATCH2_LIB_VERSION
"Catch2 library exact version requirement" v${FSFW_CATCH2_LIB_MAJOR_VERSION}.0.0-preview5
) CACHE STRING "Catch2 library exact version requirement")
# Keep this off by default for now. See PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/616 # Keep this off by default for now. See PR:
# for information which keeping this on by default is problematic # https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/616 for information which
option(FSFW_ENABLE_IPO "Enable interprocedural optimization or link-time optimization if available" OFF) # keeping this on by default is problematic
option(
FSFW_ENABLE_IPO
"Enable interprocedural optimization or link-time optimization if available"
OFF)
if(FSFW_ENABLE_IPO) if(FSFW_ENABLE_IPO)
include(CheckIPOSupported) include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_ERROR) check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_ERROR)
@ -87,13 +98,13 @@ if(FSFW_ENABLE_IPO)
endif() endif()
option(FSFW_GENERATE_SECTIONS option(FSFW_GENERATE_SECTIONS
"Generate function and data sections. Required to remove unused code" ON "Generate function and data sections. Required to remove unused code" ON)
)
if(FSFW_GENERATE_SECTIONS) if(FSFW_GENERATE_SECTIONS)
option(FSFW_REMOVE_UNUSED_CODE "Remove unused code" ON) option(FSFW_REMOVE_UNUSED_CODE "Remove unused code" ON)
endif() endif()
option(FSFW_BUILD_UNITTESTS "Build unittest binary in addition to static library" OFF) option(FSFW_BUILD_UNITTESTS
"Build unittest binary in addition to static library" OFF)
option(FSFW_BUILD_DOCS "Build documentation with Sphinx and Doxygen" OFF) option(FSFW_BUILD_DOCS "Build documentation with Sphinx and Doxygen" OFF)
if(FSFW_BUILD_UNITTESTS) if(FSFW_BUILD_UNITTESTS)
option(FSFW_TESTS_GEN_COV "Generate coverage data for unittests" ON) option(FSFW_TESTS_GEN_COV "Generate coverage data for unittests" ON)
@ -117,52 +128,58 @@ option(FSFW_ADD_TMSTORAGE "Compile with tm storage components" OFF)
# Contrib sources # Contrib sources
option(FSFW_ADD_SGP4_PROPAGATOR "Add SGP4 propagator code" OFF) option(FSFW_ADD_SGP4_PROPAGATOR "Add SGP4 propagator code" OFF)
set(FSFW_TEST_TGT fsfw-tests) set(FSFW_TEST_TGT fsfw-tests)
set(FSFW_DUMMY_TGT fsfw-dummy) set(FSFW_DUMMY_TGT fsfw-dummy)
add_library(${LIB_FSFW_NAME}) add_library(${LIB_FSFW_NAME})
if(IPO_SUPPORTED AND FSFW_ENABLE_IPO) if(IPO_SUPPORTED AND FSFW_ENABLE_IPO)
set_property(TARGET ${LIB_FSFW_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) set_property(TARGET ${LIB_FSFW_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION
TRUE)
endif() endif()
if(FSFW_BUILD_UNITTESTS) if(FSFW_BUILD_UNITTESTS)
message(STATUS "${MSG_PREFIX} Building the FSFW unittests in addition to the static library") message(
# Check whether the user has already installed Catch2 first STATUS
find_package(Catch2 ${FSFW_CATCH2_LIB_MAJOR_VERSION}) "${MSG_PREFIX} Building the FSFW unittests in addition to the static library"
# Not installed, so use FetchContent to download and provide Catch2 )
if(NOT Catch2_FOUND) # Check whether the user has already installed Catch2 first
message(STATUS "${MSG_PREFIX} Catch2 installation not found. Downloading Catch2 library with FetchContent") find_package(Catch2 ${FSFW_CATCH2_LIB_MAJOR_VERSION})
include(FetchContent) # Not installed, so use FetchContent to download and provide Catch2
if(NOT Catch2_FOUND)
message(
STATUS
"${MSG_PREFIX} Catch2 installation not found. Downloading Catch2 library with FetchContent"
)
include(FetchContent)
FetchContent_Declare( FetchContent_Declare(
Catch2 Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG ${FSFW_CATCH2_LIB_VERSION} GIT_TAG ${FSFW_CATCH2_LIB_VERSION})
)
list(APPEND FSFW_FETCH_CONTENT_TARGETS Catch2) list(APPEND FSFW_FETCH_CONTENT_TARGETS Catch2)
endif() endif()
set(FSFW_CONFIG_PATH tests/src/fsfw_tests/unit/testcfg) set(FSFW_CONFIG_PATH tests/src/fsfw_tests/unit/testcfg)
configure_file(tests/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in FSFWConfig.h) configure_file(tests/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in FSFWConfig.h)
configure_file(tests/src/fsfw_tests/unit/testcfg/TestsConfig.h.in tests/TestsConfig.h) configure_file(tests/src/fsfw_tests/unit/testcfg/TestsConfig.h.in
tests/TestsConfig.h)
project(${FSFW_TEST_TGT} CXX C) project(${FSFW_TEST_TGT} CXX C)
add_executable(${FSFW_TEST_TGT}) add_executable(${FSFW_TEST_TGT})
if(IPO_SUPPORTED AND FSFW_ENABLE_IPO) if(IPO_SUPPORTED AND FSFW_ENABLE_IPO)
set_property(TARGET ${FSFW_TEST_TGT} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) set_property(TARGET ${FSFW_TEST_TGT} PROPERTY INTERPROCEDURAL_OPTIMIZATION
endif() TRUE)
endif()
if(FSFW_TESTS_GEN_COV) if(FSFW_TESTS_GEN_COV)
message(STATUS "${MSG_PREFIX} Generating coverage data for the library") message(STATUS "${MSG_PREFIX} Generating coverage data for the library")
message(STATUS "${MSG_PREFIX} Targets linking against ${LIB_FSFW_NAME} " message(STATUS "${MSG_PREFIX} Targets linking against ${LIB_FSFW_NAME} "
"will be compiled with coverage data as well" "will be compiled with coverage data as well")
) set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_BUILD_TYPE "Debug") include(CodeCoverage)
include(CodeCoverage) endif()
endif()
endif() endif()
message(STATUS "${MSG_PREFIX} Finding and/or providing ETL library") message(STATUS "${MSG_PREFIX} Finding and/or providing ETL library")
@ -171,34 +188,33 @@ message(STATUS "${MSG_PREFIX} Finding and/or providing ETL library")
find_package(${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_MAJOR_VERSION} QUIET) find_package(${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_MAJOR_VERSION} QUIET)
# Not installed, so use FetchContent to download and provide etl # Not installed, so use FetchContent to download and provide etl
if(NOT ${FSFW_ETL_LIB_NAME}_FOUND) if(NOT ${FSFW_ETL_LIB_NAME}_FOUND)
message(STATUS message(
"No ETL installation was found with find_package. Installing and providing " STATUS
"etl with FindPackage" "No ETL installation was found with find_package. Installing and providing "
) "etl with FindPackage")
include(FetchContent) include(FetchContent)
FetchContent_Declare( FetchContent_Declare(
${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_NAME}
GIT_REPOSITORY https://github.com/ETLCPP/etl GIT_REPOSITORY https://github.com/ETLCPP/etl
GIT_TAG ${FSFW_ETL_LIB_VERSION} GIT_TAG ${FSFW_ETL_LIB_VERSION})
)
list(APPEND FSFW_FETCH_CONTENT_TARGETS ${FSFW_ETL_LIB_NAME}) list(APPEND FSFW_FETCH_CONTENT_TARGETS ${FSFW_ETL_LIB_NAME})
endif() endif()
# The documentation for FetchContent recommends declaring all the dependencies # The documentation for FetchContent recommends declaring all the dependencies
# before making them available. We make all declared dependency available here # before making them available. We make all declared dependency available here
# after their declaration # after their declaration
if(FSFW_FETCH_CONTENT_TARGETS) if(FSFW_FETCH_CONTENT_TARGETS)
FetchContent_MakeAvailable(${FSFW_FETCH_CONTENT_TARGETS}) FetchContent_MakeAvailable(${FSFW_FETCH_CONTENT_TARGETS})
if(TARGET ${FSFW_ETL_LIB_NAME}) if(TARGET ${FSFW_ETL_LIB_NAME})
add_library(${FSFW_ETL_LINK_TARGET} ALIAS ${FSFW_ETL_LIB_NAME}) add_library(${FSFW_ETL_LINK_TARGET} ALIAS ${FSFW_ETL_LIB_NAME})
endif() endif()
if(TARGET Catch2) if(TARGET Catch2)
# Fixes regression -preview4, to be confirmed in later releases # Fixes regression -preview4, to be confirmed in later releases Related
# Related GitHub issue: https://github.com/catchorg/Catch2/issues/2417 # GitHub issue: https://github.com/catchorg/Catch2/issues/2417
set_target_properties(Catch2 PROPERTIES DEBUG_POSTFIX "") set_target_properties(Catch2 PROPERTIES DEBUG_POSTFIX "")
endif() endif()
endif() endif()
set(FSFW_CORE_INC_PATH "inc") set(FSFW_CORE_INC_PATH "inc")
@ -206,275 +222,242 @@ set(FSFW_CORE_INC_PATH "inc")
set_property(CACHE FSFW_OSAL PROPERTY STRINGS host linux rtems freertos) set_property(CACHE FSFW_OSAL PROPERTY STRINGS host linux rtems freertos)
# For configure files # For configure files
target_include_directories(${LIB_FSFW_NAME} PRIVATE target_include_directories(${LIB_FSFW_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
${CMAKE_CURRENT_BINARY_DIR} target_include_directories(${LIB_FSFW_NAME}
) INTERFACE ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(${LIB_FSFW_NAME} INTERFACE
${CMAKE_CURRENT_BINARY_DIR}
)
# Backwards comptability # Backwards comptability
if(OS_FSFW AND NOT FSFW_OSAL) if(OS_FSFW AND NOT FSFW_OSAL)
message(WARNING "${MSG_PREFIX} Please pass the FSFW OSAL as FSFW_OSAL instead of OS_FSFW") message(
set(FSFW_OSAL OS_FSFW) WARNING
"${MSG_PREFIX} Please pass the FSFW OSAL as FSFW_OSAL instead of OS_FSFW")
set(FSFW_OSAL OS_FSFW)
endif() endif()
if(NOT FSFW_OSAL) if(NOT FSFW_OSAL)
message(STATUS "${MSG_PREFIX} No OS for FSFW via FSFW_OSAL set. Assuming host OS") message(STATUS "No OS for FSFW via FSFW_OSAL set. Assuming host OS")
# Assume host OS and autodetermine from OS_FSFW # Assume host OS and autodetermine from OS_FSFW
if(UNIX) if(UNIX)
set(FSFW_OSAL "linux" set(FSFW_OSAL
CACHE STRING "linux"
"OS abstraction layer used in the FSFW" CACHE STRING "OS abstraction layer used in the FSFW")
) elseif(WIN32)
elseif(WIN32) set(FSFW_OSAL
set(FSFW_OSAL "host" "host"
CACHE STRING "OS abstraction layer used in the FSFW" CACHE STRING "OS abstraction layer used in the FSFW")
) endif()
endif()
endif() endif()
set(FSFW_OSAL_DEFINITION FSFW_OSAL_HOST) set(FSFW_OSAL_DEFINITION FSFW_OSAL_HOST)
if(FSFW_OSAL MATCHES host) if(FSFW_OSAL MATCHES host)
set(FSFW_OS_NAME "Host") set(FSFW_OS_NAME "Host")
set(FSFW_OSAL_HOST ON) set(FSFW_OSAL_HOST ON)
elseif(FSFW_OSAL MATCHES linux) elseif(FSFW_OSAL MATCHES linux)
set(FSFW_OS_NAME "Linux") set(FSFW_OS_NAME "Linux")
set(FSFW_OSAL_LINUX ON) set(FSFW_OSAL_LINUX ON)
elseif(FSFW_OSAL MATCHES freertos) elseif(FSFW_OSAL MATCHES freertos)
set(FSFW_OS_NAME "FreeRTOS") set(FSFW_OS_NAME "FreeRTOS")
set(FSFW_OSAL_FREERTOS ON) set(FSFW_OSAL_FREERTOS ON)
target_link_libraries(${LIB_FSFW_NAME} PRIVATE target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${LIB_OS_NAME})
${LIB_OS_NAME}
)
elseif(FSFW_OSAL STREQUAL rtems) elseif(FSFW_OSAL STREQUAL rtems)
set(FSFW_OS_NAME "RTEMS") set(FSFW_OS_NAME "RTEMS")
set(FSFW_OSAL_RTEMS ON) set(FSFW_OSAL_RTEMS ON)
else() else()
message(WARNING message(
"${MSG_PREFIX} Invalid operating system for FSFW specified! Setting to host.." WARNING
) "${MSG_PREFIX} Invalid operating system for FSFW specified! Setting to host.."
set(FSFW_OS_NAME "Host") )
set(OS_FSFW "host") set(FSFW_OS_NAME "Host")
set(OS_FSFW "host")
endif() endif()
configure_file(src/fsfw/FSFW.h.in fsfw/FSFW.h) configure_file(src/fsfw/FSFW.h.in fsfw/FSFW.h)
configure_file(src/fsfw/FSFWVersion.h.in fsfw/FSFWVersion.h) configure_file(src/fsfw/FSFWVersion.h.in fsfw/FSFWVersion.h)
message(STATUS "${MSG_PREFIX} Compiling FSFW for the ${FSFW_OS_NAME} operating system") message(
STATUS "${MSG_PREFIX} Compiling FSFW for the ${FSFW_OS_NAME} operating system"
)
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(tests) add_subdirectory(tests)
if(FSFW_ADD_HAL) if(FSFW_ADD_HAL)
add_subdirectory(hal) add_subdirectory(hal)
endif() endif()
add_subdirectory(contrib) add_subdirectory(contrib)
if(FSFW_BUILD_DOCS) if(FSFW_BUILD_DOCS)
add_subdirectory(docs) add_subdirectory(docs)
endif() endif()
if(FSFW_BUILD_UNITTESTS) if(FSFW_BUILD_UNITTESTS)
if(FSFW_TESTS_GEN_COV) if(FSFW_TESTS_GEN_COV)
if(CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_COMPILER_IS_GNUCXX)
include(CodeCoverage) include(CodeCoverage)
# Remove quotes. # Remove quotes.
separate_arguments(COVERAGE_COMPILER_FLAGS separate_arguments(COVERAGE_COMPILER_FLAGS NATIVE_COMMAND
NATIVE_COMMAND "${COVERAGE_COMPILER_FLAGS}" "${COVERAGE_COMPILER_FLAGS}")
)
# Add compile options manually, we don't want coverage for Catch2 # Add compile options manually, we don't want coverage for Catch2
target_compile_options(${FSFW_TEST_TGT} PRIVATE target_compile_options(${FSFW_TEST_TGT}
"${COVERAGE_COMPILER_FLAGS}" PRIVATE "${COVERAGE_COMPILER_FLAGS}")
) target_compile_options(${LIB_FSFW_NAME}
target_compile_options(${LIB_FSFW_NAME} PRIVATE PRIVATE "${COVERAGE_COMPILER_FLAGS}")
"${COVERAGE_COMPILER_FLAGS}"
)
# Exclude directories here # Exclude directories here
if(WIN32) if(WIN32)
set(GCOVR_ADDITIONAL_ARGS set(GCOVR_ADDITIONAL_ARGS "--exclude-throw-branches"
"--exclude-throw-branches" "--exclude-unreachable-branches")
"--exclude-unreachable-branches" set(COVERAGE_EXCLUDES "/c/msys64/mingw64/*" "*/fsfw_hal/*")
) elseif(UNIX)
set(COVERAGE_EXCLUDES set(COVERAGE_EXCLUDES
"/c/msys64/mingw64/*" "*/fsfw_hal/*" "/usr/include/*"
) "/usr/bin/*"
elseif(UNIX) "Catch2/*"
set(COVERAGE_EXCLUDES "/usr/local/include/*"
"/usr/include/*" "/usr/bin/*" "Catch2/*" "*/fsfw_tests/*"
"/usr/local/include/*" "*/fsfw_tests/*" "*/catch2-src/*"
"*/catch2-src/*" "*/fsfw_hal/*" "*/fsfw_hal/*")
) endif()
endif()
target_link_options(${FSFW_TEST_TGT} PRIVATE target_link_options(${FSFW_TEST_TGT} PRIVATE -fprofile-arcs
-fprofile-arcs -ftest-coverage)
-ftest-coverage target_link_options(${LIB_FSFW_NAME} PRIVATE -fprofile-arcs
) -ftest-coverage)
target_link_options(${LIB_FSFW_NAME} PRIVATE # Need to specify this as an interface, otherwise there will the compile
-fprofile-arcs # issues
-ftest-coverage target_link_options(${LIB_FSFW_NAME} INTERFACE -fprofile-arcs
) -ftest-coverage)
# Need to specify this as an interface, otherwise there will the compile issues
target_link_options(${LIB_FSFW_NAME} INTERFACE
-fprofile-arcs
-ftest-coverage
)
if(WIN32) if(WIN32)
setup_target_for_coverage_gcovr_html( setup_target_for_coverage_gcovr_html(
NAME ${FSFW_TEST_TGT}_coverage NAME ${FSFW_TEST_TGT}_coverage EXECUTABLE ${FSFW_TEST_TGT}
EXECUTABLE ${FSFW_TEST_TGT} DEPENDENCIES ${FSFW_TEST_TGT})
DEPENDENCIES ${FSFW_TEST_TGT} else()
) setup_target_for_coverage_lcov(
else() NAME ${FSFW_TEST_TGT}_coverage EXECUTABLE ${FSFW_TEST_TGT}
setup_target_for_coverage_lcov( DEPENDENCIES ${FSFW_TEST_TGT})
NAME ${FSFW_TEST_TGT}_coverage endif()
EXECUTABLE ${FSFW_TEST_TGT}
DEPENDENCIES ${FSFW_TEST_TGT}
)
endif()
endif()
endif() endif()
target_link_libraries(${FSFW_TEST_TGT} PRIVATE Catch2::Catch2 ${LIB_FSFW_NAME}) endif()
target_link_libraries(${FSFW_TEST_TGT} PRIVATE Catch2::Catch2
${LIB_FSFW_NAME})
endif() endif()
# The project CMakeLists file has to set the FSFW_CONFIG_PATH and add it. # The project CMakeLists file has to set the FSFW_CONFIG_PATH and add it. If
# If this is not given, we include the default configuration and emit a warning. # this is not given, we include the default configuration and emit a warning.
if(NOT FSFW_CONFIG_PATH) if(NOT FSFW_CONFIG_PATH)
set(DEF_CONF_PATH misc/defaultcfg/fsfwconfig) set(DEF_CONF_PATH misc/defaultcfg/fsfwconfig)
if(NOT FSFW_BUILD_DOCS) if(NOT FSFW_BUILD_DOCS)
message(WARNING "${MSG_PREFIX} Flight Software Framework configuration path not set") message(
message(WARNING "${MSG_PREFIX} Setting default configuration from ${DEF_CONF_PATH} ..") WARNING
endif() "${MSG_PREFIX} Flight Software Framework configuration path not set")
add_subdirectory(${DEF_CONF_PATH}) message(
set(FSFW_CONFIG_PATH ${DEF_CONF_PATH}) WARNING
"${MSG_PREFIX} Setting default configuration from ${DEF_CONF_PATH} ..")
endif()
add_subdirectory(${DEF_CONF_PATH})
set(FSFW_CONFIG_PATH ${DEF_CONF_PATH})
endif() endif()
# FSFW might be part of a possibly complicated folder structure, so we # FSFW might be part of a possibly complicated folder structure, so we extract
# extract the absolute path of the fsfwconfig folder. # the absolute path of the fsfwconfig folder.
if(IS_ABSOLUTE ${FSFW_CONFIG_PATH}) if(IS_ABSOLUTE ${FSFW_CONFIG_PATH})
set(FSFW_CONFIG_PATH_ABSOLUTE ${FSFW_CONFIG_PATH}) set(FSFW_CONFIG_PATH_ABSOLUTE ${FSFW_CONFIG_PATH})
else() else()
get_filename_component(FSFW_CONFIG_PATH_ABSOLUTE get_filename_component(FSFW_CONFIG_PATH_ABSOLUTE ${FSFW_CONFIG_PATH} REALPATH
${FSFW_CONFIG_PATH} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR} BASE_DIR ${CMAKE_SOURCE_DIR})
)
endif() endif()
foreach(INCLUDE_PATH ${FSFW_ADDITIONAL_INC_PATHS}) foreach(INCLUDE_PATH ${FSFW_ADDITIONAL_INC_PATHS})
if(IS_ABSOLUTE ${INCLUDE_PATH}) if(IS_ABSOLUTE ${INCLUDE_PATH})
set(CURR_ABS_INC_PATH "${INCLUDE_PATH}") set(CURR_ABS_INC_PATH "${INCLUDE_PATH}")
else() else()
get_filename_component(CURR_ABS_INC_PATH get_filename_component(CURR_ABS_INC_PATH ${INCLUDE_PATH} REALPATH BASE_DIR
${INCLUDE_PATH} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR}) ${CMAKE_SOURCE_DIR})
endif() endif()
if(CMAKE_VERBOSE) if(CMAKE_VERBOSE)
message(STATUS "FSFW include path: ${CURR_ABS_INC_PATH}") message(STATUS "FSFW include path: ${CURR_ABS_INC_PATH}")
endif() endif()
list(APPEND FSFW_ADD_INC_PATHS_ABS ${CURR_ABS_INC_PATH}) list(APPEND FSFW_ADD_INC_PATHS_ABS ${CURR_ABS_INC_PATH})
endforeach() endforeach()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(NOT DEFINED FSFW_WARNING_FLAGS) if(NOT DEFINED FSFW_WARNING_FLAGS)
set(FSFW_WARNING_FLAGS set(FSFW_WARNING_FLAGS
-Wall -Wall
-Wextra -Wextra
-Wimplicit-fallthrough=1 -Wimplicit-fallthrough=1
-Wno-unused-parameter -Wno-unused-parameter
-Wno-psabi -Wno-psabi
-Wduplicated-cond # check for duplicate conditions -Wduplicated-cond # check for duplicate conditions
-Wduplicated-branches # check for duplicate branches -Wduplicated-branches # check for duplicate branches
-Wlogical-op # Search for bitwise operations instead of logical -Wlogical-op # Search for bitwise operations instead of logical
-Wnull-dereference # Search for NULL dereference -Wnull-dereference # Search for NULL dereference
-Wundef # Warn if undefind marcos are used -Wundef # Warn if undefind marcos are used
-Wformat=2 # Format string problem detection -Wformat=2 # Format string problem detection
-Wformat-overflow=2 # Formatting issues in printf -Wformat-overflow=2 # Formatting issues in printf
-Wformat-truncation=2 # Formatting issues in printf -Wformat-truncation=2 # Formatting issues in printf
-Wformat-security # Search for dangerous printf operations -Wformat-security # Search for dangerous printf operations
-Wstrict-overflow=3 # Warn if integer overflows might happen -Wstrict-overflow=3 # Warn if integer overflows might happen
-Warray-bounds=2 # Some array bounds violations will be found -Warray-bounds=2 # Some array bounds violations will be found
-Wshift-overflow=2 # Search for bit left shift overflows (<c++14) -Wshift-overflow=2 # Search for bit left shift overflows (<c++14)
-Wcast-qual # Warn if the constness is cast away -Wcast-qual # Warn if the constness is cast away
-Wstringop-overflow=4 -Wstringop-overflow=4
# -Wstack-protector # Emits a few false positives for low level access # -Wstack-protector # Emits a few false positives for low level access
# -Wconversion # Creates many false positives # -Wconversion # Creates many false positives -Warith-conversion # Use
# -Warith-conversion # Use with Wconversion to find more implicit conversions # with Wconversion to find more implicit conversions -fanalyzer # Should
# -fanalyzer # Should be used to look through problems # be used to look through problems
) )
endif() endif()
if(FSFW_GENERATE_SECTIONS) if(FSFW_GENERATE_SECTIONS)
target_compile_options(${LIB_FSFW_NAME} PRIVATE target_compile_options(${LIB_FSFW_NAME} PRIVATE "-ffunction-sections"
"-ffunction-sections" "-fdata-sections")
"-fdata-sections" endif()
)
endif()
if(FSFW_REMOVE_UNUSED_CODE) if(FSFW_REMOVE_UNUSED_CODE)
target_link_options(${LIB_FSFW_NAME} PRIVATE target_link_options(${LIB_FSFW_NAME} PRIVATE "Wl,--gc-sections")
"Wl,--gc-sections" endif()
)
endif()
if(FSFW_WARNING_SHADOW_LOCAL_GCC) if(FSFW_WARNING_SHADOW_LOCAL_GCC)
list(APPEND WARNING_FLAGS "-Wshadow=local") list(APPEND WARNING_FLAGS "-Wshadow=local")
endif() endif()
endif() endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(COMPILER_FLAGS "/permissive-") set(COMPILER_FLAGS "/permissive-")
endif() endif()
# Required include paths to compile the FSFW # Required include paths to compile the FSFW
target_include_directories(${LIB_FSFW_NAME} INTERFACE target_include_directories(
${CMAKE_SOURCE_DIR} ${LIB_FSFW_NAME} INTERFACE ${CMAKE_SOURCE_DIR} ${FSFW_CONFIG_PATH_ABSOLUTE}
${FSFW_CONFIG_PATH_ABSOLUTE} ${FSFW_CORE_INC_PATH} ${FSFW_ADD_INC_PATHS_ABS})
${FSFW_CORE_INC_PATH}
${FSFW_ADD_INC_PATHS_ABS}
)
# Includes path required to compile FSFW itself as well # Includes path required to compile FSFW itself as well We assume that the
# We assume that the fsfwconfig folder uses include relative to the project # fsfwconfig folder uses include relative to the project root here!
# root here! target_include_directories(
target_include_directories(${LIB_FSFW_NAME} PRIVATE ${LIB_FSFW_NAME} PRIVATE ${CMAKE_SOURCE_DIR} ${FSFW_CONFIG_PATH_ABSOLUTE}
${CMAKE_SOURCE_DIR} ${FSFW_CORE_INC_PATH} ${FSFW_ADD_INC_PATHS_ABS})
${FSFW_CONFIG_PATH_ABSOLUTE}
${FSFW_CORE_INC_PATH}
${FSFW_ADD_INC_PATHS_ABS}
)
target_compile_options(${LIB_FSFW_NAME} PRIVATE target_compile_options(${LIB_FSFW_NAME} PRIVATE ${FSFW_WARNING_FLAGS}
${FSFW_WARNING_FLAGS} ${COMPILER_FLAGS})
${COMPILER_FLAGS}
)
target_link_libraries(${LIB_FSFW_NAME} PRIVATE target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${FSFW_ETL_LINK_TARGET}
${FSFW_ETL_LINK_TARGET} ${FSFW_ADDITIONAL_LINK_LIBS})
${FSFW_ADDITIONAL_LINK_LIBS}
)
string(CONCAT POST_BUILD_COMMENT string(
CONCAT
POST_BUILD_COMMENT
"######################################################################\n" "######################################################################\n"
"Built FSFW v${FSFW_VERSION}.${FSFW_SUBVERSION}.${FSFW_REVISION}, " "Built FSFW v${FSFW_VERSION}.${FSFW_SUBVERSION}.${FSFW_REVISION}, "
"Target OSAL: ${FSFW_OS_NAME}\n" "Target OSAL: ${FSFW_OS_NAME}\n"
"######################################################################\n" "######################################################################\n")
)
add_custom_command( add_custom_command(
TARGET ${LIB_FSFW_NAME} TARGET ${LIB_FSFW_NAME}
POST_BUILD POST_BUILD
COMMENT ${POST_BUILD_COMMENT} COMMENT ${POST_BUILD_COMMENT})
)
add_custom_command(
TARGET ${LIB_FSFW_NAME}
PRE_BUILD
COMMAND touch ${FSFW_SOURCES_DIR}/FSFWVersion.h.in
COMMENT "${MSG_PREFIX} Updating FSFWVersion.h"
)

View File

@ -3,6 +3,12 @@ if [[ ! -f README.md ]]; then
cd .. cd ..
fi fi
cmake_fmt="cmake-format"
if command -v ${cmake_fmt} &> /dev/null; then
cmake_fmt_cmd="${cmake_fmt} -i CMakeLists.txt"
eval ${cmake_fmt_cmd}
fi
find ./src -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i find ./src -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i
find ./hal -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i find ./hal -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i
find ./tests -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i find ./tests -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i

View File

@ -12,6 +12,7 @@ template <typename T, size_t MAX_SIZE, typename count_t = uint8_t>
class FixedArrayList : public ArrayList<T, count_t> { class FixedArrayList : public ArrayList<T, count_t> {
static_assert(MAX_SIZE <= std::numeric_limits<count_t>::max(), static_assert(MAX_SIZE <= std::numeric_limits<count_t>::max(),
"count_t is not large enough to hold MAX_SIZE"); "count_t is not large enough to hold MAX_SIZE");
private: private:
T data[MAX_SIZE]; T data[MAX_SIZE];

View File

@ -161,7 +161,7 @@ void TcpTmTcServer::handleServerOperation(socket_t& connSocket) {
while (true) { while (true) {
ssize_t retval = recv(connSocket, reinterpret_cast<char*>(receptionBuffer.data()), ssize_t retval = recv(connSocket, reinterpret_cast<char*>(receptionBuffer.data()),
receptionBuffer.capacity(), tcpConfig.tcpFlags); receptionBuffer.capacity(), tcpConfig.tcpFlags);
if (retval == 0) { if (retval == 0) {
size_t availableReadData = ringBuffer.getAvailableReadData(); size_t availableReadData = ringBuffer.getAvailableReadData();
if (availableReadData > lastRingBufferSize) { if (availableReadData > lastRingBufferSize) {
@ -285,7 +285,7 @@ ReturnValue_t TcpTmTcServer::handleTmSending(socket_t connSocket, bool& tmSent)
arrayprinter::print(storeAccessor.data(), storeAccessor.size()); arrayprinter::print(storeAccessor.data(), storeAccessor.size());
} }
ssize_t retval = send(connSocket, reinterpret_cast<const char*>(storeAccessor.data()), ssize_t retval = send(connSocket, reinterpret_cast<const char*>(storeAccessor.data()),
storeAccessor.size(), tcpConfig.tcpTmFlags); storeAccessor.size(), tcpConfig.tcpTmFlags);
if (retval == static_cast<int>(storeAccessor.size())) { if (retval == static_cast<int>(storeAccessor.size())) {
// Packet sent, clear FIFO entry // Packet sent, clear FIFO entry
tmtcBridge->tmFifo->pop(); tmtcBridge->tmFifo->pop();
@ -340,7 +340,7 @@ ReturnValue_t TcpTmTcServer::handleTcRingBufferData(size_t availableReadData) {
size_t foundSize = 0; size_t foundSize = 0;
size_t readLen = 0; size_t readLen = 0;
while (readLen < readAmount) { while (readLen < readAmount) {
if(spacePacketParser == nullptr) { if (spacePacketParser == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
result = result =

View File

@ -97,7 +97,8 @@ ReturnValue_t CService201HealthCommanding::handleReply(const CommandMessage *rep
} }
// Not used for now, health state already reported by event // Not used for now, health state already reported by event
[[maybe_unused]] ReturnValue_t CService201HealthCommanding::prepareHealthSetReply(const CommandMessage *reply) { [[maybe_unused]] ReturnValue_t CService201HealthCommanding::prepareHealthSetReply(
const CommandMessage *reply) {
auto health = static_cast<uint8_t>(HealthMessage::getHealth(reply)); auto health = static_cast<uint8_t>(HealthMessage::getHealth(reply));
auto oldHealth = static_cast<uint8_t>(HealthMessage::getOldHealth(reply)); auto oldHealth = static_cast<uint8_t>(HealthMessage::getOldHealth(reply));
HealthSetReply healthSetReply(health, oldHealth); HealthSetReply healthSetReply(health, oldHealth);

View File

@ -39,7 +39,7 @@ class CService201HealthCommanding : public CommandingServiceBase {
private: private:
static ReturnValue_t checkInterfaceAndAcquireMessageQueue(MessageQueueId_t *MessageQueueToSet, static ReturnValue_t checkInterfaceAndAcquireMessageQueue(MessageQueueId_t *MessageQueueToSet,
const object_id_t *objectId); const object_id_t *objectId);
[[maybe_unused]] ReturnValue_t prepareHealthSetReply(const CommandMessage *reply); [[maybe_unused]] ReturnValue_t prepareHealthSetReply(const CommandMessage *reply);

View File

@ -67,7 +67,5 @@ TEST_CASE("Power Switcher", "[power-switcher]") {
REQUIRE(not switcherUsingDummy.active()); REQUIRE(not switcherUsingDummy.active());
} }
SECTION("More Dummy Tests") { SECTION("More Dummy Tests") {}
}
} }