Version info
parent
37ef932e03
commit
4f91d0775f
|
|
@ -57,10 +57,27 @@ set(COMMON_SRC
|
|||
|
||||
set(SRC_FILES ${COMMON_SRC} ${PLATFORM_SRC})
|
||||
|
||||
# Generate build info header
|
||||
execute_process(
|
||||
COMMAND git rev-parse --abbrev-ref HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_BRANCH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
execute_process(
|
||||
COMMAND git describe --abbrev=6 --dirty --always --tags
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_DESCRIBE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
configure_file(api/icsneocpp/buildinfo.h.template ${CMAKE_BINARY_DIR}/generated/buildinfo.h)
|
||||
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
add_library(icsneocpp
|
||||
api/icsneocpp/icsneocpp.cpp
|
||||
api/icsneocpp/error.cpp
|
||||
api/icsneocpp/errormanager.cpp
|
||||
api/icsneocpp/version.cpp
|
||||
${SRC_FILES}
|
||||
)
|
||||
target_include_directories(icsneocpp
|
||||
|
|
|
|||
|
|
@ -364,3 +364,7 @@ bool icsneo_describeDevice(const neodevice_t* device, char* str, size_t* maxLeng
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
neoversion_t icsneo_getVersion(void) {
|
||||
return icsneo::GetVersion();
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef __ICSNEO_API_BUILDINFO_H_
|
||||
#define __ICSNEO_API_BUILDINFO_H_
|
||||
|
||||
const char* GIT_BRANCH = "@GIT_BRANCH@";
|
||||
const char* GIT_DESCRIBE = "@GIT_DESCRIBE@";
|
||||
const uint16_t BUILD_MAJOR = (@PROJECT_VERSION_MAJOR@);
|
||||
const uint16_t BUILD_MINOR = (@PROJECT_VERSION_MINOR@);
|
||||
const uint16_t BUILD_PATCH = (@PROJECT_VERSION_PATCH@);
|
||||
const char* BUILD_METADATA = "@BUILD_METADATA@";
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
#include "icsneo/api/version.h"
|
||||
#include "generated/buildinfo.h"
|
||||
|
||||
using namespace icsneo;
|
||||
|
||||
neoversion_t icsneo::GetVersion(void) {
|
||||
neoversion_t version = {};
|
||||
version.major = BUILD_MAJOR;
|
||||
version.minor = BUILD_MINOR;
|
||||
version.patch = BUILD_PATCH;
|
||||
version.metadata = BUILD_METADATA;
|
||||
version.buildBranch = GIT_BRANCH;
|
||||
version.buildTag = GIT_DESCRIBE;
|
||||
return version;
|
||||
}
|
||||
|
|
@ -322,8 +322,7 @@ int icsneoValidateHObject(void* hObject) {
|
|||
}
|
||||
|
||||
int icsneoGetDLLVersion(void) {
|
||||
// TODO Implement
|
||||
return false;
|
||||
return 804;
|
||||
}
|
||||
|
||||
int icsneoGetSerialNumber(void* hObject, unsigned int*iSerialNumber) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
#ifndef __ICSNEO_API_VERSION_H_
|
||||
#define __ICSNEO_API_VERSION_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct {
|
||||
uint16_t major;
|
||||
uint16_t minor;
|
||||
uint16_t patch;
|
||||
const char* metadata;
|
||||
const char* buildBranch;
|
||||
const char* buildTag;
|
||||
char reserved[32];
|
||||
} neoversion_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace icsneo {
|
||||
|
||||
neoversion_t GetVersion(void);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
#include "icsneo/communication/message/neomessage.h" // For neomessage_t and friends
|
||||
#include "icsneo/platform/dynamiclib.h" // Dynamic library loading and exporting
|
||||
#include "icsneo/communication/network.h" // Network type and netID defines
|
||||
#include "icsneo/api/version.h" // For version info
|
||||
|
||||
#ifndef ICSNEOC_DYNAMICLOAD
|
||||
|
||||
|
|
@ -63,6 +64,8 @@ extern bool DLLExport icsneo_transmitMessages(const neodevice_t* device, const n
|
|||
|
||||
extern bool DLLExport icsneo_describeDevice(const neodevice_t* device, char* str, size_t* maxLength);
|
||||
|
||||
extern neoversion_t DLLExport icsneo_getVersion(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
|
@ -144,6 +147,9 @@ fn_icsneo_transmitMessages icsneo_transmitMessages;
|
|||
typedef bool(*fn_icsneo_describeDevice)(const neodevice_t* device, char* str, size_t* maxLength);
|
||||
fn_icsneo_describeDevice icsneo_describeDevice;
|
||||
|
||||
typedef neoversion_t(*fn_icsneo_getVersion)(void);
|
||||
fn_icsneo_getVersion icsneo_getVersion;
|
||||
|
||||
#define ICSNEO_IMPORT(func) func = (fn_##func)icsneo_dynamicLibraryGetFunction(icsneo_libraryHandle, #func)
|
||||
#define ICSNEO_IMPORTASSERT(func) if((ICSNEO_IMPORT(func)) == NULL) return 3
|
||||
void* icsneo_libraryHandle = NULL;
|
||||
|
|
@ -183,6 +189,7 @@ int icsneo_init() {
|
|||
ICSNEO_IMPORTASSERT(icsneo_transmit);
|
||||
ICSNEO_IMPORTASSERT(icsneo_transmitMessages);
|
||||
ICSNEO_IMPORTASSERT(icsneo_describeDevice);
|
||||
ICSNEO_IMPORTASSERT(icsneo_getVersion);
|
||||
|
||||
icsneo_initialized = true;
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <memory>
|
||||
|
||||
#include "icsneo/device/device.h"
|
||||
#include "icsneo/api/version.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue