Skip to content

Commit 8f6ba68

Browse files
committed
fix: load libs from ../Frameworks on macOS
Refs #2238
1 parent 5f39a44 commit 8f6ba68

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

source/apphelpers.pas

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ TAppSettings = class(TObject)
357357
function FormatTimeNumber(Seconds: Double; DisplaySeconds: Boolean; MilliSecondsPrecision: Integer=1): String;
358358
//function GetTempDir: String;
359359
function GetAppDir: String;
360+
function GetLibDir: String;
360361
procedure SaveUnicodeFile(Filename: String; Text: String; Encoding: TEncoding);
361362
procedure OpenTextFile(const Filename: String; out Stream: TFileStream; var Encoding: TEncoding);
362363
function DetectEncoding(Stream: TStream): TEncoding;
@@ -1303,6 +1304,19 @@ function GetAppDir: String;
13031304
Result := ExtractFilePath(Application.ExeName);
13041305
end;
13051306

1307+
function GetLibDir: String;
1308+
begin
1309+
{$IFDEF WINDOWS}
1310+
Result := GetAppDir;
1311+
{$ENDIF}
1312+
{$IFDEF DARWIN}
1313+
Result := GetAppDir + '..' + DirectorySeparator + 'Frameworks' + DirectorySeparator;
1314+
{$ENDIF}
1315+
{$IFDEF LINUX}
1316+
Result := '';
1317+
{$ENDIF}
1318+
end;
1319+
13061320
{**
13071321
Save a textfile with unicode
13081322
}

source/dbconnection.pas

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,9 +1949,9 @@ function TConnectionParameters.GetLibraries: TStringList;
19491949
rx.Expression := '^\s*(libsqlite3)[^=]+=>\s*(\S+)$';
19501950
{$Else}
19511951
if NetType = ntSQLite then
1952-
rx.Expression := '^sqlite.*\.' + SharedSuffix
1952+
rx.Expression := '^(lib)?sqlite.*\.' + SharedSuffix
19531953
else
1954-
rx.Expression := '^sqlite3mc.*\.' + SharedSuffix;
1954+
rx.Expression := '^(lib)?sqlite3mc.*\.' + SharedSuffix;
19551955
{$EndIf}
19561956
end;
19571957
ngInterbase:
@@ -1969,7 +1969,7 @@ function TConnectionParameters.GetLibraries: TStringList;
19691969
end;
19701970
end;
19711971
{$Else}
1972-
Dlls := FindAllFiles(GetAppDir, '*.' + SharedSuffix, False);
1972+
Dlls := FindAllFiles(GetLibDir, '*.' + SharedSuffix, False);
19731973
for DllPath in Dlls do begin
19741974
DllFile := ExtractFileName(DllPath);
19751975
if rx.Exec(DllFile) then begin
@@ -3300,7 +3300,7 @@ procedure TMySQLConnection.DoBeforeConnect;
33003300
LibraryPath: String;
33013301
begin
33023302
// Init libmysql before actually connecting.
3303-
LibraryPath := {$IFNDEF LINUX}GetAppDir + {$ENDIF} Parameters.LibraryOrProvider;
3303+
LibraryPath := GetLibDir + Parameters.LibraryOrProvider;
33043304
Log(lcDebug, f_('Loading library file %s ...', [LibraryPath]));
33053305
// Throws EDbError on any failure:
33063306
FLib := TMySQLLib.Create(LibraryPath, Parameters.DefaultLibrary);
@@ -3315,7 +3315,7 @@ procedure TPgConnection.DoBeforeConnect;
33153315
msg: String;
33163316
begin
33173317
// Init lib before actually connecting.
3318-
LibraryPath := {$IFNDEF LINUX}GetAppDir + {$ENDIF} Parameters.LibraryOrProvider;
3318+
LibraryPath := GetLibDir + Parameters.LibraryOrProvider;
33193319
Log(lcDebug, f_('Loading library file %s ...', [LibraryPath]));
33203320
try
33213321
FLib := TPostgreSQLLib.Create(LibraryPath, Parameters.DefaultLibrary);
@@ -3346,7 +3346,7 @@ procedure TSQLiteConnection.DoBeforeConnect;
33463346
LibraryPath: String;
33473347
begin
33483348
// Init lib before actually connecting.
3349-
LibraryPath := {$IFNDEF LINUX}GetAppDir + {$ENDIF} Parameters.LibraryOrProvider;
3349+
LibraryPath := GetLibDir + Parameters.LibraryOrProvider;
33503350
Log(lcDebug, f_('Loading library file %s ...', [LibraryPath]));
33513351
// Throws EDbError on any failure:
33523352
if Parameters.NetType = ntSQLite then

0 commit comments

Comments
 (0)