forked from ROMEO/fsw-ws
git version at startup
This commit is contained in:
@@ -1,2 +1,4 @@
|
||||
# TODO directly referencing bsp is not correct
|
||||
target_include_directories(bsp PUBLIC include)
|
||||
target_include_directories(bsp PUBLIC include)
|
||||
|
||||
add_subdirectory(git_version)
|
||||
@@ -0,0 +1,17 @@
|
||||
find_package(Git)
|
||||
if(Git_FOUND)
|
||||
message("Git found: ${GIT_EXECUTABLE}")
|
||||
|
||||
add_custom_target( get_git_version
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D GIT_EXECUTABLE=${GIT_EXECUTABLE}
|
||||
-D INPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/git_version.h.in
|
||||
-D OUTPUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/git_version.h
|
||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/get_version.cmake
|
||||
)
|
||||
|
||||
add_dependencies(${OBSW_NAME} get_git_version)
|
||||
target_include_directories(${OBSW_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
else()
|
||||
message( FATAL_ERROR "Building outside of git is not supported yet")
|
||||
endif()
|
||||
@@ -0,0 +1,3 @@
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --dirty OUTPUT_VARIABLE GIT_VERSION_STRING OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(TIMESTAMP BUILD_TIME_STRING UTC)
|
||||
configure_file(${INPUT_FILE} ${OUTPUT_FILE})
|
||||
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
#cmakedefine GIT_VERSION_STRING "@GIT_VERSION_STRING@"
|
||||
#cmakedefine BUILD_TIME_STRING "@BUILD_TIME_STRING@"
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <hardware/interfaces.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <git_version.h>
|
||||
|
||||
|
||||
void rust_main();
|
||||
|
||||
@@ -41,12 +43,23 @@ void test_hardware() {
|
||||
// to be implemented by bsp (do not return from it!)
|
||||
void done();
|
||||
|
||||
|
||||
void init_task(void* _) {
|
||||
rust_main(_);
|
||||
}
|
||||
|
||||
#define STARTUP_MESSAGE1 "\nROMEO embedded obsw\nRelease: "
|
||||
#define STARTUP_MESSAGE2 "\nBuild time: "
|
||||
|
||||
|
||||
void mission(void) {
|
||||
|
||||
write(1, STARTUP_MESSAGE1, strlen(STARTUP_MESSAGE1));
|
||||
write(1, GIT_VERSION_STRING, strlen(GIT_VERSION_STRING));
|
||||
write(1, STARTUP_MESSAGE2, strlen(STARTUP_MESSAGE2));
|
||||
write(1, BUILD_TIME_STRING, strlen(BUILD_TIME_STRING));
|
||||
write(1, "\n", 1);
|
||||
|
||||
|
||||
test_hardware();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user