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 SetRuntimeEnvironment call to library constructors #973

Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions generated/nidcpower/nidcpower_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -170,6 +171,10 @@ NiDCPowerLibrary::NiDCPowerLibrary() : shared_library_(kLibraryName)
function_pointers_.WaitForEvent = reinterpret_cast<WaitForEventPtr>(shared_library_.get_function_pointer("niDCPower_WaitForEvent"));
function_pointers_.WaitForEventWithChannels = reinterpret_cast<WaitForEventWithChannelsPtr>(shared_library_.get_function_pointer("niDCPower_WaitForEventWithChannels"));
function_pointers_.SetRuntimeEnvironment = reinterpret_cast<SetRuntimeEnvironmentPtr>(shared_library_.get_function_pointer("niDCPower_SetRuntimeEnvironment"));

if (function_pointers_.SetRuntimeEnvironment) {
this->SetRuntimeEnvironment(nidevice_grpc::kNiDeviceGrpcOriginalFileName, nidevice_grpc::kNiDeviceGrpcFileVersion, "", "");
}
}

NiDCPowerLibrary::~NiDCPowerLibrary()
Expand Down
5 changes: 5 additions & 0 deletions generated/nidigitalpattern/nidigitalpattern_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -154,6 +155,10 @@ NiDigitalLibrary::NiDigitalLibrary() : shared_library_(kLibraryName)
function_pointers_.WriteSourceWaveformSiteUniqueU32 = reinterpret_cast<WriteSourceWaveformSiteUniqueU32Ptr>(shared_library_.get_function_pointer("niDigital_WriteSourceWaveformSiteUniqueU32"));
function_pointers_.WriteStatic = reinterpret_cast<WriteStaticPtr>(shared_library_.get_function_pointer("niDigital_WriteStatic"));
function_pointers_.SetRuntimeEnvironment = reinterpret_cast<SetRuntimeEnvironmentPtr>(shared_library_.get_function_pointer("niDigital_SetRuntimeEnvironment"));

if (function_pointers_.SetRuntimeEnvironment) {
this->SetRuntimeEnvironment(nidevice_grpc::kNiDeviceGrpcOriginalFileName, nidevice_grpc::kNiDeviceGrpcFileVersion, "", "");
}
}

NiDigitalLibrary::~NiDigitalLibrary()
Expand Down
5 changes: 5 additions & 0 deletions generated/nidmm/nidmm_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -111,6 +112,10 @@ NiDmmLibrary::NiDmmLibrary() : shared_library_(kLibraryName)
function_pointers_.SetAttributeViString = reinterpret_cast<SetAttributeViStringPtr>(shared_library_.get_function_pointer("niDMM_SetAttributeViString"));
function_pointers_.UnlockSession = reinterpret_cast<UnlockSessionPtr>(shared_library_.get_function_pointer("niDMM_UnlockSession"));
function_pointers_.SetRuntimeEnvironment = reinterpret_cast<SetRuntimeEnvironmentPtr>(shared_library_.get_function_pointer("niDMM_SetRuntimeEnvironment"));

if (function_pointers_.SetRuntimeEnvironment) {
this->SetRuntimeEnvironment(nidevice_grpc::kNiDeviceGrpcOriginalFileName, nidevice_grpc::kNiDeviceGrpcFileVersion, "", "");
}
}

NiDmmLibrary::~NiDmmLibrary()
Expand Down
5 changes: 5 additions & 0 deletions generated/nifake/nifake_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -115,6 +116,10 @@ NiFakeLibrary::NiFakeLibrary() : shared_library_(kLibraryName)
function_pointers_.ViUInt8ArrayOutputFunction = reinterpret_cast<ViUInt8ArrayOutputFunctionPtr>(shared_library_.get_function_pointer("niFake_ViUInt8ArrayOutputFunction"));
function_pointers_.WriteWaveform = reinterpret_cast<WriteWaveformPtr>(shared_library_.get_function_pointer("niFake_WriteWaveform"));
function_pointers_.SetRuntimeEnvironment = reinterpret_cast<SetRuntimeEnvironmentPtr>(shared_library_.get_function_pointer("niFake_SetRuntimeEnvironment"));

if (function_pointers_.SetRuntimeEnvironment) {
this->SetRuntimeEnvironment(nidevice_grpc::kNiDeviceGrpcOriginalFileName, nidevice_grpc::kNiDeviceGrpcFileVersion, "", "");
}
}

NiFakeLibrary::~NiFakeLibrary()
Expand Down
5 changes: 5 additions & 0 deletions generated/nifgen/nifgen_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -155,6 +156,10 @@ NiFgenLibrary::NiFgenLibrary() : shared_library_(kLibraryName)
function_pointers_.WriteWaveform = reinterpret_cast<WriteWaveformPtr>(shared_library_.get_function_pointer("niFgen_WriteWaveform"));
function_pointers_.WriteWaveformComplexF64 = reinterpret_cast<WriteWaveformComplexF64Ptr>(shared_library_.get_function_pointer("niFgen_WriteWaveformComplexF64"));
function_pointers_.SetRuntimeEnvironment = reinterpret_cast<SetRuntimeEnvironmentPtr>(shared_library_.get_function_pointer("niFgen_SetRuntimeEnvironment"));

if (function_pointers_.SetRuntimeEnvironment) {
this->SetRuntimeEnvironment(nidevice_grpc::kNiDeviceGrpcOriginalFileName, nidevice_grpc::kNiDeviceGrpcFileVersion, "", "");
}
}

NiFgenLibrary::~NiFgenLibrary()
Expand Down
5 changes: 5 additions & 0 deletions generated/niscope/niscope_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -114,6 +115,10 @@ NiScopeLibrary::NiScopeLibrary() : shared_library_(kLibraryName)
function_pointers_.SetAttributeViString = reinterpret_cast<SetAttributeViStringPtr>(shared_library_.get_function_pointer("niScope_SetAttributeViString"));
function_pointers_.UnlockSession = reinterpret_cast<UnlockSessionPtr>(shared_library_.get_function_pointer("niScope_UnlockSession"));
function_pointers_.SetRuntimeEnvironment = reinterpret_cast<SetRuntimeEnvironmentPtr>(shared_library_.get_function_pointer("niScope_SetRuntimeEnvironment"));

if (function_pointers_.SetRuntimeEnvironment) {
this->SetRuntimeEnvironment(nidevice_grpc::kNiDeviceGrpcOriginalFileName, nidevice_grpc::kNiDeviceGrpcFileVersion, "", "");
}
}

NiScopeLibrary::~NiScopeLibrary()
Expand Down
5 changes: 5 additions & 0 deletions generated/niswitch/niswitch_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -84,6 +85,10 @@ NiSwitchLibrary::NiSwitchLibrary() : shared_library_(kLibraryName)
function_pointers_.WaitForDebounce = reinterpret_cast<WaitForDebouncePtr>(shared_library_.get_function_pointer("niSwitch_WaitForDebounce"));
function_pointers_.WaitForScanComplete = reinterpret_cast<WaitForScanCompletePtr>(shared_library_.get_function_pointer("niSwitch_WaitForScanComplete"));
function_pointers_.SetRuntimeEnvironment = reinterpret_cast<SetRuntimeEnvironmentPtr>(shared_library_.get_function_pointer("niSwitch_SetRuntimeEnvironment"));

if (function_pointers_.SetRuntimeEnvironment) {
this->SetRuntimeEnvironment(nidevice_grpc::kNiDeviceGrpcOriginalFileName, nidevice_grpc::kNiDeviceGrpcFileVersion, "", "");
}
}

NiSwitchLibrary::~NiSwitchLibrary()
Expand Down
11 changes: 11 additions & 0 deletions generated/version.h
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions source/codegen/templates/library.cpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@ 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.
//---------------------------------------------------------------------
// 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}";
Expand All @@ -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()
Expand Down
11 changes: 11 additions & 0 deletions source/server/version.h.in
Original file line number Diff line number Diff line change
@@ -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@.@[email protected]";
static constexpr const char* kNiDeviceGrpcOriginalFileName = "ni_grpc_device_server.exe";

}

#endif // NIDEVICE_GRPC_VERSION_H