Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move mysql-ext to using mariadb connector #2086

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ jobs:
ARCH: x86,x86_64
DEPENDENCIES_FOLDER: dependencies
DEPENDENCIES_ROOT: ${{ github.workspace }}/dependencies
MYSQL_VERSION: '5.5'
MMSOURCE_VERSION: '1.12'
steps:
- uses: actions/checkout@v4
Expand All @@ -44,13 +43,13 @@ jobs:
- name: Cache dependencies
uses: actions/cache@v3
env:
cache-name: hl2sdk-mysql-mmsource
cache-name: hl2sdk-mmsource
with:
path: ${{ env.DEPENDENCIES_ROOT }}
key: ${{ runner.os }}-build-${{ env.cache-name }}-mysql${{ env.MYSQL_VERSION }}-mmsource${{ env.MMSOURCE_VERSION }}-${{ join(fromJSON(env.SDKS), '') }}
key: ${{ runner.os }}-build-${{ env.cache-name }}-mmsource${{ env.MMSOURCE_VERSION }}-${{ join(fromJSON(env.SDKS), '') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-mysql${{ env.MYSQL_VERSION }}-mmsource${{ env.MMSOURCE_VERSION }}-
${{ runner.os }}-build-${{ env.cache-name }}-mysql${{ env.MYSQL_VERSION }}-
${{ runner.os }}-build-${{ env.cache-name }}-mmsource${{ env.MMSOURCE_VERSION }}-
${{ runner.os }}-build-${{ env.cache-name }}-

# Setup Python for AMBuild
- uses: actions/setup-python@v4
Expand Down Expand Up @@ -94,5 +93,5 @@ jobs:
run: |
mkdir build
cd build
python ../configure.py --enable-optimize --sdks=${{ join(fromJSON(env.SDKS)) }} --targets=${{ env.ARCH }} --mms-path=${{ env.DEPENDENCIES_ROOT }}/mmsource-${{ env.MMSOURCE_VERSION }} --hl2sdk-root=${{ env.DEPENDENCIES_ROOT }} --mysql-path=${{ env.DEPENDENCIES_ROOT }}/mysql-${{ env.MYSQL_VERSION }} --mysql64-path=${{ env.DEPENDENCIES_ROOT }}/mysql-${{ env.MYSQL_VERSION }}-x86_64
python ../configure.py --enable-optimize --sdks=${{ join(fromJSON(env.SDKS)) }} --targets=${{ env.ARCH }} --mms-path=${{ env.DEPENDENCIES_ROOT }}/mmsource-${{ env.MMSOURCE_VERSION }} --hl2sdk-root=${{ env.DEPENDENCIES_ROOT }}
ambuild
8 changes: 8 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@
path = sourcepawn
url = https://github.com/alliedmodders/sourcepawn
shallow = true
[submodule "extensions/mysql/openssl/lib"]
path = extensions/mysql/openssl/lib
url = https://github.com/openssl/openssl
shallow = true
[submodule "extensions/mysql/mariadb/connector"]
path = extensions/mysql/mariadb/connector
url = https://github.com/mariadb-corporation/mariadb-connector-c
shallow = true
26 changes: 0 additions & 26 deletions AMBuildScript
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ class SMConfig(object):
self.extensions = []
self.generated_headers = None
self.mms_root = None
self.mysql_root = {}
self.spcomp = None
self.spcomp_bins = []
self.smx_files = {}
Expand Down Expand Up @@ -215,31 +214,6 @@ class SMConfig(object):
raise Exception('Could not find a source copy of Metamod:Source')
self.mms_root = Normalize(self.mms_root)

if builder.options.hasMySql:
if 'x86' in self.target_archs:
if builder.options.mysql_path:
self.mysql_root['x86'] = builder.options.mysql_path
else:
for i in range(10):
self.mysql_root['x86'] = ResolveEnvPath('MYSQL55', 'mysql-5.' + str(i))
if self.mysql_root['x86']:
break
if not self.mysql_root['x86'] or not os.path.isdir(self.mysql_root['x86']):
raise Exception('Could not find a path to MySQL. Configure with --no-mysql to disable it.')
self.mysql_root['x86'] = Normalize(self.mysql_root['x86'])

if 'x86_64' in self.target_archs:
if builder.options.mysql64_path:
self.mysql_root['x86_64'] = builder.options.mysql64_path
else:
for i in range(10):
self.mysql_root['x86_64'] = ResolveEnvPath('MYSQL55_64', 'mysql-5.' + str(i) + '-x86_64')
if self.mysql_root['x86_64']:
break
if not self.mysql_root['x86_64'] or not os.path.isdir(self.mysql_root['x86_64']):
raise Exception('Could not find a path to 64-bit MySQL!')
self.mysql_root['x86_64'] = Normalize(self.mysql_root['x86_64'])

def configure(self):
builder.AddConfigureFile('pushbuild.txt')

Expand Down
4 changes: 0 additions & 4 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
parser = run.BuildParser(sourcePath=sys.path[0], api='2.2')
parser.options.add_argument('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None,
help='Root search folder for HL2SDKs')
parser.options.add_argument('--mysql-path', type=str, dest='mysql_path', default=None,
help='Path to MySQL 5')
parser.options.add_argument('--mysql64-path', type=str, dest='mysql64_path', default=None,
help='Path to 64-bit MySQL 5')
parser.options.add_argument('--mms-path', type=str, dest='mms_path', default=None,
help='Path to Metamod:Source')
parser.options.add_argument('--enable-debug', action='store_const', const='1', dest='debug',
Expand Down
38 changes: 22 additions & 16 deletions extensions/mysql/AMBuilder
Original file line number Diff line number Diff line change
@@ -1,33 +1,45 @@
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
import os

if SM.mysql_root:
if builder.options.hasMySql:
libmariadb = builder.Build('mariadb/AMBuilder')
libopenssl = {}
if os.name != 'nt':
libopenssl = builder.Build('openssl/AMBuilder')

for cxx in builder.targets:
arch = cxx.target.arch
binary = SM.ExtLibrary(builder, cxx, 'dbi.mysql.ext')
binary.compiler.cxxincludes += [
os.path.join(SM.mysql_root[arch], 'include'),
os.path.join(SM.mms_root, 'core', 'sourcehook')
os.path.join(SM.mms_root, 'core', 'sourcehook'),
os.path.join(builder.sourcePath, 'extensions', 'mysql', 'mariadb', 'include'),
os.path.join(builder.sourcePath, 'extensions', 'mysql', 'mariadb', 'connector', 'include'),
]
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['-fno-rtti']
elif binary.compiler.family == 'msvc':
binary.compiler.cxxflags += ['/GR-']

if binary.compiler.target.platform == 'linux' or binary.compiler.target.platform == 'mac':
binary.compiler.postlink += [
libmariadb[arch].binary,
]

if binary.compiler.target.platform == 'linux':
binary.compiler.postlink += [
os.path.join(SM.mysql_root[arch], 'lib', 'libmysqlclient_r.a'),
'-lz',
'-lpthread',
'-lm',
'-lrt',
libopenssl['ssl-' + arch].binary,
libopenssl['crypto-' + arch].binary,
]
if binary.compiler.target.platform == 'linux':
binary.compiler.postlink += ['-lrt']
elif binary.compiler.target.platform == 'windows':
binary.compiler.defines += ['WIN32_LEAN_AND_MEAN']
binary.compiler.postlink += [
os.path.join(SM.mysql_root[arch], 'lib', 'mysqlclient.lib'),
'wsock32.lib'
'ws2_32.lib',
'shlwapi.lib',
'crypt32.lib',
'secur32.lib',
]

binary.sources += [
Expand All @@ -39,11 +51,5 @@ if SM.mysql_root:
'mysql/MyStatement.cpp',
'extension.cpp'
]

if binary.compiler.family == 'msvc' and binary.compiler.version >= 1900:
binary.sources += [ 'msvc15hack.c' ]
binary.compiler.linkflags += ['legacy_stdio_definitions.lib', 'legacy_stdio_wide_specifiers.lib']
binary.compiler.defines += ['HAVE_STRUCT_TIMESPEC']

SM.extensions += [builder.Add(binary)]

SM.extensions += [builder.Add(binary)]
106 changes: 106 additions & 0 deletions extensions/mysql/mariadb/AMBuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# vim: sts=2 ts=8 sw=2 tw=99 et ft=python:
import os, platform

builder.SetBuildFolder('libmariadb')

rvalue = {}
for cxx in builder.targets:
binary = SM.StaticLibrary(builder, cxx, 'mariadb')
binary.compiler.includes += [
os.path.join(builder.sourcePath, 'extensions', 'mysql', 'mariadb', 'include'),
os.path.join(builder.sourcePath, 'extensions', 'mysql', 'mariadb', 'connector', 'include'),
os.path.join(builder.sourcePath, 'extensions', 'mysql', 'mariadb', 'connector', 'libmariadb'),
os.path.join(builder.sourcePath, 'extensions', 'mysql', 'mariadb', 'connector', 'external', 'zlib'),

os.path.join(builder.sourcePath, 'extensions', 'mysql', 'openssl', 'include'),
os.path.join(builder.sourcePath, 'extensions', 'mysql', 'openssl', 'lib', 'include'),
]

binary.compiler.defines += [
'HAVE_COMPRESS',
'LIBMARIADB',
'THREAD',
]
# Work around mariadb warnings.
if binary.compiler.target.platform == 'linux':
binary.compiler.cflags += [
'-Wno-shift-count-overflow',
'-Wno-tautological-constant-out-of-range-compare',
]

binary.sources += [
'connector/plugins/auth/my_auth.c',
'connector/plugins/auth/old_password.c',
'connector/plugins/compress/c_zlib.c',
'connector/plugins/pvio/pvio_socket.c',
'connector/libmariadb/ma_array.c',
'connector/libmariadb/ma_charset.c',
'connector/libmariadb/ma_decimal.c',
'connector/libmariadb/ma_hashtbl.c',
'connector/libmariadb/ma_net.c',
'connector/libmariadb/mariadb_charset.c',
'connector/libmariadb/ma_time.c',
'connector/libmariadb/ma_default.c',
'connector/libmariadb/ma_errmsg.c',
'connector/libmariadb/mariadb_lib.c',
'connector/libmariadb/ma_list.c',
'connector/libmariadb/ma_pvio.c',
'connector/libmariadb/ma_tls.c',
'connector/libmariadb/ma_alloc.c',
'connector/libmariadb/ma_compress.c',
'connector/libmariadb/ma_init.c',
'connector/libmariadb/ma_password.c',
'connector/libmariadb/ma_ll2str.c',
'connector/libmariadb/ma_sha1.c',
'connector/libmariadb/mariadb_stmt.c',
'connector/libmariadb/ma_loaddata.c',
'connector/libmariadb/ma_stmt_codec.c',
'connector/libmariadb/ma_string.c',
'connector/libmariadb/ma_dtoa.c',
'connector/libmariadb/mariadb_rpl.c',
'connector/libmariadb/ma_io.c',
'connector/libmariadb/mariadb_async.c',
'connector/libmariadb/ma_context.c',
'ma_client_plugin.c',
]

if binary.compiler.target.platform == 'linux':
# TLS
binary.compiler.defines += [
'HAVE_OPENSSL', 'HAVE_TLS'
]
binary.sources += [
'connector/libmariadb/secure/openssl.c',
]
elif binary.compiler.target.platform == 'windows':
binary.compiler.defines += [
'HAVE_DLOPEN',
'_CRT_SECURE_NO_WARNINGS',
'_CRT_NONSTDC_NO_DEPRECATE',
'HAVE_SCHANNEL', 'HAVE_TLS'
]
binary.sources += [
'connector/libmariadb/win32_errmsg.c',
# TLS
'connector/libmariadb/secure/schannel.c',
'connector/libmariadb/secure/ma_schannel.c',
'connector/libmariadb/secure/schannel_certs.c',
# ZLIB
'connector/external/zlib/adler32.c',
'connector/external/zlib/compress.c',
'connector/external/zlib/crc32.c',
'connector/external/zlib/deflate.c',
'connector/external/zlib/gzclose.c',
'connector/external/zlib/gzlib.c',
'connector/external/zlib/gzread.c',
'connector/external/zlib/gzwrite.c',
'connector/external/zlib/infback.c',
'connector/external/zlib/inffast.c',
'connector/external/zlib/inflate.c',
'connector/external/zlib/inftrees.c',
'connector/external/zlib/trees.c',
'connector/external/zlib/uncompr.c',
'connector/external/zlib/zutil.c',
]

rvalue[binary.compiler.target.arch] = builder.Add(binary)
1 change: 1 addition & 0 deletions extensions/mysql/mariadb/connector
Submodule connector added at 458a43
Loading