mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 18:59:21 +02:00
ide: fixed keep WriteConfigFile on cancel, fixed keeping order in config, except for search paths
This commit is contained in:
parent
ac3e802b81
commit
e375a961ce
@ -2994,6 +2994,8 @@ begin
|
|||||||
|
|
||||||
// Other
|
// Other
|
||||||
fDontUseConfigFile := CompOpts.fDontUseConfigFile;
|
fDontUseConfigFile := CompOpts.fDontUseConfigFile;
|
||||||
|
FWriteConfigFile := CompOpts.FWriteConfigFile;
|
||||||
|
FWriteConfigFilePath := CompOpts.FWriteConfigFilePath;
|
||||||
fCustomConfigFile := CompOpts.fCustomConfigFile;
|
fCustomConfigFile := CompOpts.fCustomConfigFile;
|
||||||
fConfigFilePath := CompOpts.fConfigFilePath;
|
fConfigFilePath := CompOpts.fConfigFilePath;
|
||||||
fStopAfterErrCount := CompOpts.fStopAfterErrCount;
|
fStopAfterErrCount := CompOpts.fStopAfterErrCount;
|
||||||
|
@ -741,25 +741,60 @@ end;
|
|||||||
|
|
||||||
function WriteCompilerCfgFile(CfgFilename: string; CompilerParams: TStrings;
|
function WriteCompilerCfgFile(CfgFilename: string; CompilerParams: TStrings;
|
||||||
out CmdLineParams: TStrings): TCodeBuffer;
|
out CmdLineParams: TStrings): TCodeBuffer;
|
||||||
|
|
||||||
|
function GetPathOpt(const Param: string): char;
|
||||||
|
begin
|
||||||
|
Result:=' ';
|
||||||
|
if length(Param)<3 then exit;
|
||||||
|
if (Param[1]<>'-') or (Param[2]<>'F') then exit;
|
||||||
|
Result:=Param[3];
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
Src, Param: String;
|
Src, Param: String;
|
||||||
i: Integer;
|
i, First, Cnt, j: Integer;
|
||||||
|
Opt: Char;
|
||||||
begin
|
begin
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
|
|
||||||
|
// search paths like -Fu have reverse order in fpc's cfg file
|
||||||
|
// otherwise the params must keep the order!
|
||||||
|
// For example linker options -k must keep the order
|
||||||
|
// and an -FU after -Fu must stay after -Fu
|
||||||
|
|
||||||
|
// create Src and CmdLineParams
|
||||||
CmdLineParams:=TStringListUTF8Fast.Create;
|
CmdLineParams:=TStringListUTF8Fast.Create;
|
||||||
CmdLineParams.Add('@'+CfgFilename);
|
CmdLineParams.Add('@'+CfgFilename);
|
||||||
Src:='# Auto generated by Lazarus. Do not edit.'+LineEnding;
|
Src:='# Auto generated by Lazarus. Do not edit.'+LineEnding;
|
||||||
|
Cnt:=CompilerParams.Count;
|
||||||
|
i:=0;
|
||||||
|
while i<Cnt do
|
||||||
|
begin
|
||||||
|
Param:=CompilerParams[i];
|
||||||
|
if (Param='-n') or (Param[1]<>'-') then
|
||||||
|
CmdLineParams.Add(Param)
|
||||||
|
else begin
|
||||||
|
Opt:=GetPathOpt(Param);
|
||||||
|
if Opt<>' ' then
|
||||||
|
begin
|
||||||
|
// path option -F<Opt>
|
||||||
|
// -> add in reverse order
|
||||||
|
First:=i;
|
||||||
|
while (i+1<Cnt) and (GetPathOpt(CompilerParams[i+1])=Opt) do inc(i);
|
||||||
|
for j:=i downto First do
|
||||||
|
Src+=CompilerParams[j]+LineEnding;
|
||||||
|
end else
|
||||||
|
Src+=Param+LineEnding;
|
||||||
|
end;
|
||||||
|
inc(i);
|
||||||
|
end;
|
||||||
|
|
||||||
|
// clean up CompilerParams
|
||||||
for i:=CompilerParams.Count-1 downto 0 do
|
for i:=CompilerParams.Count-1 downto 0 do
|
||||||
begin
|
begin
|
||||||
Param:=CompilerParams[i];
|
Param:=CompilerParams[i];
|
||||||
if (Param[1]='@')
|
if (Param='-n') or (Param[1]<>'-') then continue;
|
||||||
or (Param='n')
|
CompilerParams.Delete(i);
|
||||||
or (Param[1]<>'-') then
|
|
||||||
CmdLineParams.Insert(1,Param)
|
|
||||||
else begin
|
|
||||||
Src+=Param+LineEnding;
|
|
||||||
CompilerParams.Delete(i);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Result:=CodeToolBoss.LoadFile(CfgFilename,true,true);
|
Result:=CodeToolBoss.LoadFile(CfgFilename,true,true);
|
||||||
|
Loading…
Reference in New Issue
Block a user