From a54178e1eebf5f72a10c16ee5c3f73651c6ebd27 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 28 Nov 2020 14:18:58 +0100 Subject: [PATCH] Link to postgre sql if found aswell. --- database/postgres/SCsub | 11 ++++++ database/postgres/detect.py | 53 ++++++++++++++++++++++++++ database/postgres/pgsql_connection.cpp | 1 + database/postgres/pgsql_connection.h | 27 +++++++++++++ 4 files changed, 92 insertions(+) create mode 100644 database/postgres/SCsub create mode 100644 database/postgres/detect.py create mode 100644 database/postgres/pgsql_connection.cpp create mode 100644 database/postgres/pgsql_connection.h diff --git a/database/postgres/SCsub b/database/postgres/SCsub new file mode 100644 index 0000000..246e3dd --- /dev/null +++ b/database/postgres/SCsub @@ -0,0 +1,11 @@ +#!/usr/bin/env python + +Import("env_db") + +env_db.core_sources = [] + +env_db.add_source_files(env_db.core_sources, "*.cpp") + +# Build it all as a library +lib = env_db.add_library("database_pgsql", env_db.core_sources) +env_db.Prepend(LIBS=[lib]) diff --git a/database/postgres/detect.py b/database/postgres/detect.py new file mode 100644 index 0000000..27700be --- /dev/null +++ b/database/postgres/detect.py @@ -0,0 +1,53 @@ +import os +import platform +import sys + + +def is_active(): + return True + + +def get_name(): + return "pgsql" + + +def can_build(): + + if os.name == "posix" or sys.platform == "darwin": + x11_error = os.system("pkg-config --version > /dev/null") + if x11_error: + return False + + libpg_error = os.system("pkg-config libpq --modversion --silence-errors > /dev/null ") + + if libpg_error: + print("postgres not found!") + return False + + print("postgres found!") + + return True + + #todo + return False + + +def get_opts(): + from SCons.Variables import BoolVariable, EnumVariable + + return [ + EnumVariable("debug_symbols", "Add debugging symbols to release/release_debug builds", "yes", ("yes", "no")), + ] + + +def get_flags(): + + return [] + + +def configure(env): + env.ParseConfig("pkg-config libpq --cflags --libs") + + # Link those statically for portability + #if env["use_static_cpp"]: + #env.Append(LINKFLAGS=["-static-libgcc", "-static-libstdc++"]) diff --git a/database/postgres/pgsql_connection.cpp b/database/postgres/pgsql_connection.cpp new file mode 100644 index 0000000..a033fd5 --- /dev/null +++ b/database/postgres/pgsql_connection.cpp @@ -0,0 +1 @@ +#include "pgsql_connection.h" \ No newline at end of file diff --git a/database/postgres/pgsql_connection.h b/database/postgres/pgsql_connection.h new file mode 100644 index 0000000..f3f6615 --- /dev/null +++ b/database/postgres/pgsql_connection.h @@ -0,0 +1,27 @@ +#ifndef PGSQL_CONNECTION +#define PGSQL_CONNECTION + +//Brynet has it aswell, and because of using namespace it is defined here aswell +//later this will be fixed better +//#ifdef IS_NUM +//#undef IS_NUM +//#endif + +#include + +class PGSQLConnection { + public: + PGSQLConnection() { + conn = PQconnectStart(""); + } + ~PGSQLConnection() + { + PQfinish(conn); + } + + PGconn *conn; +}; + +//#undef IS_NUM + +#endif \ No newline at end of file