Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new executable flag to check if main or release version #1038

Merged
merged 6 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
13 changes: 13 additions & 0 deletions source/server/core_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "windows/console_ctrl_handler.h"
#endif

#include "version.h"

using FeatureState = nidevice_grpc::FeatureToggles::FeatureState;

struct ServerConfiguration {
Expand Down Expand Up @@ -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];
}
Expand Down
1 change: 1 addition & 0 deletions source/server/version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace nidevice_grpc {

static constexpr const char* kNiDeviceGrpcFileVersion = "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@[email protected]";
static constexpr const char* kNiDeviceGrpcOriginalFileName = "ni_grpc_device_server.exe";
static constexpr const char* kNiDeviceGrpcBranchName = "@GIT_BRANCH@";
christag-ni marked this conversation as resolved.
Show resolved Hide resolved

}

Expand Down
Loading