From a416ca406bfce706a710c3ed78351aea7b9073c9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 22 Apr 2022 14:09:08 +0200 Subject: [PATCH 1/8] git describe support finished --- CMakeLists.txt | 19 +- bsp_q7s/core/obsw.cpp | 6 +- cmake/GetGitRevisionDescription.cmake | 284 ++++++++++++++++++ cmake/GetGitRevisionDescription.cmake.in | 43 +++ cmake/HardwareOsPostConfig.cmake | 11 - cmake/HardwareOsPreConfig.cmake | 74 ----- cmake/PreProjectConfig.cmake | 75 +++++ cmake/helpers.cmake | 28 ++ common/config/commonConfig.cpp | 1 + common/config/commonConfig.h.in | 10 + fsfw | 2 +- linux/devices/GPSHyperionLinuxController.cpp | 15 +- .../devicedefinitions/PlocMPSoCDefinitions.h | 28 +- linux/devices/ploc/PlocMPSoCHandler.cpp | 7 +- linux/devices/ploc/PlocMPSoCHandler.h | 2 +- tmtc | 2 +- 16 files changed, 491 insertions(+), 116 deletions(-) create mode 100644 cmake/GetGitRevisionDescription.cmake create mode 100644 cmake/GetGitRevisionDescription.cmake.in delete mode 100644 cmake/HardwareOsPreConfig.cmake create mode 100644 cmake/helpers.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c85453c..1e1564b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,8 +41,26 @@ endif() # Perform steps like loading toolchain files where applicable. include(${CMAKE_SCRIPT_PATH}/PreProjectConfig.cmake) +include(${CMAKE_SCRIPT_PATH}/helpers.cmake) pre_project_config() +# Version handling +determine_version_with_git("--exclude" "docker_*") +set(GIT_INFO ${GIT_INFO} CACHE STRING "Version information retrieved with git describe") +list(GET GIT_INFO 1 OBSW_VERSION_MAJOR) +list(GET GIT_INFO 2 OBSW_VERSION_MINOR) +list(GET GIT_INFO 3 OBSW_VERSION_REVISION) +list(GET GIT_INFO 4 OBSW_VERSION_CST_GIT_SHA1) +if(NOT OBSW_VERSION_MAJOR) + set(OBSW_VERSION_MAJOR 0) +endif() +if(NOT OBSW_VERSION_MINOR) + set(OBSW_VERSION_MINOR 0) +endif() +if(NOT OBSW_VERSION_REVISION) + set(OBSW_VERSION_REVISION 0) +endif() + # Check whether the user has already installed Catch2 first. This has to come before # the project call. We could also exclude doing this when the Q7S primary OBSW is built.. find_package(Catch2 3 CONFIG QUIET) @@ -98,7 +116,6 @@ set(EIVE_ADD_LINUX_FILES False) # Analyse different OS and architecture/target options, determine BSP_PATH, # display information about compiler etc. -include (${CMAKE_SCRIPT_PATH}/HardwareOsPreConfig.cmake) pre_source_hw_os_config() if(TGT_BSP) diff --git a/bsp_q7s/core/obsw.cpp b/bsp_q7s/core/obsw.cpp index 359d04c2..c65fcf8a 100644 --- a/bsp_q7s/core/obsw.cpp +++ b/bsp_q7s/core/obsw.cpp @@ -5,7 +5,7 @@ #include "InitMission.h" #include "OBSWConfig.h" -#include "OBSWVersion.h" +#include "commonConfig.h" #include "fsfw/tasks/TaskFactory.h" #include "fsfw/version.h" #include "watchdog/definitions.h" @@ -16,8 +16,8 @@ int obsw::obsw() { using namespace fsfw; std::cout << "-- EIVE OBSW --" << std::endl; std::cout << "-- Compiled for Linux (Xiphos Q7S) --" << std::endl; - std::cout << "-- OBSW v" << SW_VERSION << "." << SW_SUBVERSION << "." << SW_REVISION << ", FSFW v" - << FSFW_VERSION << "--" << std::endl; + std::cout << "-- OBSW v" << common::OBSW_VERSION << " FSFW v" << fsfw::FSFW_VERSION << " --" + << std::endl; std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; #if Q7S_CHECK_FOR_ALREADY_RUNNING_IMG == 1 diff --git a/cmake/GetGitRevisionDescription.cmake b/cmake/GetGitRevisionDescription.cmake new file mode 100644 index 00000000..69ef78b2 --- /dev/null +++ b/cmake/GetGitRevisionDescription.cmake @@ -0,0 +1,284 @@ +# - Returns a version string from Git +# +# These functions force a re-configure on each git commit so that you can +# trust the values of the variables in your build system. +# +# get_git_head_revision( [ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR]) +# +# Returns the refspec and sha hash of the current head revision +# +# git_describe( [ ...]) +# +# Returns the results of git describe on the source tree, and adjusting +# the output so that it tests false if an error occurs. +# +# git_describe_working_tree( [ ...]) +# +# Returns the results of git describe on the working tree (--dirty option), +# and adjusting the output so that it tests false if an error occurs. +# +# git_get_exact_tag( [ ...]) +# +# Returns the results of git describe --exact-match on the source tree, +# and adjusting the output so that it tests false if there was no exact +# matching tag. +# +# git_local_changes() +# +# Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes. +# Uses the return code of "git diff-index --quiet HEAD --". +# Does not regard untracked files. +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2020 Ryan Pavlik +# http://academic.cleardefinition.com +# +# Copyright 2009-2013, Iowa State University. +# Copyright 2013-2020, Ryan Pavlik +# Copyright 2013-2020, Contributors +# SPDX-License-Identifier: BSL-1.0 +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +if(__get_git_revision_description) + return() +endif() +set(__get_git_revision_description YES) + +# We must run the following at "include" time, not at function call time, +# to find the path to this module rather than the path to a calling list file +get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) + +# Function _git_find_closest_git_dir finds the next closest .git directory +# that is part of any directory in the path defined by _start_dir. +# The result is returned in the parent scope variable whose name is passed +# as variable _git_dir_var. If no .git directory can be found, the +# function returns an empty string via _git_dir_var. +# +# Example: Given a path C:/bla/foo/bar and assuming C:/bla/.git exists and +# neither foo nor bar contain a file/directory .git. This wil return +# C:/bla/.git +# +function(_git_find_closest_git_dir _start_dir _git_dir_var) + set(cur_dir "${_start_dir}") + set(git_dir "${_start_dir}/.git") + while(NOT EXISTS "${git_dir}") + # .git dir not found, search parent directories + set(git_previous_parent "${cur_dir}") + get_filename_component(cur_dir "${cur_dir}" DIRECTORY) + if(cur_dir STREQUAL git_previous_parent) + # We have reached the root directory, we are not in git + set(${_git_dir_var} + "" + PARENT_SCOPE) + return() + endif() + set(git_dir "${cur_dir}/.git") + endwhile() + set(${_git_dir_var} + "${git_dir}" + PARENT_SCOPE) +endfunction() + +function(get_git_head_revision _refspecvar _hashvar) + _git_find_closest_git_dir("${CMAKE_CURRENT_SOURCE_DIR}" GIT_DIR) + + if("${ARGN}" STREQUAL "ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR") + set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR TRUE) + else() + set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR FALSE) + endif() + if(NOT "${GIT_DIR}" STREQUAL "") + file(RELATIVE_PATH _relative_to_source_dir "${CMAKE_SOURCE_DIR}" + "${GIT_DIR}") + if("${_relative_to_source_dir}" MATCHES "[.][.]" AND NOT ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR) + # We've gone above the CMake root dir. + set(GIT_DIR "") + endif() + endif() + if("${GIT_DIR}" STREQUAL "") + set(${_refspecvar} + "GITDIR-NOTFOUND" + PARENT_SCOPE) + set(${_hashvar} + "GITDIR-NOTFOUND" + PARENT_SCOPE) + return() + endif() + + # Check if the current source dir is a git submodule or a worktree. + # In both cases .git is a file instead of a directory. + # + if(NOT IS_DIRECTORY ${GIT_DIR}) + # The following git command will return a non empty string that + # points to the super project working tree if the current + # source dir is inside a git submodule. + # Otherwise the command will return an empty string. + # + execute_process( + COMMAND "${GIT_EXECUTABLE}" rev-parse + --show-superproject-working-tree + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + OUTPUT_VARIABLE out + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT "${out}" STREQUAL "") + # If out is empty, GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a submodule + file(READ ${GIT_DIR} submodule) + string(REGEX REPLACE "gitdir: (.*)$" "\\1" GIT_DIR_RELATIVE + ${submodule}) + string(STRIP ${GIT_DIR_RELATIVE} GIT_DIR_RELATIVE) + get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) + get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} + ABSOLUTE) + set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD") + else() + # GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a worktree + file(READ ${GIT_DIR} worktree_ref) + # The .git directory contains a path to the worktree information directory + # inside the parent git repo of the worktree. + # + string(REGEX REPLACE "gitdir: (.*)$" "\\1" git_worktree_dir + ${worktree_ref}) + string(STRIP ${git_worktree_dir} git_worktree_dir) + _git_find_closest_git_dir("${git_worktree_dir}" GIT_DIR) + set(HEAD_SOURCE_FILE "${git_worktree_dir}/HEAD") + endif() + else() + set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD") + endif() + set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") + if(NOT EXISTS "${GIT_DATA}") + file(MAKE_DIRECTORY "${GIT_DATA}") + endif() + + if(NOT EXISTS "${HEAD_SOURCE_FILE}") + return() + endif() + set(HEAD_FILE "${GIT_DATA}/HEAD") + configure_file("${HEAD_SOURCE_FILE}" "${HEAD_FILE}" COPYONLY) + + configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" + "${GIT_DATA}/grabRef.cmake" @ONLY) + include("${GIT_DATA}/grabRef.cmake") + + set(${_refspecvar} + "${HEAD_REF}" + PARENT_SCOPE) + set(${_hashvar} + "${HEAD_HASH}" + PARENT_SCOPE) +endfunction() + +function(git_describe _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash) + if(NOT GIT_FOUND) + set(${_var} + "GIT-NOTFOUND" + PARENT_SCOPE) + return() + endif() + if(NOT hash) + set(${_var} + "HEAD-HASH-NOTFOUND" + PARENT_SCOPE) + return() + endif() + + # TODO sanitize + #if((${ARGN}" MATCHES "&&") OR + # (ARGN MATCHES "||") OR + # (ARGN MATCHES "\\;")) + # message("Please report the following error to the project!") + # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") + #endif() + + #message(STATUS "Arguments to execute_process: ${ARGN}") + + execute_process( + COMMAND "${GIT_EXECUTABLE}" describe --tags --always ${hash} ${ARGN} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE res + OUTPUT_VARIABLE out + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + set(out "${out}-${res}-NOTFOUND") + endif() + + set(${_var} + "${out}" + PARENT_SCOPE) +endfunction() + +function(git_describe_working_tree _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + if(NOT GIT_FOUND) + set(${_var} + "GIT-NOTFOUND" + PARENT_SCOPE) + return() + endif() + + execute_process( + COMMAND "${GIT_EXECUTABLE}" describe --dirty ${ARGN} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE res + OUTPUT_VARIABLE out + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + set(out "${out}-${res}-NOTFOUND") + endif() + + set(${_var} + "${out}" + PARENT_SCOPE) +endfunction() + +function(git_get_exact_tag _var) + git_describe(out --exact-match ${ARGN}) + set(${_var} + "${out}" + PARENT_SCOPE) +endfunction() + +function(git_local_changes _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash) + if(NOT GIT_FOUND) + set(${_var} + "GIT-NOTFOUND" + PARENT_SCOPE) + return() + endif() + if(NOT hash) + set(${_var} + "HEAD-HASH-NOTFOUND" + PARENT_SCOPE) + return() + endif() + + execute_process( + COMMAND "${GIT_EXECUTABLE}" diff-index --quiet HEAD -- + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE res + OUTPUT_VARIABLE out + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + if(res EQUAL 0) + set(${_var} + "CLEAN" + PARENT_SCOPE) + else() + set(${_var} + "DIRTY" + PARENT_SCOPE) + endif() +endfunction() diff --git a/cmake/GetGitRevisionDescription.cmake.in b/cmake/GetGitRevisionDescription.cmake.in new file mode 100644 index 00000000..66eee637 --- /dev/null +++ b/cmake/GetGitRevisionDescription.cmake.in @@ -0,0 +1,43 @@ +# +# Internal file for GetGitRevisionDescription.cmake +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright 2009-2012, Iowa State University +# Copyright 2011-2015, Contributors +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +# SPDX-License-Identifier: BSL-1.0 + +set(HEAD_HASH) + +file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) + +string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) +if(HEAD_CONTENTS MATCHES "ref") + # named branch + string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") + if(EXISTS "@GIT_DIR@/${HEAD_REF}") + configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + else() + configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) + file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) + if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") + set(HEAD_HASH "${CMAKE_MATCH_1}") + endif() + endif() +else() + # detached HEAD + configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) +endif() + +if(NOT HEAD_HASH) + file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) + string(STRIP "${HEAD_HASH}" HEAD_HASH) +endif() diff --git a/cmake/HardwareOsPostConfig.cmake b/cmake/HardwareOsPostConfig.cmake index 841085f5..5146de98 100644 --- a/cmake/HardwareOsPostConfig.cmake +++ b/cmake/HardwareOsPostConfig.cmake @@ -1,16 +1,5 @@ function(post_source_hw_os_config) -if(LINK_LWIP) - message(STATUS "Linking against ${LIB_LWIP_NAME} lwIP library") - if(LIB_LWIP_NAME) - target_link_libraries(${OBSW_NAME} PUBLIC - ${LIB_LWIP_NAME} - ) - else() - message(WARNING "lwIP library name not set!") - endif() -endif() - if(LINKER_SCRIPT) add_link_options( -T${LINKER_SCRIPT} diff --git a/cmake/HardwareOsPreConfig.cmake b/cmake/HardwareOsPreConfig.cmake deleted file mode 100644 index 7b90eb54..00000000 --- a/cmake/HardwareOsPreConfig.cmake +++ /dev/null @@ -1,74 +0,0 @@ -function(pre_source_hw_os_config) - -# FreeRTOS -if(FSFW_OSAL MATCHES freertos) - message(FATAL_ERROR "No FreeRTOS support implemented yet.") -# RTEMS -elseif(FSFW_OSAL STREQUAL rtems) - add_definitions(-DRTEMS) - message(FATAL_ERROR "No RTEMS support implemented yet.") -elseif(FSFW_OSAL STREQUAL linux) - add_definitions(-DUNIX -DLINUX) - find_package(Threads REQUIRED) -# Hosted -else() - set(BSP_PATH "bsp_hosted") - if(WIN32) - add_definitions(-DWIN32) - elseif(UNIX) - find_package(Threads REQUIRED) - add_definitions(-DUNIX -DLINUX) - endif() -endif() - -# Cross-compile information -if(CMAKE_CROSSCOMPILING) - # set(CMAKE_VERBOSE TRUE) - - message(STATUS "Cross-compiling for ${TGT_BSP} target") - message(STATUS "Cross-compile gcc: ${CMAKE_C_COMPILER}") - message(STATUS "Cross-compile g++: ${CMAKE_CXX_COMPILER}") - - if(CMAKE_VERBOSE) - message(STATUS "Cross-compile linker: ${CMAKE_LINKER}") - message(STATUS "Cross-compile size utility: ${CMAKE_SIZE}") - message(STATUS "Cross-compile objcopy utility: ${CMAKE_OBJCOPY}") - message(STATUS "Cross-compile ranlib utility: ${CMAKE_RANLIB}") - message(STATUS "Cross-compile ar utility: ${CMAKE_AR}") - message(STATUS "Cross-compile nm utility: ${CMAKE_NM}") - message(STATUS "Cross-compile strip utility: ${CMAKE_STRIP}") - message(STATUS - "Cross-compile assembler: ${CMAKE_ASM_COMPILER} " - "-x assembler-with-cpp" - ) - message(STATUS "ABI flags: ${ABI_FLAGS}") - message(STATUS "Custom linker script: ${LINKER_SCRIPT}") - endif() - - set_property(CACHE TGT_BSP - PROPERTY STRINGS - "arm/q7s" "arm/raspberrypi" "arm/egse" - ) -endif() - - -if(TGT_BSP) - if (TGT_BSP MATCHES "arm/raspberrypi" OR TGT_BSP MATCHES "arm/beagleboneblack") - set(BSP_PATH "bsp_linux_board") - elseif(TGT_BSP MATCHES "arm/q7s") - set(BSP_PATH "bsp_q7s") - elseif(TGT_BSP MATCHES "arm/egse") - set(BSP_PATH "bsp_egse") - elseif(TGT_BSP MATCHES "arm/te0720-1cfa") - set(BSP_PATH "bsp_te0720_1cfa") - else() - message(WARNING "CMake not configured for this target!") - message(FATAL_ERROR "Target: ${TGT_BSP}!") - endif() -else() - set(BSP_PATH "bsp_hosted") -endif() - -set(BSP_PATH ${BSP_PATH} PARENT_SCOPE) - -endfunction() \ No newline at end of file diff --git a/cmake/PreProjectConfig.cmake b/cmake/PreProjectConfig.cmake index 52a71923..1d7ac94c 100644 --- a/cmake/PreProjectConfig.cmake +++ b/cmake/PreProjectConfig.cmake @@ -1,3 +1,78 @@ +function(pre_source_hw_os_config) + +# FreeRTOS +if(FSFW_OSAL MATCHES freertos) + message(FATAL_ERROR "No FreeRTOS support implemented yet.") +# RTEMS +elseif(FSFW_OSAL STREQUAL rtems) + add_definitions(-DRTEMS) + message(FATAL_ERROR "No RTEMS support implemented yet.") +elseif(FSFW_OSAL STREQUAL linux) + add_definitions(-DUNIX -DLINUX) + find_package(Threads REQUIRED) +# Hosted +else() + set(BSP_PATH "bsp_hosted") + if(WIN32) + add_definitions(-DWIN32) + elseif(UNIX) + find_package(Threads REQUIRED) + add_definitions(-DUNIX -DLINUX) + endif() +endif() + +# Cross-compile information +if(CMAKE_CROSSCOMPILING) + # set(CMAKE_VERBOSE TRUE) + + message(STATUS "Cross-compiling for ${TGT_BSP} target") + message(STATUS "Cross-compile gcc: ${CMAKE_C_COMPILER}") + message(STATUS "Cross-compile g++: ${CMAKE_CXX_COMPILER}") + + if(CMAKE_VERBOSE) + message(STATUS "Cross-compile linker: ${CMAKE_LINKER}") + message(STATUS "Cross-compile size utility: ${CMAKE_SIZE}") + message(STATUS "Cross-compile objcopy utility: ${CMAKE_OBJCOPY}") + message(STATUS "Cross-compile ranlib utility: ${CMAKE_RANLIB}") + message(STATUS "Cross-compile ar utility: ${CMAKE_AR}") + message(STATUS "Cross-compile nm utility: ${CMAKE_NM}") + message(STATUS "Cross-compile strip utility: ${CMAKE_STRIP}") + message(STATUS + "Cross-compile assembler: ${CMAKE_ASM_COMPILER} " + "-x assembler-with-cpp" + ) + message(STATUS "ABI flags: ${ABI_FLAGS}") + message(STATUS "Custom linker script: ${LINKER_SCRIPT}") + endif() + + set_property(CACHE TGT_BSP + PROPERTY STRINGS + "arm/q7s" "arm/raspberrypi" "arm/egse" + ) +endif() + + +if(TGT_BSP) + if (TGT_BSP MATCHES "arm/raspberrypi" OR TGT_BSP MATCHES "arm/beagleboneblack") + set(BSP_PATH "bsp_linux_board") + elseif(TGT_BSP MATCHES "arm/q7s") + set(BSP_PATH "bsp_q7s") + elseif(TGT_BSP MATCHES "arm/egse") + set(BSP_PATH "bsp_egse") + elseif(TGT_BSP MATCHES "arm/te0720-1cfa") + set(BSP_PATH "bsp_te0720_1cfa") + else() + message(WARNING "CMake not configured for this target!") + message(FATAL_ERROR "Target: ${TGT_BSP}!") + endif() +else() + set(BSP_PATH "bsp_hosted") +endif() + +set(BSP_PATH ${BSP_PATH} PARENT_SCOPE) + +endfunction() + function(pre_project_config) # Basic input sanitization diff --git a/cmake/helpers.cmake b/cmake/helpers.cmake new file mode 100644 index 00000000..666c421c --- /dev/null +++ b/cmake/helpers.cmake @@ -0,0 +1,28 @@ +# Determines the git version with git describe and returns it by setting +# the GIT_INFO list in the parent scope. The list has the following entries +# 1. Full version string +# 2. Major version +# 3. Minor version +# 4. Revision +# 5. git SHA hash and commits since tag +function(determine_version_with_git) + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GetGitRevisionDescription.cmake) + git_describe(VERSION ${ARGN}) + string(FIND ${VERSION} "." VALID_VERSION) + if(VALID_VERSION EQUAL -1) + message(WARNING "Version string ${VERSION} retrieved with git describe is invalid") + return() + endif() + # Parse the version information into pieces. + string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" _VERSION_MAJOR "${VERSION}") + string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" _VERSION_MINOR "${VERSION}") + string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" _VERSION_PATCH "${VERSION}") + string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+-(.*)" "\\1" VERSION_SHA1 "${VERSION}") + set(GIT_INFO ${VERSION}) + list(APPEND GIT_INFO ${_VERSION_MAJOR}) + list(APPEND GIT_INFO ${_VERSION_MINOR}) + list(APPEND GIT_INFO ${_VERSION_PATCH}) + list(APPEND GIT_INFO ${VERSION_SHA1}) + set(GIT_INFO ${GIT_INFO} PARENT_SCOPE) + message(STATUS "eive | Set git version info into GIT_INFO from the git tag ${VERSION}") +endfunction() diff --git a/common/config/commonConfig.cpp b/common/config/commonConfig.cpp index 31674512..cb2b9666 100644 --- a/common/config/commonConfig.cpp +++ b/common/config/commonConfig.cpp @@ -2,4 +2,5 @@ #include "tmtc/apid.h" #include "fsfw/tmtcpacket/SpacePacket.h" +const Version common::OBSW_VERSION { OBSW_VERSION_MAJOR, OBSW_VERSION_MINOR, OBSW_VERSION_REVISION, OBSW_VERSION_CST_GIT_SHA1 }; const uint16_t common::PUS_PACKET_ID = spacepacket::getTcSpacePacketIdFromApid(apid::EIVE_OBSW); diff --git a/common/config/commonConfig.h.in b/common/config/commonConfig.h.in index 6d74884f..737b0d0e 100644 --- a/common/config/commonConfig.h.in +++ b/common/config/commonConfig.h.in @@ -2,6 +2,7 @@ #define COMMON_CONFIG_COMMONCONFIG_H_ #include +#include "fsfw/version.h" #define OBSW_ADD_LWGPS_TEST 0 @@ -15,6 +16,15 @@ #define OBSW_USE_TMTC_TCP_BRIDGE 1 namespace common { + +static constexpr uint8_t OBSW_VERSION_MAJOR = @OBSW_VERSION_MAJOR@; +static constexpr uint8_t OBSW_VERSION_MINOR = @OBSW_VERSION_MINOR@; +static constexpr uint8_t OBSW_VERSION_REVISION = @OBSW_VERSION_REVISION@; +// CST: Commits since tag +static const char OBSW_VERSION_CST_GIT_SHA1[] = "@OBSW_VERSION_CST_GIT_SHA1@"; + +extern const Version OBSW_VERSION; + extern const uint16_t PUS_PACKET_ID; static constexpr uint32_t CCSDS_HANDLER_QUEUE_SIZE = 50; diff --git a/fsfw b/fsfw index 613dbe95..b951cb73 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 613dbe9592c30d9acf4cdb95d81d9f216f07374b +Subproject commit b951cb736a41c8b8db6532da3168529ad88cc017 diff --git a/linux/devices/GPSHyperionLinuxController.cpp b/linux/devices/GPSHyperionLinuxController.cpp index 42bc43a6..9c762842 100644 --- a/linux/devices/GPSHyperionLinuxController.cpp +++ b/linux/devices/GPSHyperionLinuxController.cpp @@ -110,12 +110,12 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() { // The data from the device will generally be read all at once. Therefore, we // can set all field here if (not myGpsmm.is_open()) { - if(gpsNotOpenSwitch) { + if (gpsNotOpenSwitch) { // Opening failed - #if FSFW_VERBOSE_LEVEL >= 1 - sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Opening GPSMM failed | " << - "Error " << errno << " | " << gps_errstr(errno) << std::endl; - #endif +#if FSFW_VERBOSE_LEVEL >= 1 + sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Opening GPSMM failed | " + << "Error " << errno << " | " << gps_errstr(errno) << std::endl; +#endif gpsNotOpenSwitch = false; } @@ -124,9 +124,10 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() { gps_data_t *gps = nullptr; gps = myGpsmm.read(); if (gps == nullptr) { - if(gpsReadFailedSwitch) { + if (gpsReadFailedSwitch) { gpsReadFailedSwitch = false; - sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading GPS data failed" << std::endl; + sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading GPS data failed" + << std::endl; } return; } diff --git a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h index fc7fa185..23389208 100644 --- a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h +++ b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h @@ -643,24 +643,24 @@ class TcModeIdle : public TcBase { }; class TcCamcmdSend : public TcBase { -public: + public: TcCamcmdSend(uint16_t sequenceCount) : TcBase(apid::TC_CAM_CMD_SEND, sequenceCount) {} -protected: - ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) { - if (commandDataLen > MAX_DATA_LENGTH) { - return INVALID_LENGTH; - } - std::memcpy(this->getPacketData(), commandData, commandDataLen); - *(this->getPacketData() + commandDataLen) = CARRIAGE_RETURN; - uint16_t trueLength = commandDataLen + sizeof(CARRIAGE_RETURN) + CRC_SIZE; - this->setPacketDataLength(trueLength - 1); - return HasReturnvaluesIF::RETURN_OK; + protected: + ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) { + if (commandDataLen > MAX_DATA_LENGTH) { + return INVALID_LENGTH; } -private: - static const uint8_t MAX_DATA_LENGTH = 10; - static const uint8_t CARRIAGE_RETURN = 0xD; + std::memcpy(this->getPacketData(), commandData, commandDataLen); + *(this->getPacketData() + commandDataLen) = CARRIAGE_RETURN; + uint16_t trueLength = commandDataLen + sizeof(CARRIAGE_RETURN) + CRC_SIZE; + this->setPacketDataLength(trueLength - 1); + return HasReturnvaluesIF::RETURN_OK; + } + private: + static const uint8_t MAX_DATA_LENGTH = 10; + static const uint8_t CARRIAGE_RETURN = 0xD; }; } // namespace mpsoc diff --git a/linux/devices/ploc/PlocMPSoCHandler.cpp b/linux/devices/ploc/PlocMPSoCHandler.cpp index 07a658bf..52fd5812 100644 --- a/linux/devices/ploc/PlocMPSoCHandler.cpp +++ b/linux/devices/ploc/PlocMPSoCHandler.cpp @@ -255,7 +255,7 @@ void PlocMPSoCHandler::fillCommandAndReplyMap() { this->insertInReplyMap(mpsoc::ACK_REPORT, 3, nullptr, mpsoc::SIZE_ACK_REPORT); this->insertInReplyMap(mpsoc::EXE_REPORT, 3, nullptr, mpsoc::SIZE_EXE_REPORT); this->insertInReplyMap(mpsoc::TM_MEMORY_READ_REPORT, 2, nullptr, mpsoc::SIZE_TM_MEM_READ_REPORT); - this->insertInReplyMap(mpsoc::TM_CAM_CMD_RPT, 2, nullptr, SpacePacket::PACKET_MAX_SIZE); + this->insertInReplyMap(mpsoc::TM_CAM_CMD_RPT, 2, nullptr, SpacePacket::PACKET_MAX_SIZE); } ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize, @@ -653,8 +653,9 @@ ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) { sif::warning << "PlocMPSoCHandler::handleCamCmdRpt: CRC failure" << std::endl; } const uint8_t* dataFieldPtr = data + mpsoc::SPACE_PACKET_HEADER_SIZE; - std::string camCmdRptMsg(reinterpret_cast( - dataFieldPtr), tmCamCmdRpt.rememberSpacePacketSize - mpsoc::SPACE_PACKET_HEADER_SIZE - 3); + std::string camCmdRptMsg( + reinterpret_cast(dataFieldPtr), + tmCamCmdRpt.rememberSpacePacketSize - mpsoc::SPACE_PACKET_HEADER_SIZE - 3); uint8_t ackValue = *(packet.getPacketData() + packet.getPacketDataLength() - 2); sif::info << "CamCmdRpt message: " << camCmdRptMsg << std::endl; sif::info << "CamCmdRpt Ack value: 0x" << std::hex << static_cast(ackValue) diff --git a/linux/devices/ploc/PlocMPSoCHandler.h b/linux/devices/ploc/PlocMPSoCHandler.h index c4af88d5..d5ea231b 100644 --- a/linux/devices/ploc/PlocMPSoCHandler.h +++ b/linux/devices/ploc/PlocMPSoCHandler.h @@ -4,11 +4,11 @@ #include #include "PlocMPSoCHelper.h" -#include "fsfw/tmtcpacket/SpacePacket.h" #include "fsfw/action/CommandActionHelper.h" #include "fsfw/action/CommandsActionsIF.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "fsfw/ipc/QueueFactory.h" +#include "fsfw/tmtcpacket/SpacePacket.h" #include "fsfw/tmtcservices/SourceSequenceCounter.h" #include "fsfw_hal/linux/gpio/Gpio.h" #include "fsfw_hal/linux/uart/UartComIF.h" diff --git a/tmtc b/tmtc index 45470f8c..28983d38 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 45470f8c05ef214eb41940878ef0bfabf36a4891 +Subproject commit 28983d387b82578a73fbfe052cb53dec1910d021 From 0f8050146799f71bc87ce8219dabb6ae80d83bf6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 22 Apr 2022 15:42:13 +0200 Subject: [PATCH 2/8] rename helpers file --- CMakeLists.txt | 11 +++++------ cmake/{helpers.cmake => EiveHelpers.cmake} | 2 +- fsfw | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) rename cmake/{helpers.cmake => EiveHelpers.cmake} (94%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e1564b2..48fb256e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,8 +11,7 @@ cmake_minimum_required(VERSION 3.13) # set(CMAKE_VERBOSE TRUE) -set(CMAKE_SCRIPT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") - +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") option(EIVE_ADD_ETL_LIB "Add ETL library" ON) option(EIVE_ADD_JSON_LIB "Add JSON library" ON) @@ -40,8 +39,8 @@ if(TGT_BSP) endif() # Perform steps like loading toolchain files where applicable. -include(${CMAKE_SCRIPT_PATH}/PreProjectConfig.cmake) -include(${CMAKE_SCRIPT_PATH}/helpers.cmake) +include(PreProjectConfig) +include(EiveHelpers) pre_project_config() # Version handling @@ -399,7 +398,7 @@ endif() if(CMAKE_CROSSCOMPILING) - include (${CMAKE_SCRIPT_PATH}/HardwareOsPostConfig.cmake) + include (HardwareOsPostConfig) post_source_hw_os_config() endif() @@ -436,5 +435,5 @@ add_custom_command( COMMENT ${POST_BUILD_COMMENT} ) -include (${CMAKE_SCRIPT_PATH}/BuildType.cmake) +include (BuildType) set_build_type() diff --git a/cmake/helpers.cmake b/cmake/EiveHelpers.cmake similarity index 94% rename from cmake/helpers.cmake rename to cmake/EiveHelpers.cmake index 666c421c..1a717552 100644 --- a/cmake/helpers.cmake +++ b/cmake/EiveHelpers.cmake @@ -6,7 +6,7 @@ # 4. Revision # 5. git SHA hash and commits since tag function(determine_version_with_git) - include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GetGitRevisionDescription.cmake) + include(GetGitRevisionDescription) git_describe(VERSION ${ARGN}) string(FIND ${VERSION} "." VALID_VERSION) if(VALID_VERSION EQUAL -1) diff --git a/fsfw b/fsfw index b951cb73..707a43ab 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit b951cb736a41c8b8db6532da3168529ad88cc017 +Subproject commit 707a43aba98ea00a1fd5ab73642c357b7a36a7ad From 0638c87f62b39a6cde6b588a546d7d49db727b27 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 22 Apr 2022 15:47:47 +0200 Subject: [PATCH 3/8] made version handling more robust --- CMakeLists.txt | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 48fb256e..9291e0db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,9 @@ cmake_minimum_required(VERSION 3.13) # set(CMAKE_VERBOSE TRUE) +set(OBSW_VERSION_MAJOR_IF_GIT_FAILS 0) +set(OBSW_VERSION_MINOR_IF_GIT_FAILS 0) +set(OBSW_VERSION_REVISION_IF_GIT_FAILS 0) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") @@ -44,20 +47,34 @@ include(EiveHelpers) pre_project_config() # Version handling -determine_version_with_git("--exclude" "docker_*") -set(GIT_INFO ${GIT_INFO} CACHE STRING "Version information retrieved with git describe") -list(GET GIT_INFO 1 OBSW_VERSION_MAJOR) -list(GET GIT_INFO 2 OBSW_VERSION_MINOR) -list(GET GIT_INFO 3 OBSW_VERSION_REVISION) -list(GET GIT_INFO 4 OBSW_VERSION_CST_GIT_SHA1) -if(NOT OBSW_VERSION_MAJOR) - set(OBSW_VERSION_MAJOR 0) +set(GIT_VER_HANDLING_OK FALSE) +if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git) + determine_version_with_git("--exclude" "docker_*") + set(GIT_INFO ${GIT_INFO} CACHE STRING "Version information retrieved with git describe") + if(GIT_INFO) + set(GIT_INFO ${GIT_INFO} CACHE STRING "Version information retrieved with git describe") + list(GET GIT_INFO 1 OBSW_VERSION_MAJOR) + list(GET GIT_INFO 2 OBSW_VERSION_MINOR) + list(GET GIT_INFO 3 OBSW_VERSION_REVISION) + list(GET GIT_INFO 4 OBSW_VERSION_CST_GIT_SHA1) + if(NOT OBSW_VERSION_MAJOR) + set(OBSW_VERSION_MAJOR ${OBSW_VERSION_MAJOR_IF_GIT_FAILS}) + endif() + if(NOT OBSW_VERSION_MINOR) + set(FSFW_SUBVERSION ${OBSW_VERSION_MINOR_IF_GIT_FAILS}) + endif() + if(NOT OBSW_VERSION_REVISION) + set(FSFW_REVISION ${OBSW_VERSION_REVISION_IF_GIT_FAILS}) + endif() + set(GIT_VER_HANDLING_OK TRUE) + else() + set(GIT_VER_HANDLING_OK FALSE) + endif() endif() -if(NOT OBSW_VERSION_MINOR) - set(OBSW_VERSION_MINOR 0) -endif() -if(NOT OBSW_VERSION_REVISION) - set(OBSW_VERSION_REVISION 0) +if(NOT GIT_VER_HANDLING_OK) + set(OBSW_VERSION_MAJOR ${OBSW_VERSION_MAJOR_IF_GIT_FAILS}) + set(OBSW_VERSION_MINOR ${OBSW_VERSION_MINOR_IF_GIT_FAILS}) + set(OBSW_VERSION_REVISION ${OBSW_VERSION_REVISION_IF_GIT_FAILS}) endif() # Check whether the user has already installed Catch2 first. This has to come before From 772a829333a499e0a3b51d88eed64294e2aa812f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 22 Apr 2022 15:58:15 +0200 Subject: [PATCH 4/8] small improvement --- bsp_q7s/core/obsw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp_q7s/core/obsw.cpp b/bsp_q7s/core/obsw.cpp index c65fcf8a..a2888875 100644 --- a/bsp_q7s/core/obsw.cpp +++ b/bsp_q7s/core/obsw.cpp @@ -16,7 +16,7 @@ int obsw::obsw() { using namespace fsfw; std::cout << "-- EIVE OBSW --" << std::endl; std::cout << "-- Compiled for Linux (Xiphos Q7S) --" << std::endl; - std::cout << "-- OBSW v" << common::OBSW_VERSION << " FSFW v" << fsfw::FSFW_VERSION << " --" + std::cout << "-- OBSW v" << common::OBSW_VERSION << " | FSFW v" << fsfw::FSFW_VERSION << " --" << std::endl; std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; From 17fd273d1047d6319c45060c53d861b6187a2f57 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 22 Apr 2022 16:01:10 +0200 Subject: [PATCH 5/8] fix for toolchain file handling --- cmake/PreProjectConfig.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/PreProjectConfig.cmake b/cmake/PreProjectConfig.cmake index 1d7ac94c..f4808ce8 100644 --- a/cmake/PreProjectConfig.cmake +++ b/cmake/PreProjectConfig.cmake @@ -89,7 +89,7 @@ endif() if(FSFW_OSAL MATCHES linux AND TGT_BSP AND EIVE_HARDCODED_TOOLCHAIN_FILE) if(TGT_BSP MATCHES "arm/q7s" OR TGT_BSP MATCHES "arm/te0720-1cfa") set(CMAKE_TOOLCHAIN_FILE - "${CMAKE_SCRIPT_PATH}/Zynq7020CrossCompileConfig.cmake" + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Zynq7020CrossCompileConfig.cmake" PARENT_SCOPE ) elseif(TGT_BSP MATCHES "arm/raspberrypi" OR TGT_BSP MATCHES "arm/egse") @@ -123,13 +123,13 @@ if(FSFW_OSAL MATCHES linux AND TGT_BSP AND EIVE_HARDCODED_TOOLCHAIN_FILE) endif() set(CMAKE_TOOLCHAIN_FILE - "${CMAKE_SCRIPT_PATH}/RPiCrossCompileConfig.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/RPiCrossCompileConfig.cmake" PARENT_SCOPE ) elseif(${TGT_BSP} MATCHES "arm/beagleboneblack") if(LINUX_CROSS_COMPILE) set(CMAKE_TOOLCHAIN_FILE - "${CMAKE_SCRIPT_PATH}/BBBCrossCompileConfig.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/BBBCrossCompileConfig.cmake" PARENT_SCOPE ) endif() From 417a6d8ea005d76cd451fc70446b9d288fe9decb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 22 Apr 2022 16:06:44 +0200 Subject: [PATCH 6/8] added missing character --- cmake/PreProjectConfig.cmake | 2 +- fsfw | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/PreProjectConfig.cmake b/cmake/PreProjectConfig.cmake index f4808ce8..df1d92b4 100644 --- a/cmake/PreProjectConfig.cmake +++ b/cmake/PreProjectConfig.cmake @@ -89,7 +89,7 @@ endif() if(FSFW_OSAL MATCHES linux AND TGT_BSP AND EIVE_HARDCODED_TOOLCHAIN_FILE) if(TGT_BSP MATCHES "arm/q7s" OR TGT_BSP MATCHES "arm/te0720-1cfa") set(CMAKE_TOOLCHAIN_FILE - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Zynq7020CrossCompileConfig.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Zynq7020CrossCompileConfig.cmake" PARENT_SCOPE ) elseif(TGT_BSP MATCHES "arm/raspberrypi" OR TGT_BSP MATCHES "arm/egse") diff --git a/fsfw b/fsfw index 707a43ab..24ef96d1 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 707a43aba98ea00a1fd5ab73642c357b7a36a7ad +Subproject commit 24ef96d1b802e768d395f94b69f9f81a3c6d1e66 From 8bd7d00ab15bfcfeefad4e3e58498de4c60a4654 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 22 Apr 2022 16:15:04 +0200 Subject: [PATCH 7/8] forgot to bump version --- common/config/OBSWVersion.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/config/OBSWVersion.h b/common/config/OBSWVersion.h index 71fd3355..1e5dd04b 100644 --- a/common/config/OBSWVersion.h +++ b/common/config/OBSWVersion.h @@ -4,7 +4,7 @@ const char* const SW_NAME = "eive"; #define SW_VERSION 1 -#define SW_SUBVERSION 9 +#define SW_SUBVERSION 10 #define SW_REVISION 1 #endif /* COMMON_CONFIG_OBSWVERSION_H_ */ From ea139d0657c16a18302f0c8b011e8db2b592ee83 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 22 Apr 2022 16:16:25 +0200 Subject: [PATCH 8/8] added new revision --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17d29e7b..a2ef8a06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,10 @@ list yields a list of all related PRs for each release. - Add `/usr/local/bin` to PATH. All shell scripts are there now - Rename GPS device to `/dev/gps0` +# [v1.10.1] + +Version bump + # [v1.10.0] For all releases equal or prior to v1.10.0,