Skip to content

Commit 85a15f8

Browse files
committed
feat: include libmysql plugins in macOS app bundle
1 parent 2967ad2 commit 85a15f8

File tree

3 files changed

+35
-32
lines changed

3 files changed

+35
-32
lines changed

create-macos-app.sh

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,15 @@ MYSQL_LIB_DIR="${BREW_PREFIX}/opt/mysql-client/lib"
4444
PG_LIB_DIR="${BREW_PREFIX}/opt/libpq/lib"
4545
SQLITE_LIB_DIR="${BREW_PREFIX}/opt/sqlite/lib"
4646
MARIADB_LIB_DIR="${BREW_PREFIX}/opt/mariadb-connector-c/lib"
47+
MYSQL_PLUGIN_DIR="${MYSQL_LIB_DIR}/plugin"
4748
MARIADB_PLUGIN_DIR="${MARIADB_LIB_DIR}/mariadb/plugin"
48-
MARIADB_PLUGIN_DEST="${APP_DIR}/Contents/Frameworks/plugins"
4949

5050
### PREPARE APP BUNDLE STRUCTURE
5151

5252
rm -rf "${APP_DIR}"
5353
mkdir -p "${APP_DIR}/Contents/MacOS"
5454
mkdir -p "${APP_DIR}/Contents/Resources"
55-
mkdir -p "${APP_DIR}/Contents/Frameworks" # where we will put .dylib files
56-
mkdir -p "${MARIADB_PLUGIN_DEST}"
55+
mkdir -p "${APP_DIR}/Contents/Frameworks" # where we will put .dylib and .so files
5756

5857
# Copy main executable
5958
cp "${EXECUTABLE_SRC}" "${EXECUTABLE_TRG}"
@@ -196,27 +195,26 @@ else
196195
fi
197196

198197
# MARIADB PLUGIN .so FILES
199-
if [[ -d "${MARIADB_PLUGIN_DIR}" ]]; then
200-
echo "Copying MariaDB plugins from ${MARIADB_PLUGIN_DIR}..."
201-
mkdir -p "${MARIADB_PLUGIN_DEST}"
202-
203-
# Copy all .so plugins into the app plugin directory
204-
for so in "${MARIADB_PLUGIN_DIR}"/*.so; do
205-
[[ -f "${so}" ]] || continue
206-
base="$(basename "${so}")"
207-
dest_so="${MARIADB_PLUGIN_DEST}/${base}"
208-
209-
echo " Copying plugin ${so} -> ${dest_so}"
210-
cp "${so}" "${dest_so}"
211-
chmod u+w "${dest_so}"
212-
213-
# Fix plugin’s own deps and copy any non-system libs into Frameworks
214-
copy_and_rewrite_dylib "${dest_so}"
198+
if ls "${MARIADB_PLUGIN_DIR}"/*.so >/dev/null 2>&1; then
199+
for f in "${MARIADB_PLUGIN_DIR}"/*.so; do
200+
[[ -f "${f}" ]] || continue
201+
copy_and_rewrite_dylib "${f}"
215202
done
216203
else
217204
echo "WARNING: MariaDB plugin directory not found: ${MARIADB_PLUGIN_DIR}" >&2
218205
fi
219206

207+
# MYSQL PLUGIN .so FILES
208+
if ls "${MYSQL_PLUGIN_DIR}"/*.so >/dev/null 2>&1; then
209+
for f in "${MYSQL_PLUGIN_DIR}"/*.so; do
210+
[[ -f "${f}" ]] || continue
211+
copy_and_rewrite_dylib "${f}"
212+
done
213+
else
214+
echo "WARNING: MySQL plugin directory not found: ${MYSQL_PLUGIN_DIR}" >&2
215+
fi
216+
217+
220218
### FIX MAIN EXECUTABLE’S REFERENCES TO CLIENT LIBS
221219

222220
# Helper: rewrite dependency of the main executable to bundled Frameworks
@@ -238,7 +236,7 @@ rewrite_exe_dep "libmysqlclient"
238236
rewrite_exe_dep "libpq"
239237
rewrite_exe_dep "libsqlite3"
240238
rewrite_exe_dep "libmariadb"
241-
239+
rewrite_exe_dep "libssl.3"
242240

243241
### DOWNLOAD AND EXTRACT LOCALE FILES
244242

source/dbconnection.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2456,7 +2456,7 @@ procedure TMySQLConnection.SetActive( Value: Boolean );
24562456

24572457
if not GetLibDir.IsEmpty then begin
24582458
// Point libmysql to the folder with client plugins
2459-
PluginDir := AnsiString(GetLibDir+'plugins');
2459+
PluginDir := AnsiString(GetLibDir);
24602460
SetOption(FLib.MYSQL_PLUGIN_DIR, PAnsiChar(PluginDir));
24612461
end;
24622462

source/dbstructures.mysql.pas

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3134,6 +3134,8 @@ implementation
31343134

31353135

31363136
constructor TMySQLLib.Create(UsedDllFile, HintDefaultDll: String);
3137+
var
3138+
LibMajorVer: String;
31373139
begin
31383140
inherited;
31393141
// MYSQL_OPT_* constants
@@ -3161,17 +3163,20 @@ constructor TMySQLLib.Create(UsedDllFile, HintDefaultDll: String);
31613163
MYSQL_OPT_SSL_VERIFY_SERVER_CERT := 21;
31623164
MARIADB_OPT_TLS_VERSION := 7005;
31633165
end
3164-
else if String(mysql_get_client_info).StartsWith('8.') then begin
3165-
// Some constants were removed in MySQL 8.0, so the offsets differ
3166-
MYSQL_PLUGIN_DIR := 16;
3167-
MYSQL_OPT_SSL_KEY := 19;
3168-
MYSQL_OPT_SSL_CERT := 20;
3169-
MYSQL_OPT_SSL_CA := 21;
3170-
MYSQL_OPT_SSL_CIPHER := 23;
3171-
MYSQL_OPT_CONNECT_ATTR_ADD := 27;
3172-
MYSQL_ENABLE_CLEARTEXT_PLUGIN := 30;
3173-
MYSQL_OPT_TLS_VERSION := 34;
3174-
MYSQL_OPT_SSL_MODE := 35;
3166+
else begin
3167+
LibMajorVer := String(mysql_get_client_info);
3168+
if LibMajorVer.StartsWith('8.') or LibMajorVer.StartsWith('9.') then begin
3169+
// Some constants were removed in MySQL 8.0, so the offsets differ
3170+
MYSQL_PLUGIN_DIR := 16;
3171+
MYSQL_OPT_SSL_KEY := 19;
3172+
MYSQL_OPT_SSL_CERT := 20;
3173+
MYSQL_OPT_SSL_CA := 21;
3174+
MYSQL_OPT_SSL_CIPHER := 23;
3175+
MYSQL_OPT_CONNECT_ATTR_ADD := 27;
3176+
MYSQL_ENABLE_CLEARTEXT_PLUGIN := 30;
3177+
MYSQL_OPT_TLS_VERSION := 34;
3178+
MYSQL_OPT_SSL_MODE := 35;
3179+
end;
31753180
end;
31763181
end;
31773182

0 commit comments

Comments
 (0)