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 ee0d0205c..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"; @@ -170,6 +171,10 @@ NiDCPowerLibrary::NiDCPowerLibrary() : shared_library_(kLibraryName) 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() diff --git a/generated/nidigitalpattern/nidigitalpattern_library.cpp b/generated/nidigitalpattern/nidigitalpattern_library.cpp index a7b38d785..f70faa875 100644 --- a/generated/nidigitalpattern/nidigitalpattern_library.cpp +++ b/generated/nidigitalpattern/nidigitalpattern_library.cpp @@ -4,6 +4,7 @@ // Service implementation for the NI-Digital Pattern Driver Metadata //--------------------------------------------------------------------- #include "nidigitalpattern_library.h" +#include "version.h" #if defined(_MSC_VER) static const char* kLibraryName = "niDigital_64.dll"; @@ -154,6 +155,10 @@ NiDigitalLibrary::NiDigitalLibrary() : shared_library_(kLibraryName) function_pointers_.WriteSourceWaveformSiteUniqueU32 = reinterpret_cast(shared_library_.get_function_pointer("niDigital_WriteSourceWaveformSiteUniqueU32")); function_pointers_.WriteStatic = reinterpret_cast(shared_library_.get_function_pointer("niDigital_WriteStatic")); function_pointers_.SetRuntimeEnvironment = reinterpret_cast(shared_library_.get_function_pointer("niDigital_SetRuntimeEnvironment")); + + if (function_pointers_.SetRuntimeEnvironment) { + this->SetRuntimeEnvironment(nidevice_grpc::kNiDeviceGrpcOriginalFileName, nidevice_grpc::kNiDeviceGrpcFileVersion, "", ""); + } } NiDigitalLibrary::~NiDigitalLibrary() diff --git a/generated/nidmm/nidmm_library.cpp b/generated/nidmm/nidmm_library.cpp index 34a79fce5..bb07413cd 100644 --- a/generated/nidmm/nidmm_library.cpp +++ b/generated/nidmm/nidmm_library.cpp @@ -4,6 +4,7 @@ // Service implementation for the NI-DMM Metadata //--------------------------------------------------------------------- #include "nidmm_library.h" +#include "version.h" #if defined(_MSC_VER) static const char* kLibraryName = "nidmm_64.dll"; @@ -111,6 +112,10 @@ NiDmmLibrary::NiDmmLibrary() : shared_library_(kLibraryName) function_pointers_.SetAttributeViString = reinterpret_cast(shared_library_.get_function_pointer("niDMM_SetAttributeViString")); function_pointers_.UnlockSession = reinterpret_cast(shared_library_.get_function_pointer("niDMM_UnlockSession")); function_pointers_.SetRuntimeEnvironment = reinterpret_cast(shared_library_.get_function_pointer("niDMM_SetRuntimeEnvironment")); + + if (function_pointers_.SetRuntimeEnvironment) { + this->SetRuntimeEnvironment(nidevice_grpc::kNiDeviceGrpcOriginalFileName, nidevice_grpc::kNiDeviceGrpcFileVersion, "", ""); + } } NiDmmLibrary::~NiDmmLibrary() diff --git a/generated/nifake/nifake_library.cpp b/generated/nifake/nifake_library.cpp index f3c7fda11..4c0d64415 100644 --- a/generated/nifake/nifake_library.cpp +++ b/generated/nifake/nifake_library.cpp @@ -4,6 +4,7 @@ // Service implementation for the NI-FAKE Metadata //--------------------------------------------------------------------- #include "nifake_library.h" +#include "version.h" #if defined(_MSC_VER) static const char* kLibraryName = "nifake_64.dll"; @@ -115,6 +116,10 @@ NiFakeLibrary::NiFakeLibrary() : shared_library_(kLibraryName) function_pointers_.ViUInt8ArrayOutputFunction = reinterpret_cast(shared_library_.get_function_pointer("niFake_ViUInt8ArrayOutputFunction")); function_pointers_.WriteWaveform = reinterpret_cast(shared_library_.get_function_pointer("niFake_WriteWaveform")); function_pointers_.SetRuntimeEnvironment = reinterpret_cast(shared_library_.get_function_pointer("niFake_SetRuntimeEnvironment")); + + if (function_pointers_.SetRuntimeEnvironment) { + this->SetRuntimeEnvironment(nidevice_grpc::kNiDeviceGrpcOriginalFileName, nidevice_grpc::kNiDeviceGrpcFileVersion, "", ""); + } } NiFakeLibrary::~NiFakeLibrary() diff --git a/generated/nifgen/nifgen_library.cpp b/generated/nifgen/nifgen_library.cpp index c25b796ab..94f120661 100644 --- a/generated/nifgen/nifgen_library.cpp +++ b/generated/nifgen/nifgen_library.cpp @@ -4,6 +4,7 @@ // Service implementation for the NI-FGEN Metadata //--------------------------------------------------------------------- #include "nifgen_library.h" +#include "version.h" #if defined(_MSC_VER) static const char* kLibraryName = "niFgen_64.dll"; @@ -155,6 +156,10 @@ NiFgenLibrary::NiFgenLibrary() : shared_library_(kLibraryName) function_pointers_.WriteWaveform = reinterpret_cast(shared_library_.get_function_pointer("niFgen_WriteWaveform")); function_pointers_.WriteWaveformComplexF64 = reinterpret_cast(shared_library_.get_function_pointer("niFgen_WriteWaveformComplexF64")); function_pointers_.SetRuntimeEnvironment = reinterpret_cast(shared_library_.get_function_pointer("niFgen_SetRuntimeEnvironment")); + + if (function_pointers_.SetRuntimeEnvironment) { + this->SetRuntimeEnvironment(nidevice_grpc::kNiDeviceGrpcOriginalFileName, nidevice_grpc::kNiDeviceGrpcFileVersion, "", ""); + } } NiFgenLibrary::~NiFgenLibrary() diff --git a/generated/niscope/niscope_library.cpp b/generated/niscope/niscope_library.cpp index ca13aa7e7..0a60c895b 100644 --- a/generated/niscope/niscope_library.cpp +++ b/generated/niscope/niscope_library.cpp @@ -4,6 +4,7 @@ // Service implementation for the NI-SCOPE Metadata //--------------------------------------------------------------------- #include "niscope_library.h" +#include "version.h" #if defined(_MSC_VER) static const char* kLibraryName = "niScope_64.dll"; @@ -114,6 +115,10 @@ NiScopeLibrary::NiScopeLibrary() : shared_library_(kLibraryName) function_pointers_.SetAttributeViString = reinterpret_cast(shared_library_.get_function_pointer("niScope_SetAttributeViString")); function_pointers_.UnlockSession = reinterpret_cast(shared_library_.get_function_pointer("niScope_UnlockSession")); function_pointers_.SetRuntimeEnvironment = reinterpret_cast(shared_library_.get_function_pointer("niScope_SetRuntimeEnvironment")); + + if (function_pointers_.SetRuntimeEnvironment) { + this->SetRuntimeEnvironment(nidevice_grpc::kNiDeviceGrpcOriginalFileName, nidevice_grpc::kNiDeviceGrpcFileVersion, "", ""); + } } NiScopeLibrary::~NiScopeLibrary() diff --git a/generated/niswitch/niswitch_library.cpp b/generated/niswitch/niswitch_library.cpp index 531f77e9f..55c73e094 100644 --- a/generated/niswitch/niswitch_library.cpp +++ b/generated/niswitch/niswitch_library.cpp @@ -4,6 +4,7 @@ // Service implementation for the NI-SWITCH Metadata //--------------------------------------------------------------------- #include "niswitch_library.h" +#include "version.h" #if defined(_MSC_VER) static const char* kLibraryName = "niswitch_64.dll"; @@ -84,6 +85,10 @@ NiSwitchLibrary::NiSwitchLibrary() : shared_library_(kLibraryName) function_pointers_.WaitForDebounce = reinterpret_cast(shared_library_.get_function_pointer("niSwitch_WaitForDebounce")); function_pointers_.WaitForScanComplete = reinterpret_cast(shared_library_.get_function_pointer("niSwitch_WaitForScanComplete")); function_pointers_.SetRuntimeEnvironment = reinterpret_cast(shared_library_.get_function_pointer("niSwitch_SetRuntimeEnvironment")); + + if (function_pointers_.SetRuntimeEnvironment) { + this->SetRuntimeEnvironment(nidevice_grpc::kNiDeviceGrpcOriginalFileName, nidevice_grpc::kNiDeviceGrpcFileVersion, "", ""); + } } NiSwitchLibrary::~NiSwitchLibrary() 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/templates/library.cpp.mako b/source/codegen/templates/library.cpp.mako index 5bae34e65..70b0a6eba 100644 --- a/source/codegen/templates/library.cpp.mako +++ b/source/codegen/templates/library.cpp.mako @@ -14,6 +14,8 @@ linux_abi_version = linux_library_info.get('abi_version', None) linux_so_version_suffix = f'.{linux_abi_version}' if linux_abi_version else '' windows_library_info = config['library_info']['Windows']['64bit'] windows_library_name = windows_library_info['name'] + +set_runtime_environment_supported = 'SetRuntimeEnvironment' in service_helpers.filter_api_functions(functions, only_mockable_functions=False) %>\ //--------------------------------------------------------------------- // This file is automatically generated. All manual edits will be lost. @@ -21,6 +23,9 @@ windows_library_name = windows_library_info['name'] // Service implementation for the ${config["driver_name"]} Metadata //--------------------------------------------------------------------- #include "${module_name}_library.h" +% if set_runtime_environment_supported: +#include "version.h" +% endif #if defined(_MSC_VER) static const char* kLibraryName = "${windows_library_name}"; @@ -44,6 +49,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 set_runtime_environment_supported: + + 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..d50bb4d9a --- /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