Report the commit too with ovniver

This commit is contained in:
Rodrigo Arias 2023-07-26 17:13:28 +02:00
parent bf8a2213c1
commit a3ffb2443a
5 changed files with 18 additions and 7 deletions

View File

@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- Add `ovni_version_get()` function. - Add `ovni_version_get()` function.
- Add the `ovniver` program to report the `libovni.so` version. - Add the `ovniver` program to report the libovni version and commit.
## [1.2.2] - 2022-07-26 ## [1.2.2] - 2022-07-26

View File

@ -22,6 +22,11 @@ set(CMAKE_C_EXTENSIONS FALSE)
option(ENABLE_DEBUG_LOG "Enable debug messages (very verbose)") option(ENABLE_DEBUG_LOG "Enable debug messages (very verbose)")
option(ENABLE_ALL_TESTS "Forces the execution of all tests") option(ENABLE_ALL_TESTS "Forces the execution of all tests")
set(OVNI_GIT_COMMIT "unknown" CACHE STRING "Set the git commit")
if("${OVNI_GIT_COMMIT}" STREQUAL "unknown")
message(WARNING "OVNI_GIT_COMMIT is unknown, please specify the git commit")
endif()
if(ENABLE_DEBUG_LOG) if(ENABLE_DEBUG_LOG)
add_definitions(-DENABLE_DEBUG) add_definitions(-DENABLE_DEBUG)

View File

@ -37,6 +37,7 @@ typedef struct json_value_t JSON_Value;
/* Follow https://semver.org rules for versioning */ /* Follow https://semver.org rules for versioning */
#define OVNI_LIB_VERSION "@PROJECT_VERSION@" #define OVNI_LIB_VERSION "@PROJECT_VERSION@"
#define OVNI_GIT_COMMIT "@OVNI_GIT_COMMIT@"
/* ----------------------- common ------------------------ */ /* ----------------------- common ------------------------ */
@ -129,7 +130,7 @@ struct ovni_rproc {
#define ovni_version_check() ovni_version_check_str(OVNI_LIB_VERSION) #define ovni_version_check() ovni_version_check_str(OVNI_LIB_VERSION)
void ovni_version_check_str(const char *version); void ovni_version_check_str(const char *version);
const char *ovni_version_get(void); void ovni_version_get(const char **version, const char **commit);
void ovni_proc_init(int app, const char *loom, int pid); void ovni_proc_init(int app, const char *loom, int pid);

View File

@ -7,8 +7,12 @@
int int
main(void) main(void)
{ {
printf("libovni version compiled %s, dynamic %s\n", const char *version, *commit;
OVNI_LIB_VERSION, ovni_version_get()); ovni_version_get(&version, &commit);
printf("libovni: build v%s (%s), dynamic v%s (%s)\n",
OVNI_LIB_VERSION, OVNI_GIT_COMMIT,
version, commit);
return 0; return 0;
} }

View File

@ -23,10 +23,11 @@ struct ovni_rproc rproc = {0};
/* Data per thread */ /* Data per thread */
_Thread_local struct ovni_rthread rthread = {0}; _Thread_local struct ovni_rthread rthread = {0};
const char * void
ovni_version_get(void) ovni_version_get(const char **version, const char **commit)
{ {
return OVNI_LIB_VERSION; *version = OVNI_LIB_VERSION;
*commit = OVNI_GIT_COMMIT;
} }
void ovni_version_check_str(const char *version) void ovni_version_check_str(const char *version)