Skip to content

Commit

Permalink
Merge pull request #92 from FredyH/mariadb-connector
Browse files Browse the repository at this point in the history
Mariadb connector
  • Loading branch information
FredyH authored Nov 17, 2021
2 parents 7112f33 + 3799cf9 commit fd2ecc4
Show file tree
Hide file tree
Showing 115 changed files with 8,420 additions and 10,682 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
/premake5
/premake5.exe
/out
.vscode
.vscode
*.zip
cmake-build-debug
.idea
.vs
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

67 changes: 0 additions & 67 deletions BuildProjects.lua

This file was deleted.

40 changes: 40 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
cmake_minimum_required(VERSION 3.5)
project(mysqloo)
add_subdirectory(GmodLUA)

file(GLOB_RECURSE MYSQLOO_SRC "src/*.h" "src/*.cpp")
set(SOURCE_FILES ${MYSQLOO_SRC} src/Main.cpp)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
set (CMAKE_CXX_STANDARD 14)

add_library(mysqloo SHARED ${SOURCE_FILES})
target_link_libraries(mysqloo gmod-module-base)

target_include_directories(mysqloo PRIVATE MySQL/include)

if (CMAKE_SIZEOF_VOID_P EQUAL 8)
if (WIN32)
find_library(MARIADB_CLIENT_LIB mariadbclient HINTS "${PROJECT_SOURCE_DIR}/MySQL/lib64/windows")
else ()
find_library(MARIADB_CLIENT_LIB mariadbclient HINTS "${PROJECT_SOURCE_DIR}/MySQL/lib64/linux")
find_library(CRYPTO_LIB crypto HINTS "${PROJECT_SOURCE_DIR}/MySQL/lib64/linux")
find_library(SSL_LIB ssl HINTS "${PROJECT_SOURCE_DIR}/MySQL/lib64/linux")
endif ()
elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
if (WIN32)
find_library(MARIADB_CLIENT_LIB mariadbclient HINTS "${PROJECT_SOURCE_DIR}/MySQL/lib/windows")
else ()
find_library(MARIADB_CLIENT_LIB mariadbclient HINTS "${PROJECT_SOURCE_DIR}/MySQL/lib/linux")
find_library(CRYPTO_LIB crypto HINTS "${PROJECT_SOURCE_DIR}/MySQL/lib/linux")
find_library(SSL_LIB ssl HINTS "${PROJECT_SOURCE_DIR}/MySQL/lib/linux")
endif ()
endif ()

if (WIN32)
target_link_libraries(mysqloo ${MARIADB_CLIENT_LIB} crypt32 ws2_32 shlwapi bcrypt secur32)
else ()
find_package(Threads REQUIRED)
target_link_libraries(mysqloo ${MARIADB_CLIENT_LIB} ${SSL_LIB} ${CRYPTO_LIB} Threads::Threads ${CMAKE_DL_LIBS})
endif ()

set_gmod_suffix_prefix(mysqloo)
27 changes: 27 additions & 0 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"configurations": [
{
"name": "x64-RelDebug",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": ""
},
{
"name": "x86-RelDebug",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x86" ],
"variables": []
}
]
}
33 changes: 33 additions & 0 deletions GmodLUA/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
set(SOURCES
GarrysMod/Lua/Interface.h
GarrysMod/Lua/LuaBase.h
GarrysMod/Lua/SourceCompat.h
GarrysMod/Lua/Types.h
GarrysMod/Lua/UserData.h)

add_library(gmod-module-base INTERFACE)
target_include_directories(gmod-module-base INTERFACE ./)

function(set_gmod_suffix_prefix library)
SET_TARGET_PROPERTIES(${library} PROPERTIES PREFIX "gmsv_")

if(APPLE)
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
SET_TARGET_PROPERTIES(${library} PROPERTIES SUFFIX "_osx.dll")
else()
SET_TARGET_PROPERTIES(${library} PROPERTIES SUFFIX "_osx64.dll")
endif()
elseif(UNIX)
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
SET_TARGET_PROPERTIES(${library} PROPERTIES SUFFIX "_linux.dll")
else()
SET_TARGET_PROPERTIES(${library} PROPERTIES SUFFIX "_linux64.dll")
endif()
elseif(WIN32)
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
SET_TARGET_PROPERTIES(${library} PROPERTIES SUFFIX "_win32.dll")
else()
SET_TARGET_PROPERTIES(${library} PROPERTIES SUFFIX "_win64.dll")
endif()
endif()
endfunction()
74 changes: 74 additions & 0 deletions GmodLUA/GarrysMod/Lua/Interface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#ifndef GARRYSMOD_LUA_INTERFACE_H
#define GARRYSMOD_LUA_INTERFACE_H

#include "LuaBase.h"

struct lua_State {
#if defined( _WIN32 ) && !defined( _M_X64 )
// Win32
unsigned char _ignore_this_common_lua_header_[48 + 22];
#elif defined( _WIN32 ) && defined( _M_X64 )
// Win64
unsigned char _ignore_this_common_lua_header_[92 + 22];
#elif defined( __linux__ ) && !defined( __x86_64__ )
// Linux32
unsigned char _ignore_this_common_lua_header_[48 + 22];
#elif defined( __linux__ ) && defined( __x86_64__ )
// Linux64
unsigned char _ignore_this_common_lua_header_[92 + 22];
#elif defined ( __APPLE__ ) && !defined( __x86_64__ )
// macOS32
unsigned char _ignore_this_common_lua_header_[48 + 22];
#elif defined ( __APPLE__ ) && defined( __x86_64__ )
// macOS64
unsigned char _ignore_this_common_lua_header_[92 + 22];
#else
#error agh
#endif

GarrysMod::Lua::ILuaBase *luabase;
};

#ifndef GMOD
#ifdef _WIN32
#define DLL_EXPORT extern "C" __declspec( dllexport )
#else
#define DLL_EXPORT extern "C" __attribute__((visibility("default")))
#endif

#ifdef GMOD_ALLOW_DEPRECATED
// Stop using this and use LUA_FUNCTION!
#define LUA ( state->luabase )

#define GMOD_MODULE_OPEN() DLL_EXPORT int gmod13_open( lua_State* state )
#define GMOD_MODULE_CLOSE() DLL_EXPORT int gmod13_close( lua_State* state )
#else
#define GMOD_MODULE_OPEN() \
int gmod13_open__Imp( GarrysMod::Lua::ILuaBase* LUA ); \
DLL_EXPORT int gmod13_open( lua_State* L ) \
{ \
return gmod13_open__Imp( L->luabase ); \
} \
int gmod13_open__Imp( GarrysMod::Lua::ILuaBase* LUA )

#define GMOD_MODULE_CLOSE() \
int gmod13_close__Imp( GarrysMod::Lua::ILuaBase* LUA ); \
DLL_EXPORT int gmod13_close( lua_State* L ) \
{ \
return gmod13_close__Imp( L->luabase ); \
} \
int gmod13_close__Imp( GarrysMod::Lua::ILuaBase* LUA )

#define LUA_FUNCTION(FUNC) \
static int FUNC##__Imp( GarrysMod::Lua::ILuaBase* LUA ); \
static int FUNC( lua_State* L ) \
{ \
GarrysMod::Lua::ILuaBase* LUA = L->luabase; \
LUA->SetState(L); \
return FUNC##__Imp( LUA ); \
} \
static int FUNC##__Imp( GarrysMod::Lua::ILuaBase* LUA )
#endif
#endif

#endif
Loading

0 comments on commit fd2ecc4

Please sign in to comment.