include version number of amqp-cpp, longer product name, change order of platform info
This commit is contained in:
parent
5bc547b121
commit
d8550894ba
10
Makefile
10
Makefile
|
|
@ -6,19 +6,19 @@ export SONAME = 4.3
|
|||
export VERSION = 4.3.24
|
||||
|
||||
all:
|
||||
$(MAKE) -C src all
|
||||
$(MAKE) VERSION=${VERSION} -C src all
|
||||
|
||||
pure:
|
||||
$(MAKE) -C src pure
|
||||
$(MAKE) VERSION=${VERSION} -C src pure
|
||||
|
||||
release:
|
||||
$(MAKE) -C src release
|
||||
$(MAKE) VERSION=${VERSION} -C src release
|
||||
|
||||
static:
|
||||
$(MAKE) -C src static
|
||||
$(MAKE) VERSION=${VERSION} -C src static
|
||||
|
||||
shared:
|
||||
$(MAKE) -C src shared
|
||||
$(MAKE) VERSION=${VERSION} -C src shared
|
||||
|
||||
clean:
|
||||
$(MAKE) -C src clean
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
CPP = g++
|
||||
RM = rm -f
|
||||
CPPFLAGS = -Wall -c -I../include -std=c++17 -MD -Wno-class-conversion
|
||||
CPPFLAGS = -Wall -c -I../include -std=c++17 -MD -Wno-class-conversion -DVERSION=${VERSION}
|
||||
LD = g++
|
||||
LD_FLAGS = -Wall -shared
|
||||
SHARED_LIB = lib$(LIBRARY_NAME).so.$(VERSION)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,18 @@
|
|||
#include "programname.h"
|
||||
#include "platformname.h"
|
||||
|
||||
/**
|
||||
* Cause we want to print out version string that is passed to compiled with -D
|
||||
* flag. Why 2 macros? https://www.guyrutenberg.com/2008/12/20/expanding-macros-into-string-constants-in-c/
|
||||
*/
|
||||
#define STR_EXPAND(s) #s
|
||||
#define STR(s) STR_EXPAND(s)
|
||||
|
||||
/**
|
||||
* The version and distro names
|
||||
*/
|
||||
#define VERSION_NAME STR(VERSION)
|
||||
|
||||
/**
|
||||
* Set up namespace
|
||||
*/
|
||||
|
|
@ -207,7 +219,7 @@ public:
|
|||
|
||||
// fill the peer properties
|
||||
if (!properties.contains("product")) properties["product"] = ProgramName();
|
||||
if (!properties.contains("version")) properties["version"] = "Unknown";
|
||||
if (!properties.contains("version")) properties["version"] = "AMQP-CPP " VERSION_NAME;
|
||||
if (!properties.contains("platform")) properties["platform"] = PlatformName();
|
||||
if (!properties.contains("copyright")) properties["copyright"] = "Copernica AMQP-CPP library :: Copyright 2015-2023 Copernica BV";
|
||||
if (!properties.contains("information")) properties["information"] = "https://github.com/CopernicaMarketingSoftware/AMQP-CPP";
|
||||
|
|
|
|||
|
|
@ -41,13 +41,13 @@ public:
|
|||
PlatformName()
|
||||
{
|
||||
// all information
|
||||
struct utsname sysinfo;
|
||||
struct utsname info;
|
||||
|
||||
// retrieve system info
|
||||
if (uname(&sysinfo) != 0) return;
|
||||
if (uname(&info) != 0) return;
|
||||
|
||||
// add all info
|
||||
_value.append(sysinfo.sysname).append(" ").append(sysinfo.version).append(" ").append(sysinfo.release).append(" running on ").append(sysinfo.nodename);
|
||||
_value.append(info.sysname).append(" ").append(info.nodename).append(" ").append(info.release).append(" ").append(info.version);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -45,7 +45,17 @@ public:
|
|||
/**
|
||||
* Constructor
|
||||
*/
|
||||
ProgramName() : _valid(readlink("/proc/self/exe", _path, PATH_MAX) == 0) {}
|
||||
ProgramName()
|
||||
{
|
||||
// read the link target
|
||||
auto size = readlink("/proc/self/exe", _path, PATH_MAX);
|
||||
|
||||
// -1 is returned on error, otherwise the size
|
||||
_valid = size >= 0;
|
||||
|
||||
// set trailing null byte
|
||||
_path[size == PATH_MAX ? PATH_MAX-1 : size] = '\0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
|
|
@ -61,11 +71,8 @@ public:
|
|||
// empty string when not valid
|
||||
if (!_valid) return "";
|
||||
|
||||
// locate the last slash
|
||||
auto *slash = strrchr(_path, '/');
|
||||
|
||||
// if not found return entire path, otherwise just the program name
|
||||
return slash ? slash + 1 : _path;
|
||||
// return path to executable
|
||||
return _path;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue