Moved the database backends into their own modules. All of them are disabled for now.

This commit is contained in:
Relintai 2022-07-06 13:13:00 +02:00
parent 8422566d28
commit 07af5c285c
33 changed files with 87 additions and 136 deletions

View File

@ -1,30 +0,0 @@
#ifndef DB_INIT_H
#define DB_INIT_H
#if MYSQL_PRESENT
#include "mysql/mysql_database.h"
#endif
#if PGSQL_PRESENT
#include "postgres/pgsql_database.h"
#endif
#if SQLITE_PRESENT
#include "sqlite/sqlite3_database.h"
#endif
void initialize_database_backends() {
#if MYSQL_PRESENT
MysqlDatabase::_register();
#endif
#if PGSQL_PRESENT
PGSQLDatabase::_register();
#endif
#if SQLITE_PRESENT
SQLite3Database::_register();
#endif
}
#endif

View File

@ -1,12 +0,0 @@
#!/usr/bin/env python
Import("env_db")
Import("env")
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_mysql", env_db.core_sources)
env.Prepend(LIBS=[lib])

View File

@ -1,12 +0,0 @@
#!/usr/bin/env python
Import("env_db")
Import("env")
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.Prepend(LIBS=[lib])

View File

@ -1,13 +0,0 @@
#!/usr/bin/env python
Import("env_db")
Import("env")
env_db.core_sources = []
env_db.add_source_files(env_db.core_sources, "*.cpp")
env_db.core_sources.append("./sqlite/sqlite3.c")
# Build it all as a library
lib = env_db.add_library("database_sqlite", env_db.core_sources)
env.Prepend(LIBS=[lib])

View File

@ -0,0 +1,36 @@
#import os
#import version
#Import('env')
#module_env = env.Clone()
#sources = [
#"register_types.cpp",
#]
#if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes':
# Shared lib compilation
# module_env.Append(CCFLAGS=['-fPIC'])
# module_env['LIBS'] = []
# shared_lib = module_env.SharedLibrary(target='#bin/database', source=sources)
# shared_lib_shim = shared_lib[0].name.rsplit('.', 1)[0]
# env.Append(LIBS=[shared_lib_shim])
# env.Append(LIBPATH=['#bin'])
#else:
# Static compilation
# module_env.add_source_files(env.modules_sources, sources)
#Import("env_db")
#Import("env")
#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_mysql", env_db.core_sources)
#env.Prepend(LIBS=[lib])

View File

@ -1,18 +1,9 @@
import os
import platform
import sys
def can_build(env, platform):
return False
def is_active():
return True
def get_name():
return "mysql"
def can_build():
def _can_build():
if os.name == "posix" or sys.platform == "darwin":
x11_error = os.system("pkg-config --version > /dev/null")
if x11_error:
@ -39,20 +30,10 @@ def can_build():
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):
pass
def _configure(env):
mariadb_error = os.system("pkg-config mariadb --modversion --silence-errors > /dev/null ")
mysql_error = os.system("pkg-config mysql --modversion --silence-errors > /dev/null ")
@ -69,3 +50,12 @@ def configure(env):
# Link those statically for portability
#if env["use_static_cpp"]:
#env.Append(LINKFLAGS=["-static-libgcc", "-static-libstdc++"])
def get_doc_classes():
return [
]
def get_doc_path():
return "doc_classes"

View File

@ -0,0 +1,11 @@
#Import("env_db")
#Import("env")
#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.Prepend(LIBS=[lib])

View File

@ -3,16 +3,10 @@ import platform
import sys
def is_active():
return True
def get_name():
return "pgsql"
def can_build():
def can_build(env, platform):
return False
def _can_build():
if os.name == "posix" or sys.platform == "darwin":
x11_error = os.system("pkg-config --version > /dev/null")
if x11_error:
@ -31,21 +25,10 @@ def can_build():
#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):
pass
def _configure(env):
env.ParseConfig("pkg-config libpq --cflags --libs")
env.Append(CPPDEFINES=["PGSQL_PRESENT"])

View File

@ -0,0 +1,12 @@
#Import("env_db")
#Import("env")
#env_db.core_sources = []
#env_db.add_source_files(env_db.core_sources, "*.cpp")
#env_db.core_sources.append("./sqlite/sqlite3.c")
# Build it all as a library
#lib = env_db.add_library("database_sqlite", env_db.core_sources)
#env.Prepend(LIBS=[lib])

View File

@ -3,15 +3,10 @@ import platform
import sys
def is_active():
return True
def can_build(env, platform):
return False
def get_name():
return "sqlite3"
def can_build():
def _can_build():
# if os.name == "posix" or sys.platform == "darwin":
# x11_error = os.system("pkg-config --version > /dev/null")
@ -31,24 +26,15 @@ def can_build():
# #todo
# return False
print("sqlite3 built in!")
#print("sqlite3 built in!")
return True
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):
pass
def _configure(env):
#env.ParseConfig("pkg-config sqlite3 --cflags --libs")
env.Append(CPPDEFINES=["SQLITE_PRESENT"])