Skip to content
Snippets Groups Projects
Commit 1ac5bc99 authored by Stuart Mark James's avatar Stuart Mark James
Browse files

Minor updates + fix logging not shutting down on libray close

parent a784f9c6
No related branches found
No related tags found
No related merge requests found
......@@ -7,11 +7,22 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]
### Fixed
- Close logging down in destructor so linked device server can be restarted.
### Changed
- Build system correctly produces a major version shared object
- Removed Clang path from build (CMake checks PATH)
- Corrected static library build
- Install now places header in include/hdb++/
## [0.9.1] - 2019-07-18
### Added
- Google benchmark submodule for micro benchmarking. This will enabled future optimisation
- Google benchmark sub-module for micro benchmarking. This will enabled future optimisation
- Benchmark tests for QueryBuilder
### Fixed
......
......@@ -20,10 +20,15 @@ set(LIBHDBPP_TIMESCALE_NAME "libhdb++timescale")
# Versioning
set(VERSION_MAJOR "0")
set(VERSION_MINOR "9")
set(VERSION_PATCH "1")
set(VERSION_PATCH "2")
set(VERSION_METADATA "")
set(VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
# Add any include paths from the command line
list(APPEND INCLUDE_PATHS ${CMAKE_INCLUDE_PATH})
list(APPEND INCLUDE_PATHS ${CMAKE_SOURCE_DIR})
list(APPEND LIBRARY_PATHS ${CMAKE_LIBRARY_PATH})
# Start the project
project(libhdbpp_timescale VERSION ${VERSION_STRING} LANGUAGES CXX)
......@@ -80,10 +85,10 @@ find_package(Threads REQUIRED)
# build google benchmark (target: benchmark)
# do not build tests of benchmarking lib
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Suppressing benchmark's tests" FORCE)
add_subdirectory(thirdparty/google/benchmark)
add_subdirectory(thirdparty/google/benchmark EXCLUDE_FROM_ALL)
# build tests (targets: gtest_main, gtest)
add_subdirectory(thirdparty/google/googletest/googletest)
add_subdirectory(thirdparty/google/googletest/googletest EXCLUDE_FROM_ALL)
# Include the thirdparty projects
add_subdirectory(thirdparty/libhdbpp EXCLUDE_FROM_ALL)
......@@ -107,9 +112,11 @@ set_target_properties(pqxx_static
if(ENABLE_CLANG)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# To find clang, find_program will search your PATH environment variable.
# Ensure if you have a non-standard clang install, that it has been added
# to your path.
find_program(CLANG_TIDY_EXE
NAMES "clang-tidy"
HINTS "/users/sjames/workspace/tools/clang/bin"
DOC "Path to clang-tidy executable")
if(NOT CLANG_TIDY_EXE)
......@@ -120,6 +127,8 @@ if(ENABLE_CLANG)
endif(NOT CLANG_TIDY_EXE)
endif(ENABLE_CLANG)
# Source -----------------------------------
add_subdirectory(src)
# Build Targets -----------------------------------
......@@ -146,7 +155,7 @@ set_target_properties(libhdbpp_timescale_shared_library
CXX_STANDARD 14
POSITION_INDEPENDENT_CODE 1
VERSION ${VERSION_STRING}
SOVERSION ${VERSION_STRING})
SOVERSION ${VERSION_MAJOR})
if(DO_CLANG_TIDY)
set_target_properties(libhdbpp_timescale_shared_library
......@@ -157,16 +166,25 @@ endif(DO_CLANG_TIDY)
target_compile_options(libhdbpp_timescale_shared_library
PRIVATE "$<$<CONFIG:DEBUG>:-g>")
# Libhdbpp shared library --------
add_library(libhdbpp_timescale_static_library STATIC ${SRC_FILES})
# Static library --------
add_library(libhdbpp_timescale_static_library STATIC EXCLUDE_FROM_ALL ${SRC_FILES})
target_link_libraries(libhdbpp_timescale_static_library
PUBLIC ${TDB_FOUND_LIBRARIES}
PUBLIC ${TDB_FOUND_LIBRARIES} pqxx_static libhdbpp_headers spdlog Threads::Threads
PRIVATE TangoInterfaceLibrary)
target_include_directories(libhdbpp_timescale_static_library
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
${INCLUDE_PATHS}
"${PROJECT_BINARY_DIR}")
set_target_properties(libhdbpp_timescale_static_library
PROPERTIES
OUTPUT_NAME hdb++
OUTPUT_NAME hdb++timescale
LINK_FLAGS "-Wl,--no-undefined"
CXX_STANDARD 14
EXCLUDE_FROM_ALL 1)
......@@ -183,7 +201,7 @@ install(
install(
DIRECTORY ${PROJECT_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hdb++
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN HdbppTimescaleDb.hpp)
......
......@@ -35,8 +35,6 @@ To compile this library, first ensure it has been recursively cloned so all subm
export PKG_CONFIG_PATH=/non/standard/tango/install/location
```
CMake is also set to search any paths added to CMAKE_PREFIX_PATH. This can be set and passed into CMake instead.
Then to build just the library:
```bash
......@@ -46,6 +44,14 @@ cmake ..
make
```
The pkg-config path can also be set with the cmake argument CMAKE_PREFIX_PATH. This can be set on the command line at configuration time, i.e.:
```bash
...
cmake -DCMAKE_PREFIX_PATH=/non/standard/tango/install/location ..
...
```
## Build Flags
The following build flags are available
......
......@@ -35,6 +35,7 @@ Rather than create and manage the tables via a superuser, we create and admin us
```sql
CREATE ROLE hdb_admin WITH LOGIN PASSWORD 'hdbpp';
ALTER USER hdb_admin CREATEDB;
ALTER USER hdb_admin CREATEROLE;
ALTER USER hdb_admin SUPERUSER;
```
......
File moved
......@@ -58,7 +58,8 @@ namespace pqxx_conn
}
catch (const pqxx::broken_connection &ex)
{
string msg {"Failed to connect to database. Ensure parameters are correct and database is running"};
string msg {"Failed to connect to database. Exception: "};
msg += ex.what();
_logger->error("Error: Connecting to postgres database with connect string: \"{}\"", connect_string);
_logger->error("Caught error: \"{}\"", ex.what());
......@@ -622,7 +623,7 @@ namespace pqxx_conn
"] does not exist in the database. Unable to work with this attribute until it is added."};
_logger->error("Error: The attribute does not exist in the database, add it first.");
_logger->error("Attribute details. Name: {} traits: {}", full_attr_name);
_logger->error("Attribute details. Name: {}", full_attr_name);
_logger->error("Throwing consistency error with message: \"{}\"", msg);
Tango::Except::throw_exception("Consistency Error", msg, location);
}
......
......@@ -17,7 +17,7 @@
You should have received a copy of the Lesser GNU General Public License
along with libhdb++timescale. If not, see <http://www.gnu.org/licenses/>. */
#include "HdbppTimescaleDb.hpp"
#include "hdb++/HdbppTimescaleDb.hpp"
#include "DbConnection.hpp"
#include "HdbppTxDataEvent.hpp"
......@@ -148,6 +148,8 @@ HdbppTimescaleDb::~HdbppTimescaleDb()
{
if (Conn->isOpen())
Conn->disconnect();
LogConfigurator::shutdownLogging();
}
//=============================================================================
......@@ -163,7 +165,7 @@ void HdbppTimescaleDb::insert_Attr(Tango::EventData *event_data, HdbEventDataTyp
{
spdlog::trace("Event type is error for attribute: {}", event_data->attr_name);
// now time data is passed for errors, so make something up
// no time data is passed for errors, so make something up
struct timeval tv
{};
......
......@@ -38,7 +38,7 @@ public:
HdbppTxDataEventError(Conn &conn) : HdbppTxDataEventBase<Conn, HdbppTxDataEventError>(conn) {}
virtual ~HdbppTxDataEventError() {}
HdbppTxDataEventError<Conn> &withError(const string &error_msg)
HdbppTxDataEventError<Conn> &withError(const std::string &error_msg)
{
_error_msg = error_msg;
return *this;
......
......@@ -59,7 +59,7 @@ std::ostream &operator<<(std::ostream &os, Tango::CmdArgType type);
std::ostream &operator<<(std::ostream &os, Tango::AttrQuality quality);
// SPDLOG config and setup
const string LibLoggerName = "hdbpp";
const std::string LibLoggerName = "hdbpp";
struct LogConfigurator
{
......
......@@ -28,11 +28,13 @@ target_link_libraries(unit-tests
target_include_directories(unit-tests
PRIVATE ${CMAKE_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR})
target_compile_definitions(unit-tests
PRIVATE -DDEBUG_ENABLED)
set_target_properties(unit-tests
PROPERTIES
LINK_FLAGS "-Wl,--no-undefined"
CXX_CLANG_TIDY ${DO_CLANG_TIDY}
CXX_STANDARD 14)
if(DO_CLANG_TIDY)
set_target_properties(unit-tests
PROPERTIES
CXX_CLANG_TIDY ${DO_CLANG_TIDY})
endif(DO_CLANG_TIDY)
\ No newline at end of file
......@@ -106,7 +106,7 @@ Tango::DeviceAttribute createDeviceAttribute(const AttributeTraits &traits)
};
// hack hack hack.... this mess of forced public (!) variable setting actually
// sets up the consitions for valid extracts inside the HdbppTxDataEvent class.
// sets up the conditions for valid extracts inside the HdbppTxDataEvent class.
// Should the Tango API ever be improved then this hack is doomed.
auto attr = attr_gen(select_size(traits.hasReadData(), 1), select_size(traits.hasWriteData(), 1));
attr.dim_x = select_size(traits.hasReadData(), 1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment