Skip to content

Commit

Permalink
Add git hash variable and print version info in trace file for improv…
Browse files Browse the repository at this point in the history
…ed debugging
  • Loading branch information
ThijsSassen authored and eboasson committed Oct 21, 2024
1 parent 5c1a44f commit 447912e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ function(PREPEND var prefix)
set(${var} "${listVar}" PARENT_SCOPE)
endfunction()

# default to unknown
set(CYCLONEDDS_GIT_HASH "unknown")

# find latest hash and set it
find_package(Git QUIET)
if(GIT_FOUND)
execute_process(
COMMAND git log -1 --pretty=format:%h
OUTPUT_VARIABLE CYCLONEDDS_GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
endif()

option(ENABLE_SECURITY "Enable OMG DDS Security support" ON)
option(ENABLE_LIFESPAN "Enable Lifespan QoS support" ON)
option(ENABLE_DEADLINE_MISSED "Enable Deadline Missed QoS support" ON)
Expand Down
2 changes: 2 additions & 0 deletions src/core/ddsi/src/ddsi_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "dds/ddsrt/string.h"
#include "dds/ddsrt/sync.h"
#include "dds/ddsrt/avl.h"
#include "dds/version.h"

#include "dds/ddsi/ddsi_init.h"
#include "dds/ddsi/ddsi_log.h"
Expand Down Expand Up @@ -1148,6 +1149,7 @@ int ddsi_init (struct ddsi_domaingv *gv, struct ddsi_psmx_instance_locators *psm
char str[DDSRT_RFC3339STRLEN+1];
ddsrt_ctime(gv->tstart.v, str, sizeof(str));
GVLOG (DDS_LC_CONFIG, "started at %d.06%d -- %s\n", sec, usec, str);
GVLOG (DDS_LC_CONFIG, "Version: %s %s %s \n", DDS_PROJECT_NAME, DDS_VERSION, DDS_GIT_HASH);
}

/* Allow configuration to set "deaf_mute" in case we want to start out that way */
Expand Down
1 change: 1 addition & 0 deletions src/ddsrt/include/dds/version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define DDS_VERSION_PATCH @CycloneDDS_VERSION_PATCH@
#define DDS_VERSION_TWEAK @CycloneDDS_VERSION_TWEAK@
#define DDS_PROJECT_NAME "@PROJECT_NAME@"
#define DDS_GIT_HASH "@CYCLONEDDS_GIT_HASH@"

#define DDS_HOST_NAME "@CMAKE_HOST_SYSTEM_NAME@"
#define DDS_TARGET_NAME "@CMAKE_SYSTEM_NAME@"
Expand Down

0 comments on commit 447912e

Please sign in to comment.