mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
Mysql database module. Only implemented compiling / linking.
This commit is contained in:
parent
c3922e17d2
commit
9c7be6e808
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@ bin/**
|
|||||||
*.dblite
|
*.dblite
|
||||||
*.o
|
*.o
|
||||||
*.a
|
*.a
|
||||||
|
*.pyc
|
||||||
|
45
SConstruct
45
SConstruct
@ -71,6 +71,25 @@ env_base.msvc = False
|
|||||||
# avoid issues when building with different versions of python out of the same directory
|
# avoid issues when building with different versions of python out of the same directory
|
||||||
env_base.SConsignFile(".sconsign{0}.dblite".format(pickle.HIGHEST_PROTOCOL))
|
env_base.SConsignFile(".sconsign{0}.dblite".format(pickle.HIGHEST_PROTOCOL))
|
||||||
|
|
||||||
|
database_list = []
|
||||||
|
|
||||||
|
for x in sorted(glob.glob("database/*")):
|
||||||
|
if not os.path.isdir(x) or not os.path.exists(x + "/detect.py"):
|
||||||
|
continue
|
||||||
|
tmppath = "./" + x
|
||||||
|
|
||||||
|
sys.path.insert(0, tmppath)
|
||||||
|
import detect
|
||||||
|
|
||||||
|
if detect.is_active() and detect.can_build():
|
||||||
|
x = x.replace("database/", "") # rest of world
|
||||||
|
x = x.replace("database\\", "") # win32
|
||||||
|
database_list += [x]
|
||||||
|
|
||||||
|
sys.path.remove(tmppath)
|
||||||
|
sys.modules.pop("detect")
|
||||||
|
|
||||||
|
|
||||||
# Build options
|
# Build options
|
||||||
|
|
||||||
opts = Variables([], ARGUMENTS)
|
opts = Variables([], ARGUMENTS)
|
||||||
@ -92,10 +111,34 @@ env_base.Prepend(CPPPATH=["#libs"])
|
|||||||
env_base.Prepend(LINKFLAGS=["-lpthread"])
|
env_base.Prepend(LINKFLAGS=["-lpthread"])
|
||||||
|
|
||||||
env_base.Append(CXX=["-o3"])
|
env_base.Append(CXX=["-o3"])
|
||||||
#env_base.Append(CXX=["-g"])
|
#env_base.Append(CXX=["-g2"])
|
||||||
|
|
||||||
env = env_base.Clone()
|
env = env_base.Clone()
|
||||||
|
|
||||||
|
for d in database_list:
|
||||||
|
tmppath = "./database/" + d
|
||||||
|
sys.path.insert(0, tmppath)
|
||||||
|
|
||||||
|
import detect
|
||||||
|
|
||||||
|
env_db = env_base.Clone()
|
||||||
|
|
||||||
|
# Compilation DB requires SCons 3.1.1+.
|
||||||
|
from SCons import __version__ as scons_raw_version
|
||||||
|
|
||||||
|
scons_ver = env_db._get_major_minor_revision(scons_raw_version)
|
||||||
|
|
||||||
|
if scons_ver >= (4, 0, 0):
|
||||||
|
env_db.Tool("compilation_db")
|
||||||
|
env_db.Alias("compiledb", env.CompilationDatabase())
|
||||||
|
|
||||||
|
detect.configure(env_db)
|
||||||
|
detect.configure(env)
|
||||||
|
|
||||||
|
Export("env_db")
|
||||||
|
|
||||||
|
SConscript("database/" + d + "/SCsub")
|
||||||
|
|
||||||
Export("env")
|
Export("env")
|
||||||
|
|
||||||
SConscript("core/SCsub")
|
SConscript("core/SCsub")
|
||||||
|
0
core/database.cpp
Normal file
0
core/database.cpp
Normal file
0
core/database.h
Normal file
0
core/database.h
Normal file
0
core/database_manager.cpp
Normal file
0
core/database_manager.cpp
Normal file
0
core/database_manager.h
Normal file
0
core/database_manager.h
Normal file
11
database/mysql/SCsub
Normal file
11
database/mysql/SCsub
Normal file
@ -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_mysql", env_db.core_sources)
|
||||||
|
env_db.Prepend(LIBS=[lib])
|
59
database/mysql/detect.py
Normal file
59
database/mysql/detect.py
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def is_active():
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def get_name():
|
||||||
|
return "mysql"
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
mariadb_error = os.system("pkg-config mariadb --modversion --silence-errors > /dev/null ")
|
||||||
|
mysql_error = os.system("pkg-config mysql --modversion --silence-errors > /dev/null ")
|
||||||
|
|
||||||
|
if mariadb_error and mysql_error:
|
||||||
|
#print("mysql and mariadb not found..")
|
||||||
|
return False
|
||||||
|
|
||||||
|
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):
|
||||||
|
mariadb_error = os.system("pkg-config mariadb --modversion --silence-errors > /dev/null ")
|
||||||
|
mysql_error = os.system("pkg-config mysql --modversion --silence-errors > /dev/null ")
|
||||||
|
|
||||||
|
if not mariadb_error:
|
||||||
|
env.ParseConfig("pkg-config mariadb --cflags --libs")
|
||||||
|
|
||||||
|
if not mysql_error:
|
||||||
|
env.ParseConfig("pkg-config mysql --cflags --libs")
|
||||||
|
|
||||||
|
# Link those statically for portability
|
||||||
|
#if env["use_static_cpp"]:
|
||||||
|
#env.Append(LINKFLAGS=["-static-libgcc", "-static-libstdc++"])
|
1
database/mysql/mysql_connection.cpp
Normal file
1
database/mysql/mysql_connection.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "mysql_connection.h"
|
27
database/mysql/mysql_connection.h
Normal file
27
database/mysql/mysql_connection.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef MYSQL_CONNECTION
|
||||||
|
#define MYSQL_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 <mysql.h>
|
||||||
|
|
||||||
|
class MysqlConnection {
|
||||||
|
public:
|
||||||
|
MysqlConnection() {
|
||||||
|
mysql = new MYSQL();
|
||||||
|
}
|
||||||
|
~MysqlConnection()
|
||||||
|
{
|
||||||
|
delete mysql;
|
||||||
|
}
|
||||||
|
|
||||||
|
MYSQL *mysql;
|
||||||
|
};
|
||||||
|
|
||||||
|
#undef IS_NUM
|
||||||
|
|
||||||
|
#endif
|
6
main.cpp
6
main.cpp
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#include "rdn_application.h"
|
#include "rdn_application.h"
|
||||||
|
|
||||||
|
#include "database/mysql/mysql_connection.h"
|
||||||
|
|
||||||
#define MAIN_CLASS RDNApplication
|
#define MAIN_CLASS RDNApplication
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
@ -14,6 +16,9 @@ int main(int argc, char **argv) {
|
|||||||
file_cache->wwwroot = "./www";
|
file_cache->wwwroot = "./www";
|
||||||
file_cache->wwwroot_refresh_cache();
|
file_cache->wwwroot_refresh_cache();
|
||||||
|
|
||||||
|
//MysqlConnection *conn;
|
||||||
|
//conn = new MysqlConnection();
|
||||||
|
|
||||||
Application *app = new MAIN_CLASS();
|
Application *app = new MAIN_CLASS();
|
||||||
|
|
||||||
app->setup_routes();
|
app->setup_routes();
|
||||||
@ -28,6 +33,7 @@ int main(int argc, char **argv) {
|
|||||||
delete server;
|
delete server;
|
||||||
delete app;
|
delete app;
|
||||||
delete file_cache;
|
delete file_cache;
|
||||||
|
// delete conn;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user