diff --git a/CMakeLists.txt b/CMakeLists.txt index bf74adebd..26fe927dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -425,6 +425,18 @@ if(WIN32) ) endif() +# Generate version header file +# This file requires product name and version info that mako does not know, but CMake does +configure_file( + source/server/version.h.in + ${service_output_dir}/version.h + @ONLY) + +target_sources(ni_grpc_device_server + PUBLIC "${service_output_dir}/version.h" +) + + if(CMAKE_SYSTEM_NAME STREQUAL Linux) target_sources(ni_grpc_device_server PRIVATE "source/server/linux/syslog_logging.cpp" diff --git a/generated/nidcpower/nidcpower_library.cpp b/generated/nidcpower/nidcpower_library.cpp index a93521f8e..8313705f6 100644 --- a/generated/nidcpower/nidcpower_library.cpp +++ b/generated/nidcpower/nidcpower_library.cpp @@ -4,6 +4,7 @@ // Service implementation for the NI-DCPower Metadata //--------------------------------------------------------------------- #include "nidcpower_library.h" +#include "version.h" #if defined(_MSC_VER) static const char* kLibraryName = "nidcpower_64.dll"; @@ -169,6 +170,11 @@ NiDCPowerLibrary::NiDCPowerLibrary() : shared_library_(kLibraryName) function_pointers_.UnlockSession = reinterpret_cast(shared_library_.get_function_pointer("niDCPower_UnlockSession")); function_pointers_.WaitForEvent = reinterpret_cast(shared_library_.get_function_pointer("niDCPower_WaitForEvent")); function_pointers_.WaitForEventWithChannels = reinterpret_cast(shared_library_.get_function_pointer("niDCPower_WaitForEventWithChannels")); + function_pointers_.SetRuntimeEnvironment = reinterpret_cast(shared_library_.get_function_pointer("niDCPower_SetRuntimeEnvironment")); + + if (function_pointers_.SetRuntimeEnvironment) { + this->SetRuntimeEnvironment(nidevice_grpc::kNiDeviceGrpcOriginalFileName, nidevice_grpc::kNiDeviceGrpcFileVersion, "", ""); + } } NiDCPowerLibrary::~NiDCPowerLibrary() @@ -1366,4 +1372,12 @@ ViStatus NiDCPowerLibrary::WaitForEventWithChannels(ViSession vi, ViConstString return function_pointers_.WaitForEventWithChannels(vi, channelName, eventId, timeout); } +ViStatus NiDCPowerLibrary::SetRuntimeEnvironment(ViConstString environment, ViConstString environmentVersion, ViConstString reserved1, ViConstString reserved2) +{ + if (!function_pointers_.SetRuntimeEnvironment) { + throw nidevice_grpc::LibraryLoadException("Could not find niDCPower_SetRuntimeEnvironment."); + } + return function_pointers_.SetRuntimeEnvironment(environment, environmentVersion, reserved1, reserved2); +} + } // namespace nidcpower_grpc diff --git a/generated/nidcpower/nidcpower_library.h b/generated/nidcpower/nidcpower_library.h index 6ae9bd49b..95a8c5944 100644 --- a/generated/nidcpower/nidcpower_library.h +++ b/generated/nidcpower/nidcpower_library.h @@ -166,6 +166,7 @@ class NiDCPowerLibrary : public nidcpower_grpc::NiDCPowerLibraryInterface { ViStatus UnlockSession(ViSession vi, ViBoolean* callerHasLock); ViStatus WaitForEvent(ViSession vi, ViInt32 eventId, ViReal64 timeout); ViStatus WaitForEventWithChannels(ViSession vi, ViConstString channelName, ViInt32 eventId, ViReal64 timeout); + ViStatus SetRuntimeEnvironment(ViConstString environment, ViConstString environmentVersion, ViConstString reserved1, ViConstString reserved2); private: using AbortPtr = decltype(&niDCPower_Abort); @@ -316,6 +317,7 @@ class NiDCPowerLibrary : public nidcpower_grpc::NiDCPowerLibraryInterface { using UnlockSessionPtr = ViStatus (*)(ViSession vi, ViBoolean* callerHasLock); using WaitForEventPtr = decltype(&niDCPower_WaitForEvent); using WaitForEventWithChannelsPtr = decltype(&niDCPower_WaitForEventWithChannels); + using SetRuntimeEnvironmentPtr = ViStatus (*)(ViConstString environment, ViConstString environmentVersion, ViConstString reserved1, ViConstString reserved2); typedef struct FunctionPointers { AbortPtr Abort; @@ -466,6 +468,7 @@ class NiDCPowerLibrary : public nidcpower_grpc::NiDCPowerLibraryInterface { UnlockSessionPtr UnlockSession; WaitForEventPtr WaitForEvent; WaitForEventWithChannelsPtr WaitForEventWithChannels; + SetRuntimeEnvironmentPtr SetRuntimeEnvironment; } FunctionLoadStatus; nidevice_grpc::SharedLibrary shared_library_; diff --git a/generated/nidcpower/nidcpower_library_interface.h b/generated/nidcpower/nidcpower_library_interface.h index d082e7815..2be7d920d 100644 --- a/generated/nidcpower/nidcpower_library_interface.h +++ b/generated/nidcpower/nidcpower_library_interface.h @@ -163,6 +163,7 @@ class NiDCPowerLibraryInterface { virtual ViStatus UnlockSession(ViSession vi, ViBoolean* callerHasLock) = 0; virtual ViStatus WaitForEvent(ViSession vi, ViInt32 eventId, ViReal64 timeout) = 0; virtual ViStatus WaitForEventWithChannels(ViSession vi, ViConstString channelName, ViInt32 eventId, ViReal64 timeout) = 0; + virtual ViStatus SetRuntimeEnvironment(ViConstString environment, ViConstString environmentVersion, ViConstString reserved1, ViConstString reserved2) = 0; }; } // namespace nidcpower_grpc diff --git a/generated/nidcpower/nidcpower_mock_library.h b/generated/nidcpower/nidcpower_mock_library.h index c2af1af1f..03bbf4412 100644 --- a/generated/nidcpower/nidcpower_mock_library.h +++ b/generated/nidcpower/nidcpower_mock_library.h @@ -165,6 +165,7 @@ class NiDCPowerMockLibrary : public nidcpower_grpc::NiDCPowerLibraryInterface { MOCK_METHOD(ViStatus, UnlockSession, (ViSession vi, ViBoolean* callerHasLock), (override)); MOCK_METHOD(ViStatus, WaitForEvent, (ViSession vi, ViInt32 eventId, ViReal64 timeout), (override)); MOCK_METHOD(ViStatus, WaitForEventWithChannels, (ViSession vi, ViConstString channelName, ViInt32 eventId, ViReal64 timeout), (override)); + MOCK_METHOD(ViStatus, SetRuntimeEnvironment, (ViConstString environment, ViConstString environmentVersion, ViConstString reserved1, ViConstString reserved2), (override)); }; } // namespace unit diff --git a/generated/version.h b/generated/version.h new file mode 100644 index 000000000..9da828da7 --- /dev/null +++ b/generated/version.h @@ -0,0 +1,11 @@ +#ifndef NIDEVICE_GRPC_VERSION_H +#define NIDEVICE_GRPC_VERSION_H + +namespace nidevice_grpc { + +static constexpr const char* kNiDeviceGrpcFileVersion = "2.3.0.0"; +static constexpr const char* kNiDeviceGrpcOriginalFileName = "ni_grpc_device_server.exe"; + +} + +#endif // NIDEVICE_GRPC_VERSION_H diff --git a/source/codegen/metadata/nidcpower/__init__.py b/source/codegen/metadata/nidcpower/__init__.py index 479c7c96a..505b7843d 100644 --- a/source/codegen/metadata/nidcpower/__init__.py +++ b/source/codegen/metadata/nidcpower/__init__.py @@ -1,6 +1,9 @@ from .functions import functions +from .functions_addon import functions_override_metadata from .attributes import attributes +from .attributes_addon import attributes_override_metadata from .enums import enums +from .enums_addon import enums_override_metadata from .config import config metadata = { @@ -8,4 +11,8 @@ "attributes" : attributes, "enums" : enums, "config" : config -} \ No newline at end of file +} + +metadata['functions'].update(functions_override_metadata) +metadata['attributes'].update(attributes_override_metadata) +metadata['enums'].update(enums_override_metadata) \ No newline at end of file diff --git a/source/codegen/metadata/nidcpower/functions_addon.py b/source/codegen/metadata/nidcpower/functions_addon.py index 03bd3b115..4f881393c 100644 --- a/source/codegen/metadata/nidcpower/functions_addon.py +++ b/source/codegen/metadata/nidcpower/functions_addon.py @@ -2,4 +2,38 @@ # Changes to the metadata should be made here, because functions.py is generated thus any changes get overwritten. functions_override_metadata = { + 'SetRuntimeEnvironment': { + 'codegen_method': 'private', + 'parameters': [ + { + 'cppName': 'environment', + 'direction': 'in', + 'grpc_type': 'string', + 'name': 'environment', + 'type': 'ViConstString' + }, + { + 'cppName': 'environmentVersion', + 'direction': 'in', + 'grpc_type': 'string', + 'name': 'environmentVersion', + 'type': 'ViConstString' + }, + { + 'cppName': 'reserved1', + 'direction': 'in', + 'grpc_type': 'string', + 'name': 'reserved1', + 'type': 'ViConstString' + }, + { + 'cppName': 'reserved2', + 'direction': 'in', + 'grpc_type': 'string', + 'name': 'reserved2', + 'type': 'ViConstString' + } + ], + 'returns': 'ViStatus' + }, } \ No newline at end of file diff --git a/source/codegen/templates/library.cpp.mako b/source/codegen/templates/library.cpp.mako index 5bae34e65..7795c126c 100644 --- a/source/codegen/templates/library.cpp.mako +++ b/source/codegen/templates/library.cpp.mako @@ -21,6 +21,9 @@ windows_library_name = windows_library_info['name'] // Service implementation for the ${config["driver_name"]} Metadata //--------------------------------------------------------------------- #include "${module_name}_library.h" +% if 'SetRuntimeEnvironment' in service_helpers.filter_api_functions(functions, only_mockable_functions=False): +#include "version.h" +% endif #if defined(_MSC_VER) static const char* kLibraryName = "${windows_library_name}"; @@ -44,6 +47,12 @@ ${service_class_prefix}Library::${service_class_prefix}Library() : shared_librar %>\ function_pointers_.${method_name} = reinterpret_cast<${method_name}Ptr>(shared_library_.get_function_pointer("${c_name}")); % endfor +% if 'SetRuntimeEnvironment' in service_helpers.filter_api_functions(functions, only_mockable_functions=False): + + if (function_pointers_.SetRuntimeEnvironment) { + this->SetRuntimeEnvironment(nidevice_grpc::kNiDeviceGrpcOriginalFileName, nidevice_grpc::kNiDeviceGrpcFileVersion, "", ""); + } +% endif } ${service_class_prefix}Library::~${service_class_prefix}Library() diff --git a/source/server/version.h.in b/source/server/version.h.in new file mode 100644 index 000000000..c2c3ab499 --- /dev/null +++ b/source/server/version.h.in @@ -0,0 +1,11 @@ +#ifndef NIDEVICE_GRPC_VERSION_H +#define NIDEVICE_GRPC_VERSION_H + +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"; + +} + +#endif // NIDEVICE_GRPC_VERSION_H \ No newline at end of file