CMake git describe support #226
@ -10,9 +10,11 @@
|
||||
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)
|
||||
|
||||
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,9 +42,41 @@ if(TGT_BSP)
|
||||
endif()
|
||||
|
||||
# Perform steps like loading toolchain files where applicable.
|
||||
include(${CMAKE_SCRIPT_PATH}/PreProjectConfig.cmake)
|
||||
include(PreProjectConfig)
|
||||
include(EiveHelpers)
|
||||
pre_project_config()
|
||||
|
||||
# Version handling
|
||||
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 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
|
||||
# the project call. We could also exclude doing this when the Q7S primary OBSW is built..
|
||||
find_package(Catch2 3 CONFIG QUIET)
|
||||
@ -98,7 +132,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)
|
||||
@ -382,7 +415,7 @@ endif()
|
||||
|
||||
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
include (${CMAKE_SCRIPT_PATH}/HardwareOsPostConfig.cmake)
|
||||
include (HardwareOsPostConfig)
|
||||
post_source_hw_os_config()
|
||||
endif()
|
||||
|
||||
@ -419,5 +452,5 @@ add_custom_command(
|
||||
COMMENT ${POST_BUILD_COMMENT}
|
||||
)
|
||||
|
||||
include (${CMAKE_SCRIPT_PATH}/BuildType.cmake)
|
||||
include (BuildType)
|
||||
set_build_type()
|
||||
|
@ -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
|
||||
|
28
cmake/EiveHelpers.cmake
Normal file
28
cmake/EiveHelpers.cmake
Normal file
@ -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(GetGitRevisionDescription)
|
||||
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()
|
284
cmake/GetGitRevisionDescription.cmake
Normal file
284
cmake/GetGitRevisionDescription.cmake
Normal file
@ -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(<refspecvar> <hashvar> [ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR])
|
||||
#
|
||||
# Returns the refspec and sha hash of the current head revision
|
||||
#
|
||||
# git_describe(<var> [<additional arguments to 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(<var> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# 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(<var> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# 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(<var>)
|
||||
#
|
||||
# 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 <ryan.pavlik@gmail.com> <abiryan@ryand.net>
|
||||
# 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()
|
43
cmake/GetGitRevisionDescription.cmake.in
Normal file
43
cmake/GetGitRevisionDescription.cmake.in
Normal file
@ -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 <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||
# 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()
|
@ -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}
|
||||
|
@ -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()
|
@ -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
|
||||
@ -14,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")
|
||||
@ -48,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()
|
||||
|
@ -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);
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define COMMON_CONFIG_COMMONCONFIG_H_
|
||||
|
||||
#include <cstdint>
|
||||
#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;
|
||||
|
2
fsfw
2
fsfw
@ -1 +1 @@
|
||||
Subproject commit 613dbe9592c30d9acf4cdb95d81d9f216f07374b
|
||||
Subproject commit 24ef96d1b802e768d395f94b69f9f81a3c6d1e66
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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<const char*>(
|
||||
dataFieldPtr), tmCamCmdRpt.rememberSpacePacketSize - mpsoc::SPACE_PACKET_HEADER_SIZE - 3);
|
||||
std::string camCmdRptMsg(
|
||||
reinterpret_cast<const char*>(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<unsigned int>(ackValue)
|
||||
|
@ -4,11 +4,11 @@
|
||||
#include <string>
|
||||
|
||||
#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"
|
||||
|
2
tmtc
2
tmtc
@ -1 +1 @@
|
||||
Subproject commit 45470f8c05ef214eb41940878ef0bfabf36a4891
|
||||
Subproject commit 28983d387b82578a73fbfe052cb53dec1910d021
|
Loading…
Reference in New Issue
Block a user