From e4d38552514efcd81f18ccfad41ec57d1fd8f4d5 Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Mon, 6 Dec 2021 07:53:50 -0800 Subject: [PATCH] Adding git hash --- CMakeLists.txt | 18 +++++++++++++++++- build | 2 +- src/framework/MicroService.h | 7 ++++--- src/ow_version.h.in | 13 +++++++++++++ 4 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 src/ow_version.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f9ddfb..5f3de31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,9 +30,22 @@ else() file(WRITE build ${BUILD_NUM}) endif() +find_package(Git QUIET) +if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") + execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --tags + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE GIT_RESULT + OUTPUT_VARIABLE GIT_HASH) + if(NOT GIT_RESULT EQUAL "0") + message(FATAL_ERROR "git describe --always --tags failed with ${GIT_RESULT}") + endif() + string(REGEX REPLACE "\n$" "" GIT_HASH "${GIT_HASH}") +endif() + +add_definitions(-DAWS_CUSTOM_MEMORY_MANAGEMENT) + set(BUILD_SHARED_LIBS 1) -add_definitions(-DAPP_VERSION="${CMAKE_PROJECT_VERSION}" -DBUILD_NUMBER="${BUILD_NUM}") add_definitions(-DTIP_SECURITY_SERVICE="1") set(Boost_USE_STATIC_LIBS OFF) @@ -50,8 +63,11 @@ find_package(Poco REQUIRED COMPONENTS JSON Crypto JWT Net Util NetSSL Data DataS include_directories(/usr/local/include /usr/local/opt/openssl/include src include/kafka /usr/local/opt/mysql-client/include) +configure_file(src/ow_version.h.in ${PROJECT_SOURCE_DIR}/src/ow_version.h @ONLY) + add_executable( owsec build + src/ow_version.h.in src/framework/CountryCodes.h src/framework/KafkaTopics.h src/framework/MicroService.h diff --git a/build b/build index e77a963..eb13855 100644 --- a/build +++ b/build @@ -1 +1 @@ -73 \ No newline at end of file +79 \ No newline at end of file diff --git a/src/framework/MicroService.h b/src/framework/MicroService.h index ac289f6..8520619 100644 --- a/src/framework/MicroService.h +++ b/src/framework/MicroService.h @@ -71,6 +71,8 @@ using namespace std::chrono_literals; #include "RESTObjects/RESTAPI_SecurityObjects.h" #include "nlohmann/json.hpp" +#include "ow_version.h" + namespace OpenWifi { enum UNAUTHORIZED_REASON { @@ -881,8 +883,7 @@ namespace OpenWifi::Utils { [[nodiscard]] inline bool ValidEMailAddress(const std::string &email) { // define a regular expression static const std::regex pattern -// ("(\\w+)(\\.|_)?(\\w*)@(\\w+)(\\.(\\w+))+"); - ("(\\w+)(\\.|_\\+)?(\\w*)@(\\w+)(\\.(\\w+))+"); + (("(\\w+)(\\.|_\\+)?(\\w*)@(\\w+)(\\.(\\w+))+")); // try to match the string with the regular expression return std::regex_match(email, pattern); @@ -2695,7 +2696,7 @@ namespace OpenWifi { std::string MyPrivateEndPoint_; std::string MyPublicEndPoint_; std::string UIURI_; - std::string Version_{std::string(APP_VERSION) + "("+ BUILD_NUMBER + ")"}; + std::string Version_{ OW_VERSION::VERSION + "("+ OW_VERSION::BUILD + ")" + " - " + OW_VERSION::HASH }; BusEventManager BusEventManager_; std::mutex InfraMutex_; std::default_random_engine RandomEngine_; diff --git a/src/ow_version.h.in b/src/ow_version.h.in new file mode 100644 index 0000000..f61c19e --- /dev/null +++ b/src/ow_version.h.in @@ -0,0 +1,13 @@ +// +// Created by stephane bourque on 2021-12-06. +// + +#pragma once + +#include + +namespace OW_VERSION { + inline static const std::string VERSION{"@CMAKE_PROJECT_VERSION@"}; + inline static const std::string BUILD{"@BUILD_NUM@"}; + inline static const std::string HASH{"@GIT_HASH@"}; +} \ No newline at end of file