diff --git a/CHANGELOG.md b/CHANGELOG.md index cdc2f6c..f1093a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - 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 diff --git a/CMakeLists.txt b/CMakeLists.txt index a625a7d..8816489 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,11 @@ set(CMAKE_C_EXTENSIONS FALSE) option(ENABLE_DEBUG_LOG "Enable debug messages (very verbose)") 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) add_definitions(-DENABLE_DEBUG) diff --git a/include/ovni.h.in b/include/ovni.h.in index 9fb9aa1..d1907db 100644 --- a/include/ovni.h.in +++ b/include/ovni.h.in @@ -37,6 +37,7 @@ typedef struct json_value_t JSON_Value; /* Follow https://semver.org rules for versioning */ #define OVNI_LIB_VERSION "@PROJECT_VERSION@" +#define OVNI_GIT_COMMIT "@OVNI_GIT_COMMIT@" /* ----------------------- common ------------------------ */ @@ -129,7 +130,7 @@ struct ovni_rproc { #define ovni_version_check() ovni_version_check_str(OVNI_LIB_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); diff --git a/src/emu/ovniver.c b/src/emu/ovniver.c index 41c6b7a..6cc06e5 100644 --- a/src/emu/ovniver.c +++ b/src/emu/ovniver.c @@ -7,8 +7,12 @@ int main(void) { - printf("libovni version compiled %s, dynamic %s\n", - OVNI_LIB_VERSION, ovni_version_get()); + const char *version, *commit; + 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; } diff --git a/src/rt/ovni.c b/src/rt/ovni.c index 4ef8603..1a2e947 100644 --- a/src/rt/ovni.c +++ b/src/rt/ovni.c @@ -23,10 +23,11 @@ struct ovni_rproc rproc = {0}; /* Data per thread */ _Thread_local struct ovni_rthread rthread = {0}; -const char * -ovni_version_get(void) +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)