mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 20:21:04 +02:00
IDE: fpc msg parser: use Compiling
git-svn-id: trunk@45143 -
This commit is contained in:
parent
e530415577
commit
772e4d235b
@ -36,6 +36,8 @@ uses
|
|||||||
DirectoryCacher, BasicCodeTools, DefineTemplates, LazUTF8, FileUtil,
|
DirectoryCacher, BasicCodeTools, DefineTemplates, LazUTF8, FileUtil,
|
||||||
etMakeMsgParser, EnvironmentOpts;
|
etMakeMsgParser, EnvironmentOpts;
|
||||||
|
|
||||||
|
const
|
||||||
|
FPCMsgIDLogo = 11023;
|
||||||
type
|
type
|
||||||
TFPCMsgFilePool = class;
|
TFPCMsgFilePool = class;
|
||||||
|
|
||||||
@ -982,7 +984,7 @@ begin
|
|||||||
|
|
||||||
fLineToMsgID.Clear;
|
fLineToMsgID.Clear;
|
||||||
// FPC logo lines
|
// FPC logo lines
|
||||||
Item:=MsgFile.GetMsg(11023);
|
Item:=MsgFile.GetMsg(FPCMsgIDLogo);
|
||||||
if Item<>nil then
|
if Item<>nil then
|
||||||
fLineToMsgID.AddLines(Item.Pattern,Item.ID);
|
fLineToMsgID.AddLines(Item.Pattern,Item.ID);
|
||||||
// Linking <progname>
|
// Linking <progname>
|
||||||
@ -1002,23 +1004,35 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TIDEFPCParser.CheckForCompilingState(p: PChar): boolean;
|
function TIDEFPCParser.CheckForCompilingState(p: PChar): boolean;
|
||||||
|
const
|
||||||
|
FPCMsgIDCompiling = 3104;
|
||||||
var
|
var
|
||||||
AFilename: string;
|
AFilename: string;
|
||||||
MsgLine: TMessageLine;
|
MsgLine: TMessageLine;
|
||||||
OldP: PChar;
|
OldP: PChar;
|
||||||
begin
|
begin
|
||||||
Result:=fMsgID=3104;
|
|
||||||
if (fMsgID>0) and not Result then exit;
|
|
||||||
OldP:=p;
|
OldP:=p;
|
||||||
if not CompStr('Compiling ',p) then exit;
|
|
||||||
// for example 'Compiling ./subdir/unit1.pas'
|
// for example 'Compiling ./subdir/unit1.pas'
|
||||||
|
if fMsgID=0 then begin
|
||||||
|
if not ReadString(p,'Compiling ') then exit(false);
|
||||||
|
fMsgID:=FPCMsgIDCompiling;
|
||||||
|
Result:=true;
|
||||||
|
end else if fMsgID=FPCMsgIDCompiling then begin
|
||||||
|
Result:=true;
|
||||||
|
if not ReadString(p,'Compiling ') then exit;
|
||||||
|
end else begin
|
||||||
|
exit(false);
|
||||||
|
end;
|
||||||
// add path to history
|
// add path to history
|
||||||
if DirectoryStack=nil then DirectoryStack:=TStringList.Create;
|
|
||||||
inc(p,length('Compiling '));
|
|
||||||
if (p^='.') and (p[1]=PathDelim) then
|
if (p^='.') and (p[1]=PathDelim) then
|
||||||
inc(p,2); // skip ./
|
inc(p,2); // skip ./
|
||||||
AFilename:=TrimFilename(p);
|
AFilename:=ExtractFilePath(TrimFilename(p));
|
||||||
//DirectoryStack.Add(AFilename);
|
if AFilename<>'' then begin
|
||||||
|
if DirectoryStack=nil then DirectoryStack:=TStringList.Create;
|
||||||
|
if (DirectoryStack.Count=0)
|
||||||
|
or (DirectoryStack[DirectoryStack.Count-1]<>AFilename) then
|
||||||
|
DirectoryStack.Add(AFilename);
|
||||||
|
end;
|
||||||
MsgLine:=CreateMsgLine;
|
MsgLine:=CreateMsgLine;
|
||||||
MsgLine.Urgency:=mluProgress;
|
MsgLine.Urgency:=mluProgress;
|
||||||
MsgLine.SubTool:=SubToolFPC;
|
MsgLine.SubTool:=SubToolFPC;
|
||||||
@ -1419,6 +1433,11 @@ begin
|
|||||||
i:=fLineToMsgID.LineToMsgID(p);
|
i:=fLineToMsgID.LineToMsgID(p);
|
||||||
if i=0 then exit;
|
if i=0 then exit;
|
||||||
fMsgID:=i;
|
fMsgID:=i;
|
||||||
|
if (fMsgID=FPCMsgIDLogo) and (DirectoryStack<>nil) then begin
|
||||||
|
// a new call of the compiler (e.g. when compiling via make)
|
||||||
|
// => clear stack
|
||||||
|
FreeAndNil(DirectoryStack);
|
||||||
|
end;
|
||||||
MsgItem:=MsgFile.GetMsg(fMsgID);
|
MsgItem:=MsgFile.GetMsg(fMsgID);
|
||||||
if MsgItem=nil then exit;
|
if MsgItem=nil then exit;
|
||||||
Result:=true;
|
Result:=true;
|
||||||
@ -2019,8 +2038,6 @@ begin
|
|||||||
if CheckForMsgId(p) then exit;
|
if CheckForMsgId(p) then exit;
|
||||||
// check for 'filename(line,column) Error: message'
|
// check for 'filename(line,column) Error: message'
|
||||||
if CheckForFileLineColMessage(p) then exit;
|
if CheckForFileLineColMessage(p) then exit;
|
||||||
// check for infos (logo, Linking <Progname>)
|
|
||||||
if CheckForInfos(p) then exit;
|
|
||||||
// check for 'Compiling <filename>'
|
// check for 'Compiling <filename>'
|
||||||
if CheckForCompilingState(p) then exit;
|
if CheckForCompilingState(p) then exit;
|
||||||
// check for 'Assembling <filename>'
|
// check for 'Assembling <filename>'
|
||||||
@ -2031,6 +2048,8 @@ begin
|
|||||||
if CheckForLineProgress(p) then exit;
|
if CheckForLineProgress(p) then exit;
|
||||||
// check for '<int> Lines compiled, <int>.<int> sec'
|
// check for '<int> Lines compiled, <int>.<int> sec'
|
||||||
if CheckForLinesCompiled(p) then exit;
|
if CheckForLinesCompiled(p) then exit;
|
||||||
|
// check for infos (logo, Linking <Progname>)
|
||||||
|
if CheckForInfos(p) then exit;
|
||||||
// check for -vx output
|
// check for -vx output
|
||||||
if CheckForExecutableInfo(p) then exit;
|
if CheckForExecutableInfo(p) then exit;
|
||||||
// check for linking errors
|
// check for linking errors
|
||||||
@ -2048,71 +2067,30 @@ begin
|
|||||||
writeln('TFPCParser.ReadLine UNKNOWN: ',Line);
|
writeln('TFPCParser.ReadLine UNKNOWN: ',Line);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Handled:=false;
|
Handled:=false;
|
||||||
|
|
||||||
{
|
|
||||||
else if (not CompilerOptions.ShowHintsForUnusedUnitsInMainSrc) then
|
|
||||||
begin
|
|
||||||
MainSrcFilename:=CompilerOptions.GetDefaultMainSourceFileName;
|
|
||||||
if (MainSrcFilename<>'')
|
|
||||||
and (IsHintForUnusedUnit(s,MainSrcFilename)) then
|
|
||||||
SkipMessage:=true;
|
|
||||||
if copy(s,j+2,length(s)-j-1)='Error while linking' then begin
|
|
||||||
DoAddLastLinkerMessages(true);
|
|
||||||
end
|
|
||||||
else if copy(s,j+2,length(AsmError))=AsmError then begin
|
|
||||||
DoAddLastAssemblerMessages;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// beautify compiler message
|
|
||||||
|
|
||||||
// the compiler always gives short filenames, even if it went into a
|
|
||||||
// subdirectory
|
|
||||||
// -> prepend the current subdirectory
|
|
||||||
Msg:=s;
|
|
||||||
Filename:=TrimFilename(copy(Msg,1,FilenameEndPos));
|
|
||||||
if not FilenameIsAbsolute(Filename) then begin
|
|
||||||
// filename is relative
|
|
||||||
i:=-1;
|
|
||||||
if (fCompilingHistory<>nil) then begin
|
|
||||||
// the compiler writes a line compiling ./subdir/unit.pas
|
|
||||||
// and then writes the messages without any path
|
|
||||||
// -> prepend this subdirectory
|
|
||||||
i:=fCompilingHistory.Count-1;
|
|
||||||
while (i>=0) do begin
|
|
||||||
CurCompHistory:=fCompilingHistory[i];
|
|
||||||
CurCompHistLen:=length(CurCompHistory);
|
|
||||||
CurFilenameLen:=length(Filename);
|
|
||||||
j:=CurCompHistLen-CurFilenameLen;
|
|
||||||
if (j>1) and (CurCompHistory[j]=PathDelim)
|
|
||||||
and (CompareFilenames(
|
|
||||||
copy(CurCompHistory,j+1,CurFilenameLen),Filename)=0) then
|
|
||||||
begin
|
|
||||||
Msg:=copy(CurCompHistory,1,j)+Msg;
|
|
||||||
inc(FilenameEndPos,j);
|
|
||||||
break;
|
|
||||||
end;
|
|
||||||
dec(i);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
if i<0 then begin
|
|
||||||
// this file is not a compiled pascal source
|
|
||||||
// -> search for include files
|
|
||||||
Filename:=SearchIncludeFile(Filename);
|
|
||||||
Msg:=Filename+copy(Msg,FileNameEndPos+1,length(Msg)-FileNameEndPos);
|
|
||||||
FileNameEndPos:=length(Filename);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TIDEFPCParser.LongenFilename(aFilename: string): string;
|
function TIDEFPCParser.LongenFilename(aFilename: string): string;
|
||||||
|
var
|
||||||
|
ShortFilename: String;
|
||||||
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
Result:=TrimFilename(aFilename);
|
Result:=TrimFilename(aFilename);
|
||||||
if FilenameIsAbsolute(Result) then exit;
|
if FilenameIsAbsolute(Result) then exit;
|
||||||
if Tool.WorkerDirectory<>'' then begin
|
ShortFilename:=Result;
|
||||||
Result:=AppendPathDelim(Tool.WorkerDirectory)+Result;
|
// seach file in the last compiling directories
|
||||||
|
if DirectoryStack<>nil then begin
|
||||||
|
for i:=DirectoryStack.Count-1 downto 0 do begin
|
||||||
|
Result:=AppendPathDelim(DirectoryStack[i])+ShortFilename;
|
||||||
|
if FileExists(Result,false) then exit;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
// search file in worker directory
|
||||||
|
if Tool.WorkerDirectory<>'' then begin
|
||||||
|
Result:=AppendPathDelim(Tool.WorkerDirectory)+ShortFilename;
|
||||||
|
if FileExists(Result,false) then exit;
|
||||||
|
end;
|
||||||
|
// file not found
|
||||||
|
Result:=ShortFilename;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIDEFPCParser.ImproveMessages(aSynchronized: boolean);
|
procedure TIDEFPCParser.ImproveMessages(aSynchronized: boolean);
|
||||||
|
@ -3535,6 +3535,7 @@ begin
|
|||||||
PkgCompileTool.Data:=TIDEExternalToolData.Create(IDEToolCompilePackage,
|
PkgCompileTool.Data:=TIDEExternalToolData.Create(IDEToolCompilePackage,
|
||||||
APackage.Name,APackage.Filename);
|
APackage.Name,APackage.Filename);
|
||||||
PkgCompileTool.FreeData:=true;
|
PkgCompileTool.FreeData:=true;
|
||||||
|
|
||||||
// check if main ppu file was created
|
// check if main ppu file was created
|
||||||
SrcPPUFile:=APackage.GetSrcPPUFilename;
|
SrcPPUFile:=APackage.GetSrcPPUFilename;
|
||||||
SrcPPUFileExists:=(SrcPPUFile<>'') and FileExistsUTF8(SrcPPUFile);
|
SrcPPUFileExists:=(SrcPPUFile<>'') and FileExistsUTF8(SrcPPUFile);
|
||||||
|
Loading…
Reference in New Issue
Block a user