From bc98f3b06df224bde3db31fd4a604dae1177fb21 Mon Sep 17 00:00:00 2001 From: Christian Aguilar Date: Wed, 31 Jan 2024 10:09:35 -0600 Subject: [PATCH 1/5] now prints version and 'dev' if 'releases' is not in branch name --- CMakeLists.txt | 7 +++++++ generated/version.h | 1 + source/server/core_server.cpp | 13 +++++++++++++ source/server/version.h.in | 1 + 4 files changed, 22 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index fac1027ee..c0934dd63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -425,6 +425,13 @@ if(WIN32) ) endif() +execute_process( + COMMAND git rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE +) + # Generate version header file # This file requires product name and version info that mako does not know, but CMake does configure_file( diff --git a/generated/version.h b/generated/version.h index cf2b266ab..e08bfdd43 100644 --- a/generated/version.h +++ b/generated/version.h @@ -5,6 +5,7 @@ namespace nidevice_grpc { static constexpr const char* kNiDeviceGrpcFileVersion = "2.5.0.0"; static constexpr const char* kNiDeviceGrpcOriginalFileName = "ni_grpc_device_server.exe"; +static constexpr const char* kNiDeviceGrpcBranchName = "users/christag-ni/noteDevWithCommand"; } diff --git a/source/server/core_server.cpp b/source/server/core_server.cpp index 8d5b4dd84..3c97a1451 100644 --- a/source/server/core_server.cpp +++ b/source/server/core_server.cpp @@ -17,6 +17,8 @@ #include "windows/console_ctrl_handler.h" #endif +#include "version.h" + using FeatureState = nidevice_grpc::FeatureToggles::FeatureState; struct ServerConfiguration { @@ -185,6 +187,17 @@ Options parse_options(int argc, char** argv) nidevice_grpc::logging::log(nidevice_grpc::logging::Level_Info, usage); exit(EXIT_SUCCESS); } + else if (strcmp("--version", argv[i]) == 0) { + std::string string_kNiDeviceGrpcBranchName(nidevice_grpc::kNiDeviceGrpcBranchName); + if (string_kNiDeviceGrpcBranchName.rfind("releases", 0) == 0) { + nidevice_grpc::logging::log(nidevice_grpc::logging::Level_Info, nidevice_grpc::kNiDeviceGrpcFileVersion); + } + else { + nidevice_grpc::logging::log(nidevice_grpc::logging::Level_Info, nidevice_grpc::kNiDeviceGrpcFileVersion); + nidevice_grpc::logging::log(nidevice_grpc::logging::Level_Info, "dev"); + } + exit(EXIT_SUCCESS); + } else if (i == argc - 1) { options.config_file_path = argv[i]; } diff --git a/source/server/version.h.in b/source/server/version.h.in index d50bb4d9a..82eae2d85 100644 --- a/source/server/version.h.in +++ b/source/server/version.h.in @@ -5,6 +5,7 @@ namespace nidevice_grpc { static constexpr const char* kNiDeviceGrpcFileVersion = "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@.0"; static constexpr const char* kNiDeviceGrpcOriginalFileName = "ni_grpc_device_server.exe"; +static constexpr const char* kNiDeviceGrpcBranchName = "@GIT_BRANCH@"; } From 278842b02e92dd2460438ff43329468194ae71cb Mon Sep 17 00:00:00 2001 From: Christian Aguilar Date: Wed, 31 Jan 2024 13:25:10 -0600 Subject: [PATCH 2/5] updated version.h file to not have generated branch name, should get overwriten either way --- generated/version.h | 1 - 1 file changed, 1 deletion(-) diff --git a/generated/version.h b/generated/version.h index e08bfdd43..cf2b266ab 100644 --- a/generated/version.h +++ b/generated/version.h @@ -5,7 +5,6 @@ namespace nidevice_grpc { static constexpr const char* kNiDeviceGrpcFileVersion = "2.5.0.0"; static constexpr const char* kNiDeviceGrpcOriginalFileName = "ni_grpc_device_server.exe"; -static constexpr const char* kNiDeviceGrpcBranchName = "users/christag-ni/noteDevWithCommand"; } From 13e2cc8ae5cfd875a835219277d024db8d156190 Mon Sep 17 00:00:00 2001 From: Christian Aguilar Date: Tue, 6 Feb 2024 14:21:35 -0600 Subject: [PATCH 3/5] added version.h to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f76fdb680..2e247ec75 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ gens .vscode __pycache__/ .venv +/generated/version.h From e7dc6c69ebe07d880a6ee49af77cc003e69f23ee Mon Sep 17 00:00:00 2001 From: Christian Aguilar Date: Thu, 8 Feb 2024 09:11:26 -0600 Subject: [PATCH 4/5] intermediate commit to remove history of version.h --- .gitignore | 1 - generated/version.h | 11 ----------- 2 files changed, 12 deletions(-) delete mode 100644 generated/version.h diff --git a/.gitignore b/.gitignore index 2e247ec75..f76fdb680 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,3 @@ gens .vscode __pycache__/ .venv -/generated/version.h diff --git a/generated/version.h b/generated/version.h deleted file mode 100644 index cf2b266ab..000000000 --- a/generated/version.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef NIDEVICE_GRPC_VERSION_H -#define NIDEVICE_GRPC_VERSION_H - -namespace nidevice_grpc { - -static constexpr const char* kNiDeviceGrpcFileVersion = "2.5.0.0"; -static constexpr const char* kNiDeviceGrpcOriginalFileName = "ni_grpc_device_server.exe"; - -} - -#endif // NIDEVICE_GRPC_VERSION_H From 85e8da8c1371d59f7b170e528c6a5ae7e60b7915 Mon Sep 17 00:00:00 2001 From: Christian Aguilar Date: Thu, 8 Feb 2024 09:13:07 -0600 Subject: [PATCH 5/5] added version.h to .gitignore, with no history of file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f76fdb680..2e247ec75 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ gens .vscode __pycache__/ .venv +/generated/version.h