Skip to content

Commit 2967ad2

Browse files
committed
feat: provide libmariadb plugins in macOS app bundle
1 parent 3ea4a90 commit 2967ad2

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

create-macos-app.sh

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,16 @@ 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-
47+
MARIADB_PLUGIN_DIR="${MARIADB_LIB_DIR}/mariadb/plugin"
48+
MARIADB_PLUGIN_DEST="${APP_DIR}/Contents/Frameworks/plugins"
4849

4950
### PREPARE APP BUNDLE STRUCTURE
5051

5152
rm -rf "${APP_DIR}"
5253
mkdir -p "${APP_DIR}/Contents/MacOS"
5354
mkdir -p "${APP_DIR}/Contents/Resources"
5455
mkdir -p "${APP_DIR}/Contents/Frameworks" # where we will put .dylib files
56+
mkdir -p "${MARIADB_PLUGIN_DEST}"
5557

5658
# Copy main executable
5759
cp "${EXECUTABLE_SRC}" "${EXECUTABLE_TRG}"
@@ -193,6 +195,27 @@ else
193195
echo "WARNING: No libmariadb*.dylib found in ${MARIADB_LIB_DIR}" >&2
194196
fi
195197

198+
# 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}"
215+
done
216+
else
217+
echo "WARNING: MariaDB plugin directory not found: ${MARIADB_PLUGIN_DIR}" >&2
218+
fi
196219

197220
### FIX MAIN EXECUTABLE’S REFERENCES TO CLIENT LIBS
198221

@@ -240,9 +263,9 @@ echo "Done. Bundled app is at: ${APP_DIR}"
240263
### SIGN ALL DYLIBS AND THE APP BUNDLE
241264

242265
echo "Signing embedded libraries..."
243-
find "${APP_DIR}/Contents" -type f -name "*.dylib" | while read -r dylib; do
244-
echo " Signing ${dylib}"
245-
codesign --force --options runtime --timestamp --sign "${CODESIGN_IDENTITY}" "${dylib}"
266+
find "${APP_DIR}/Contents" -type f \( -name "*.dylib" -o -name "*.so" \) | while read -r f; do
267+
echo " Signing ${f}"
268+
codesign --force --options runtime --timestamp --sign "${CODESIGN_IDENTITY}" "${f}"
246269
done
247270

248271
echo "Signing main app bundle..."

source/dbconnection.pas

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2454,11 +2454,11 @@ procedure TMySQLConnection.SetActive( Value: Boolean );
24542454
if Parameters.WantSSL and (not FLib.IsLibMariadb) then
24552455
ClientFlags := ClientFlags or CLIENT_SSL;
24562456

2457-
{$IfDef WINDOWS}
2458-
// Point libmysql to the folder with client plugins
2459-
PluginDir := AnsiString(GetAppDir+'plugins');
2460-
SetOption(FLib.MYSQL_PLUGIN_DIR, PAnsiChar(PluginDir));
2461-
{$EndIf}
2457+
if not GetLibDir.IsEmpty then begin
2458+
// Point libmysql to the folder with client plugins
2459+
PluginDir := AnsiString(GetLibDir+'plugins');
2460+
SetOption(FLib.MYSQL_PLUGIN_DIR, PAnsiChar(PluginDir));
2461+
end;
24622462

24632463
// Enable cleartext plugin
24642464
if Parameters.CleartextPluginEnabled then

0 commit comments

Comments
 (0)