ide: started checking for recompiling on second pass

This commit is contained in:
mattias 2024-10-13 17:31:57 +02:00
parent 5b818b586b
commit 8ba0de5d29

View File

@ -70,6 +70,8 @@ const
MakefileCompileVersion = 2; MakefileCompileVersion = 2;
// 2 : changed macro format from %() to $() // 2 : changed macro format from %() to $()
FPCMsgIDCompiling = 3104;
type type
TFindPackageFlag = ( TFindPackageFlag = (
fpfSearchInInstalledPckgs, fpfSearchInInstalledPckgs,
@ -151,7 +153,7 @@ type
CompilerFilename: string; CompilerFilename: string;
CompilerParams: TStrings; CompilerParams: TStrings;
ErrorMessage: string; ErrorMessage: string;
Run: integer; Pass: integer; // when compiling multiple times, this is the pass number
constructor Create(aKind, aModuleName, aFilename: string); override; constructor Create(aKind, aModuleName, aFilename: string); override;
destructor Destroy; override; destructor Destroy; override;
end; end;
@ -2146,13 +2148,18 @@ begin
end; end;
procedure TLazPackageGraph.ExtToolBuildStopped(Sender: TObject); procedure TLazPackageGraph.ExtToolBuildStopped(Sender: TObject);
const
FPCCompilingPattern = '(3104) Compiling ';
var var
PkgCompileTool: TAbstractExternalTool; PkgCompileTool: TAbstractExternalTool;
Data: TLazPkgGraphExtToolData; Data: TLazPkgGraphExtToolData;
aPackage: TLazPackage; aPackage: TLazPackage;
SrcF: String; SrcF, MainFilename, aFilename: String;
SrcPPUFileExists: Boolean; SrcPPUFileExists, FoundCompiling: Boolean;
MsgResult: TModalResult; MsgResult: TModalResult;
Msgs: TMessageLines;
i: Integer;
Msg: TMessageLine;
begin begin
PkgCompileTool:=Sender as TAbstractExternalTool; PkgCompileTool:=Sender as TAbstractExternalTool;
Data:=PkgCompileTool.Data as TLazPkgGraphExtToolData; Data:=PkgCompileTool.Data as TLazPkgGraphExtToolData;
@ -2176,7 +2183,7 @@ begin
if Data.ErrorMessage<>'' then exit; if Data.ErrorMessage<>'' then exit;
if Data.Run=0 then if Data.Pass=0 then
begin begin
// update .po files // update .po files
if (APackage.POOutputDirectory<>'') then begin if (APackage.POOutputDirectory<>'') then begin
@ -2190,6 +2197,44 @@ begin
exit; exit;
end; end;
end; end;
end else begin
// check for recompiled units on second compile
Msgs:=PkgCompileTool.WorkerMessages;
MainFilename:=aPackage.GetSrcFilename;
FoundCompiling:=false;
// check using parser data. Note: lazbuild skips parsers
for i:=0 to Msgs.Count-1 do
begin
Msg:=Msgs[i];
if (Msg.SubTool=SubToolFPC) and (Msg.MsgID=FPCMsgIDCompiling) then
begin
FoundCompiling:=true;
if CompareFilenames(Msg.Filename,MainFilename)<>0 then
begin
debugln(['Warning: (lazarus) [TLazPackageGraph.ExtToolBuildStopped] on second compile of "',aPackage.Name,'" the unit "',Msg.GetShortFilename,'" was recompiled']);
break;
end;
end;
end;
if not FoundCompiling then
begin
// check direct message texts
MainFilename:=ExtractFilename(MainFilename);
for i:=0 to Msgs.Count-1 do
begin
Msg:=Msgs[i];
if (LeftStr(Msg.Msg,length(FPCCompilingPattern))=FPCCompilingPattern) then
begin
FoundCompiling:=true;
aFilename:=ExtractFilename(copy(Msg.Msg,length(FPCCompilingPattern)+1));
if CompareFilenames(aFilename,MainFilename)<>0 then
begin
debugln(['Warning: (lazarus) [TLazPackageGraph.ExtToolBuildStopped] on second compile of "',aPackage.Name,'" the unit "',aFilename,'" was recompiled']);
break;
end;
end;
end;
end;
end; end;
end; end;
@ -4354,7 +4399,7 @@ function TLazPackageGraph.CompilePackage(APackage: TLazPackage;
ExtToolData.SrcPPUFilename:=APackage.GetSrcPPUFilename; ExtToolData.SrcPPUFilename:=APackage.GetSrcPPUFilename;
ExtToolData.CompilerFilename:=CompilerFilename; ExtToolData.CompilerFilename:=CompilerFilename;
ExtToolData.CompilerParams.Assign(CompilerParams); ExtToolData.CompilerParams.Assign(CompilerParams);
ExtToolData.Run:=Run; ExtToolData.Pass:=Run;
PkgCompileTool:=ExternalToolList.Add(Title); PkgCompileTool:=ExternalToolList.Add(Title);
PkgCompileTool.Data:=ExtToolData; PkgCompileTool.Data:=ExtToolData;