From d36a344980bc99c2b1157d1c11070f9217558da5 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 28 Nov 2020 14:30:50 +0100 Subject: [PATCH] Also link to sqlite 3 if present. --- database/sqlite/SCsub | 11 ++++++ database/sqlite/detect.py | 53 ++++++++++++++++++++++++++ database/sqlite/sqlite3_connection.cpp | 1 + database/sqlite/sqlite3_connection.h | 35 +++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 database/sqlite/SCsub create mode 100644 database/sqlite/detect.py create mode 100644 database/sqlite/sqlite3_connection.cpp create mode 100644 database/sqlite/sqlite3_connection.h diff --git a/database/sqlite/SCsub b/database/sqlite/SCsub new file mode 100644 index 0000000..246e3dd --- /dev/null +++ b/database/sqlite/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/sqlite/detect.py b/database/sqlite/detect.py new file mode 100644 index 0000000..5bdd2bb --- /dev/null +++ b/database/sqlite/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 + + sqlite_error = os.system("pkg-config sqlite3 --modversion --silence-errors > /dev/null ") + + if sqlite_error: + print("sqlite3 not found!") + return False + + print("sqlite3 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 sqlite3 --cflags --libs") + + # Link those statically for portability + #if env["use_static_cpp"]: + #env.Append(LINKFLAGS=["-static-libgcc", "-static-libstdc++"]) diff --git a/database/sqlite/sqlite3_connection.cpp b/database/sqlite/sqlite3_connection.cpp new file mode 100644 index 0000000..3a8aced --- /dev/null +++ b/database/sqlite/sqlite3_connection.cpp @@ -0,0 +1 @@ +#include "sqlite3_connection.h" \ No newline at end of file diff --git a/database/sqlite/sqlite3_connection.h b/database/sqlite/sqlite3_connection.h new file mode 100644 index 0000000..fc878ee --- /dev/null +++ b/database/sqlite/sqlite3_connection.h @@ -0,0 +1,35 @@ +#ifndef SQLITE3_CONNECTION +#define SQLITE3_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 + +#include + +class SQLite3Connection { +public: + SQLite3Connection() { + + int ret = sqlite3_config(SQLITE_CONFIG_MULTITHREAD); + if (ret != SQLITE_OK) { + printf("SQLITE3 multithreading is not supported!\n"); + } + + ret = sqlite3_open("", &conn); + } + + ~SQLite3Connection() { + sqlite3_close(conn); + } + + sqlite3 *conn; +}; + +//#undef IS_NUM + +#endif \ No newline at end of file