ide: fixed overriding lazarusdir via cfg file

This commit is contained in:
mattias 2024-10-24 15:13:34 +02:00
parent 90584b2d07
commit 505c8d4619
2 changed files with 18 additions and 9 deletions

View File

@ -1266,17 +1266,15 @@ begin
AddDefaultRecentProjects; // Add some initial recent projects.
// read language and lazarusdir parameters, needed for translation
if Application.HasOption('language') then
if GetParamOptionPlusValue('--language=',s) then
begin
debugln('Hint: (lazarus) [TMainIDE.LoadGlobalOptions] overriding language with command line: ',
Application.GetOptionValue('language'));
EnvironmentOptions.LanguageID := Application.GetOptionValue('language');
debugln('Hint: (lazarus) [TMainIDE.LoadGlobalOptions] overriding language with command line: ',s);
EnvironmentOptions.LanguageID := s;
end;
if Application.HasOption('lazarusdir') then
if GetParamOptionPlusValue('--lazarusdir=',s) then
begin
debugln('Hint: (lazarus) [TMainIDE.LoadGlobalOptions] overriding Lazarusdir with command line: ',
Application.GetOptionValue('lazarusdir'));
EnvironmentOptions.Lazarusdirectory:= Application.GetOptionValue('lazarusdir');
debugln('Hint: (lazarus) [TMainIDE.LoadGlobalOptions] overriding Lazarusdir with command line: ',s);
EnvironmentOptions.Lazarusdirectory:= s;
end;
// translate IDE resourcestrings

View File

@ -122,6 +122,7 @@ function ParamIsOption(ParamIndex : integer; const Option : string) : boolean; o
function ParamIsOption(ParamIndex : integer; const OptionShort, OptionLong: string) : boolean; overload; // case insensitive
function ParamIsOptionPlusValue(ParamIndex : integer;
const Option : string; out AValue : string) : boolean;
function GetParamOptionPlusValue(const Option: string; out AValue: string): boolean; overload; // case insensitive
procedure ParseNoGuiCmdLineParams;
@ -354,7 +355,7 @@ begin
end;
end;
function GetCommandLineParameters(aCmdLineParams : TStrings; isStartLazarus : Boolean = False) : String;
function GetCommandLineParameters(aCmdLineParams: TStrings; isStartLazarus: Boolean): string;
var
i: Integer;
s: String;
@ -475,6 +476,16 @@ begin
AValue := '';
end;
function GetParamOptionPlusValue(const Option: string; out AValue: string): boolean;
var
i: Integer;
begin
AValue:='';
for i:=1 to ParamsAndCfgCount do
if ParamIsOptionPlusValue(i,Option,AValue) then exit(true);
Result:=false;
end;
procedure ParseNoGuiCmdLineParams;
var
i : integer;