IDE: fpc msg parser: use Compiling

git-svn-id: trunk@45143 -
This commit is contained in:
mattias 2014-05-21 22:03:16 +00:00
parent e530415577
commit 772e4d235b
2 changed files with 47 additions and 68 deletions

View File

@ -36,6 +36,8 @@ uses
DirectoryCacher, BasicCodeTools, DefineTemplates, LazUTF8, FileUtil,
etMakeMsgParser, EnvironmentOpts;
const
FPCMsgIDLogo = 11023;
type
TFPCMsgFilePool = class;
@ -982,7 +984,7 @@ begin
fLineToMsgID.Clear;
// FPC logo lines
Item:=MsgFile.GetMsg(11023);
Item:=MsgFile.GetMsg(FPCMsgIDLogo);
if Item<>nil then
fLineToMsgID.AddLines(Item.Pattern,Item.ID);
// Linking <progname>
@ -1002,23 +1004,35 @@ begin
end;
function TIDEFPCParser.CheckForCompilingState(p: PChar): boolean;
const
FPCMsgIDCompiling = 3104;
var
AFilename: string;
MsgLine: TMessageLine;
OldP: PChar;
begin
Result:=fMsgID=3104;
if (fMsgID>0) and not Result then exit;
OldP:=p;
if not CompStr('Compiling ',p) then exit;
// 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
if DirectoryStack=nil then DirectoryStack:=TStringList.Create;
inc(p,length('Compiling '));
if (p^='.') and (p[1]=PathDelim) then
inc(p,2); // skip ./
AFilename:=TrimFilename(p);
//DirectoryStack.Add(AFilename);
AFilename:=ExtractFilePath(TrimFilename(p));
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.Urgency:=mluProgress;
MsgLine.SubTool:=SubToolFPC;
@ -1419,6 +1433,11 @@ begin
i:=fLineToMsgID.LineToMsgID(p);
if i=0 then exit;
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);
if MsgItem=nil then exit;
Result:=true;
@ -2019,8 +2038,6 @@ begin
if CheckForMsgId(p) then exit;
// check for 'filename(line,column) Error: message'
if CheckForFileLineColMessage(p) then exit;
// check for infos (logo, Linking <Progname>)
if CheckForInfos(p) then exit;
// check for 'Compiling <filename>'
if CheckForCompilingState(p) then exit;
// check for 'Assembling <filename>'
@ -2031,6 +2048,8 @@ begin
if CheckForLineProgress(p) then exit;
// check for '<int> Lines compiled, <int>.<int> sec'
if CheckForLinesCompiled(p) then exit;
// check for infos (logo, Linking <Progname>)
if CheckForInfos(p) then exit;
// check for -vx output
if CheckForExecutableInfo(p) then exit;
// check for linking errors
@ -2048,71 +2067,30 @@ begin
writeln('TFPCParser.ReadLine UNKNOWN: ',Line);
{$ENDIF}
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;
function TIDEFPCParser.LongenFilename(aFilename: string): string;
var
ShortFilename: String;
i: Integer;
begin
Result:=TrimFilename(aFilename);
if FilenameIsAbsolute(Result) then exit;
if Tool.WorkerDirectory<>'' then begin
Result:=AppendPathDelim(Tool.WorkerDirectory)+Result;
ShortFilename:=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;
// 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;
procedure TIDEFPCParser.ImproveMessages(aSynchronized: boolean);

View File

@ -3535,6 +3535,7 @@ begin
PkgCompileTool.Data:=TIDEExternalToolData.Create(IDEToolCompilePackage,
APackage.Name,APackage.Filename);
PkgCompileTool.FreeData:=true;
// check if main ppu file was created
SrcPPUFile:=APackage.GetSrcPPUFilename;
SrcPPUFileExists:=(SrcPPUFile<>'') and FileExistsUTF8(SrcPPUFile);