diff --git a/CMakeLists.txt b/CMakeLists.txt index daf05d31a6f21918aec1eb2575360b017f8208d0..98e95ca60c75143ef6762720fcfaddb913d33ec3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,17 @@ SET(CMAKE_INSTALL_PREFIX "/opt/${PROJECT_NAME}") SET(CPACK_INSTALL_PREFIX "/opt/${PROJECT_NAME}") SET(DESTDIR "/opt/${PROJECT_NAME}") +string(TIMESTAMP BUILD_TIMESTAMP "%d.%m.%Y") + +execute_process( + COMMAND git log -1 --format=%h + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_COMMIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE + ) +message("Build date: ${BUILD_TIMESTAMP}") +message("Git SHA: ${GIT_COMMIT_HASH}") + #SET(DAP_PQLR OFF) #possible need be setted during crosscompily #by default it uses dpkg --print-architecture @@ -32,6 +43,8 @@ SET(DESTDIR "/opt/${PROJECT_NAME}") # init CellFrame SDK add_definitions("-DDAP_VERSION=\"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}-${CPACK_PACKAGE_VERSION_PATCH}\"") +add_definitions("-DBUILD_TS=\"${BUILD_TIMESTAMP}\"") +add_definitions("-DBUILD_HASH=\"${GIT_COMMIT_HASH}\"") set(SUBMODULES_NO_BUILD ON) option(CELLFRAME_NO_OPTIMIZATION "Build without BMI BMI2 CPU instruction." ON) diff --git a/cellframe-sdk b/cellframe-sdk index d9b98ddabb638b53a96c1437d3c788e140330c90..e79d51990e85a470b2bed6783c246d569682281e 160000 --- a/cellframe-sdk +++ b/cellframe-sdk @@ -1 +1 @@ -Subproject commit d9b98ddabb638b53a96c1437d3c788e140330c90 +Subproject commit e79d51990e85a470b2bed6783c246d569682281e diff --git a/sources/cellframe-node.c b/sources/cellframe-node.c index 36dab5dda0b34adbd780ebedc0ce4550b147ec3d..a043b422c68b484335af2a75a3616dd2b15311c8 100755 --- a/sources/cellframe-node.c +++ b/sources/cellframe-node.c @@ -145,6 +145,9 @@ void set_global_sys_dir(const char *dir) int main( int argc, const char **argv ) { + if ( argv[1] && !dap_strcmp("-version", argv[1]) ) + return printf("%s\n", dap_node_version()), 0; + dap_server_t *l_server = NULL; // DAP Server instance bool l_debug_mode = true; bool bServerEnabled = false; @@ -607,3 +610,14 @@ void exit_if_server_already_running( void ) { #endif } +#ifndef BUILD_HASH +#define BUILD_HASH "0000000" // 0000000 means uninitialized +#endif + +#ifndef BUILD_TS +#define BUILD_TS "undefined" +#endif + +const char *dap_node_version() { + return "CellframeNode, " DAP_VERSION ", " BUILD_TS ", " BUILD_HASH; +} \ No newline at end of file diff --git a/sources/cellframe-node.h b/sources/cellframe-node.h index 4519196419d00c14859c5d4e4b2c8f8af893de93..f3677cbbac0a67cb6ac68c95d9cb6a87aab7b3ac 100644 --- a/sources/cellframe-node.h +++ b/sources/cellframe-node.h @@ -13,6 +13,7 @@ void set_global_sys_dir(const char *dir); typedef bool (*dap_notify_data_user_callback_t)(const char *data); void dap_notify_data_set_user_callback(dap_notify_data_user_callback_t callback); char *dap_cli_exec(int argc, char **argv); +const char *dap_node_version(); }; #endif //NODE_CELLFRAME_NODE_H