Browse Source

generate more verbose messages in case of PPU/unit not found

git-svn-id: trunk@4817 -
micha 19 years ago
parent
commit
97722babad
2 changed files with 87 additions and 39 deletions
  1. 41 7
      compiler/fppu.pas
  2. 46 32
      compiler/verbose.pas

+ 41 - 7
compiler/fppu.pas

@@ -43,6 +43,7 @@ interface
        tppumodule = class(tmodule)
        tppumodule = class(tmodule)
           ppufile    : tcompilerppufile; { the PPU file }
           ppufile    : tcompilerppufile; { the PPU file }
           sourcefn   : pstring; { Source specified with "uses .. in '..'" }
           sourcefn   : pstring; { Source specified with "uses .. in '..'" }
+          comments   : tstringlist;
 {$ifdef Test_Double_checksum}
 {$ifdef Test_Double_checksum}
           crc_array  : pointer;
           crc_array  : pointer;
           crc_size   : longint;
           crc_size   : longint;
@@ -63,6 +64,8 @@ interface
           procedure load_implementation;
           procedure load_implementation;
           procedure load_symtable_refs;
           procedure load_symtable_refs;
           procedure load_usedunits;
           procedure load_usedunits;
+          procedure printcomments;
+          procedure queuecomment(s:string;v,w:longint);
           procedure writesourcefiles;
           procedure writesourcefiles;
           procedure writeusedunit(intf:boolean);
           procedure writeusedunit(intf:boolean);
           procedure writelinkcontainer(var p:tlinkcontainer;id:byte;strippath:boolean);
           procedure writelinkcontainer(var p:tlinkcontainer;id:byte;strippath:boolean);
@@ -93,7 +96,8 @@ uses
   symtable, symsym,
   symtable, symsym,
   scanner,
   scanner,
   aasmbase,ogbase,
   aasmbase,ogbase,
-  parser;
+  parser,
+  comphook;
 
 
 {****************************************************************************
 {****************************************************************************
                                  Helpers
                                  Helpers
@@ -131,6 +135,8 @@ uses
         if assigned(ppufile) then
         if assigned(ppufile) then
          ppufile.free;
          ppufile.free;
         ppufile:=nil;
         ppufile:=nil;
+        comments.free;
+        comments:=nil;
         stringdispose(sourcefn);
         stringdispose(sourcefn);
         inherited Destroy;
         inherited Destroy;
       end;
       end;
@@ -146,13 +152,34 @@ uses
         inherited reset;
         inherited reset;
       end;
       end;
 
 
+    procedure tppumodule.queuecomment(s:string;v,w:longint);
+    begin
+      if comments = nil then
+        comments := tstringlist.create;
+      comments.insert(s);
+    end;
+
+    procedure tppumodule.printcomments;
+    var
+      comment: string;
+    begin
+      if comments = nil then
+        exit;
+      { comments are inserted in reverse order }
+      repeat
+        comment := comments.getlast;
+        if length(comment) = 0 then
+          exit;
+        do_comment(v_normal, comment);
+      until false;
+    end;
 
 
     function tppumodule.openppu:boolean;
     function tppumodule.openppu:boolean;
       var
       var
         ppufiletime : longint;
         ppufiletime : longint;
       begin
       begin
         openppu:=false;
         openppu:=false;
-        Message1(unit_t_ppu_loading,ppufilename^);
+        Message1(unit_t_ppu_loading,ppufilename^,@queuecomment);
       { Get ppufile time (also check if the file exists) }
       { Get ppufile time (also check if the file exists) }
         ppufiletime:=getnamedfiletime(ppufilename^);
         ppufiletime:=getnamedfiletime(ppufilename^);
         if ppufiletime=-1 then
         if ppufiletime=-1 then
@@ -178,7 +205,7 @@ uses
       { check for allowed PPU versions }
       { check for allowed PPU versions }
         if not (ppufile.GetPPUVersion = CurrentPPUVersion) then
         if not (ppufile.GetPPUVersion = CurrentPPUVersion) then
          begin
          begin
-           Message1(unit_u_ppu_invalid_version,tostr(ppufile.GetPPUVersion));
+           Message1(unit_u_ppu_invalid_version,tostr(ppufile.GetPPUVersion),@queuecomment);
            ppufile.free;
            ppufile.free;
            ppufile:=nil;
            ppufile:=nil;
            exit;
            exit;
@@ -188,7 +215,7 @@ uses
          begin
          begin
            ppufile.free;
            ppufile.free;
            ppufile:=nil;
            ppufile:=nil;
-           Message(unit_u_ppu_invalid_processor);
+           Message(unit_u_ppu_invalid_processor,@queuecomment);
            exit;
            exit;
          end;
          end;
       { check target }
       { check target }
@@ -196,7 +223,7 @@ uses
          begin
          begin
            ppufile.free;
            ppufile.free;
            ppufile:=nil;
            ppufile:=nil;
-           Message(unit_u_ppu_invalid_target);
+           Message(unit_u_ppu_invalid_target,@queuecomment);
            exit;
            exit;
          end;
          end;
 {$ifdef cpufpemu}
 {$ifdef cpufpemu}
@@ -1211,7 +1238,7 @@ uses
                   (pu.u.crc<>pu.checksum)
                   (pu.u.crc<>pu.checksum)
                  ) then
                  ) then
                begin
                begin
-                 Message2(unit_u_recompile_crc_change,realmodulename^,pu.u.realmodulename^);
+                 Message2(unit_u_recompile_crc_change,realmodulename^,pu.u.realmodulename^,@queuecomment);
                  recompile_reason:=rr_crcchanged;
                  recompile_reason:=rr_crcchanged;
                  do_compile:=true;
                  do_compile:=true;
                  exit;
                  exit;
@@ -1256,7 +1283,7 @@ uses
               { need to recompile the current unit ? }
               { need to recompile the current unit ? }
               if (pu.u.interface_crc<>pu.interface_checksum) then
               if (pu.u.interface_crc<>pu.interface_checksum) then
                 begin
                 begin
-                  Message2(unit_u_recompile_crc_change,realmodulename^,pu.u.realmodulename^+' {impl}');
+                  Message2(unit_u_recompile_crc_change,realmodulename^,pu.u.realmodulename^+' {impl}',@queuecomment);
                   recompile_reason:=rr_crcchanged;
                   recompile_reason:=rr_crcchanged;
                   do_compile:=true;
                   do_compile:=true;
                   exit;
                   exit;
@@ -1445,12 +1472,19 @@ uses
                    search_unit(true,true);
                    search_unit(true,true);
                  if not(sources_avail) then
                  if not(sources_avail) then
                   begin
                   begin
+                    printcomments;
                     if recompile_reason=rr_noppu then
                     if recompile_reason=rr_noppu then
                       Message1(unit_f_cant_find_ppu,realmodulename^)
                       Message1(unit_f_cant_find_ppu,realmodulename^)
                     else
                     else
                       Message1(unit_f_cant_compile_unit,realmodulename^);
                       Message1(unit_f_cant_compile_unit,realmodulename^);
                   end;
                   end;
                end;
                end;
+              { we found the sources, we do not need the verbose messages anymore }
+              if comments <> nil then
+              begin
+                comments.free;
+                comments:=nil;
+              end;
               { Flag modules to reload }
               { Flag modules to reload }
               flagdependent(old_current_module);
               flagdependent(old_current_module);
               { Reset the module }
               { Reset the module }

+ 46 - 32
compiler/verbose.pas

@@ -68,6 +68,9 @@ interface
     var
     var
       msg : pmessage;
       msg : pmessage;
 
 
+    type
+      tmsgqueueevent = procedure(s:string;v,w:longint) of object;
+
     const
     const
       msgfilename : string = '';
       msgfilename : string = '';
 
 
@@ -84,16 +87,16 @@ interface
     procedure Internalerror(i:longint);
     procedure Internalerror(i:longint);
     procedure Comment(l:longint;s:string);
     procedure Comment(l:longint;s:string);
     function  MessagePchar(w:longint):pchar;
     function  MessagePchar(w:longint):pchar;
-    procedure Message(w:longint);
-    procedure Message1(w:longint;const s1:string);
-    procedure Message2(w:longint;const s1,s2:string);
-    procedure Message3(w:longint;const s1,s2,s3:string);
-    procedure Message4(w:longint;const s1,s2,s3,s4:string);
-    procedure MessagePos(const pos:tfileposinfo;w:longint);
-    procedure MessagePos1(const pos:tfileposinfo;w:longint;const s1:string);
-    procedure MessagePos2(const pos:tfileposinfo;w:longint;const s1,s2:string);
-    procedure MessagePos3(const pos:tfileposinfo;w:longint;const s1,s2,s3:string);
-    procedure MessagePos4(const pos:tfileposinfo;w:longint;const s1,s2,s3,s4:string);
+    procedure Message(w:longint;onqueue:tmsgqueueevent=nil);
+    procedure Message1(w:longint;const s1:string;onqueue:tmsgqueueevent=nil);
+    procedure Message2(w:longint;const s1,s2:string;onqueue:tmsgqueueevent=nil);
+    procedure Message3(w:longint;const s1,s2,s3:string;onqueue:tmsgqueueevent=nil);
+    procedure Message4(w:longint;const s1,s2,s3,s4:string;onqueue:tmsgqueueevent=nil);
+    procedure MessagePos(const pos:tfileposinfo;w:longint;onqueue:tmsgqueueevent=nil);
+    procedure MessagePos1(const pos:tfileposinfo;w:longint;const s1:string;onqueue:tmsgqueueevent=nil);
+    procedure MessagePos2(const pos:tfileposinfo;w:longint;const s1,s2:string;onqueue:tmsgqueueevent=nil);
+    procedure MessagePos3(const pos:tfileposinfo;w:longint;const s1,s2,s3:string;onqueue:tmsgqueueevent=nil);
+    procedure MessagePos4(const pos:tfileposinfo;w:longint;const s1,s2,s3,s4:string;onqueue:tmsgqueueevent=nil);
 
 
     { message calls with codegenerror support }
     { message calls with codegenerror support }
     procedure cgmessage(t : longint);
     procedure cgmessage(t : longint);
@@ -486,13 +489,15 @@ var
       end;
       end;
 
 
 
 
-    Procedure Msg2Comment(s:string);
+    Procedure Msg2Comment(s:string;w:longint;onqueue:tmsgqueueevent);
       var
       var
         idx,i,v : longint;
         idx,i,v : longint;
         dostop  : boolean;
         dostop  : boolean;
+        doqueue : boolean;
       begin
       begin
       {Reset}
       {Reset}
         dostop:=false;
         dostop:=false;
+        doqueue:=false;
         v:=0;
         v:=0;
       {Parse options}
       {Parse options}
         idx:=pos('_',s);
         idx:=pos('_',s);
@@ -564,13 +569,22 @@ var
         Delete(s,1,idx);
         Delete(s,1,idx);
       { check verbosity level }
       { check verbosity level }
         if not CheckVerbosity(v) then
         if not CheckVerbosity(v) then
-          exit;
+        begin
+          doqueue := onqueue <> nil;
+          if not doqueue then
+            exit;
+        end;
         if (v and V_LineInfoMask)<>0 then
         if (v and V_LineInfoMask)<>0 then
           v:=v or V_LineInfo;
           v:=v or V_LineInfo;
       { fix status }
       { fix status }
         UpdateStatus;
         UpdateStatus;
       { Fix replacements }
       { Fix replacements }
         DefaultReplacements(s);
         DefaultReplacements(s);
+        if doqueue then
+        begin
+          onqueue(s,v,w);
+          exit;
+        end;
       { show comment }
       { show comment }
         if do_comment(v,s) or dostop then
         if do_comment(v,s) or dostop then
           raise ECompilerAbort.Create;
           raise ECompilerAbort.Create;
@@ -590,98 +604,98 @@ var
       end;
       end;
 
 
 
 
-    procedure Message(w:longint);
+    procedure Message(w:longint;onqueue:tmsgqueueevent=nil);
       begin
       begin
         MaybeLoadMessageFile;
         MaybeLoadMessageFile;
-        Msg2Comment(msg^.Get(w,[]));
+        Msg2Comment(msg^.Get(w,[]),w,onqueue);
       end;
       end;
 
 
 
 
-    procedure Message1(w:longint;const s1:string);
+    procedure Message1(w:longint;const s1:string;onqueue:tmsgqueueevent=nil);
 
 
       begin
       begin
         MaybeLoadMessageFile;
         MaybeLoadMessageFile;
-        Msg2Comment(msg^.Get(w,[s1]));
+        Msg2Comment(msg^.Get(w,[s1]),w,onqueue);
       end;
       end;
 
 
 
 
-    procedure Message2(w:longint;const s1,s2:string);
+    procedure Message2(w:longint;const s1,s2:string;onqueue:tmsgqueueevent=nil);
       begin
       begin
         MaybeLoadMessageFile;
         MaybeLoadMessageFile;
-        Msg2Comment(msg^.Get(w,[s1,s2]));
+        Msg2Comment(msg^.Get(w,[s1,s2]),w,onqueue);
       end;
       end;
 
 
 
 
-    procedure Message3(w:longint;const s1,s2,s3:string);
+    procedure Message3(w:longint;const s1,s2,s3:string;onqueue:tmsgqueueevent=nil);
       begin
       begin
         MaybeLoadMessageFile;
         MaybeLoadMessageFile;
-        Msg2Comment(msg^.Get(w,[s1,s2,s3]));
+        Msg2Comment(msg^.Get(w,[s1,s2,s3]),w,onqueue);
       end;
       end;
 
 
 
 
-    procedure Message4(w:longint;const s1,s2,s3,s4:string);
+    procedure Message4(w:longint;const s1,s2,s3,s4:string;onqueue:tmsgqueueevent=nil);
       begin
       begin
         MaybeLoadMessageFile;
         MaybeLoadMessageFile;
-        Msg2Comment(msg^.Get(w,[s1,s2,s3,s4]));
+        Msg2Comment(msg^.Get(w,[s1,s2,s3,s4]),w,onqueue);
       end;
       end;
 
 
 
 
-    procedure MessagePos(const pos:tfileposinfo;w:longint);
+    procedure MessagePos(const pos:tfileposinfo;w:longint;onqueue:tmsgqueueevent=nil);
       var
       var
         oldpos : tfileposinfo;
         oldpos : tfileposinfo;
       begin
       begin
         oldpos:=aktfilepos;
         oldpos:=aktfilepos;
         aktfilepos:=pos;
         aktfilepos:=pos;
         MaybeLoadMessageFile;
         MaybeLoadMessageFile;
-        Msg2Comment(msg^.Get(w,[]));
+        Msg2Comment(msg^.Get(w,[]),w,onqueue);
         aktfilepos:=oldpos;
         aktfilepos:=oldpos;
       end;
       end;
 
 
 
 
-    procedure MessagePos1(const pos:tfileposinfo;w:longint;const s1:string);
+    procedure MessagePos1(const pos:tfileposinfo;w:longint;const s1:string;onqueue:tmsgqueueevent=nil);
       var
       var
         oldpos : tfileposinfo;
         oldpos : tfileposinfo;
       begin
       begin
         oldpos:=aktfilepos;
         oldpos:=aktfilepos;
         aktfilepos:=pos;
         aktfilepos:=pos;
         MaybeLoadMessageFile;
         MaybeLoadMessageFile;
-        Msg2Comment(msg^.Get(w,[s1]));
+        Msg2Comment(msg^.Get(w,[s1]),w,onqueue);
         aktfilepos:=oldpos;
         aktfilepos:=oldpos;
       end;
       end;
 
 
 
 
-    procedure MessagePos2(const pos:tfileposinfo;w:longint;const s1,s2:string);
+    procedure MessagePos2(const pos:tfileposinfo;w:longint;const s1,s2:string;onqueue:tmsgqueueevent=nil);
       var
       var
         oldpos : tfileposinfo;
         oldpos : tfileposinfo;
       begin
       begin
         oldpos:=aktfilepos;
         oldpos:=aktfilepos;
         aktfilepos:=pos;
         aktfilepos:=pos;
         MaybeLoadMessageFile;
         MaybeLoadMessageFile;
-        Msg2Comment(msg^.Get(w,[s1,s2]));
+        Msg2Comment(msg^.Get(w,[s1,s2]),w,onqueue);
         aktfilepos:=oldpos;
         aktfilepos:=oldpos;
       end;
       end;
 
 
 
 
-    procedure MessagePos3(const pos:tfileposinfo;w:longint;const s1,s2,s3:string);
+    procedure MessagePos3(const pos:tfileposinfo;w:longint;const s1,s2,s3:string;onqueue:tmsgqueueevent=nil);
       var
       var
         oldpos : tfileposinfo;
         oldpos : tfileposinfo;
       begin
       begin
         oldpos:=aktfilepos;
         oldpos:=aktfilepos;
         aktfilepos:=pos;
         aktfilepos:=pos;
         MaybeLoadMessageFile;
         MaybeLoadMessageFile;
-        Msg2Comment(msg^.Get(w,[s1,s2,s3]));
+        Msg2Comment(msg^.Get(w,[s1,s2,s3]),w,onqueue);
         aktfilepos:=oldpos;
         aktfilepos:=oldpos;
       end;
       end;
 
 
 
 
-    procedure MessagePos4(const pos:tfileposinfo;w:longint;const s1,s2,s3,s4:string);
+    procedure MessagePos4(const pos:tfileposinfo;w:longint;const s1,s2,s3,s4:string;onqueue:tmsgqueueevent=nil);
       var
       var
         oldpos : tfileposinfo;
         oldpos : tfileposinfo;
       begin
       begin
         oldpos:=aktfilepos;
         oldpos:=aktfilepos;
         aktfilepos:=pos;
         aktfilepos:=pos;
         MaybeLoadMessageFile;
         MaybeLoadMessageFile;
-        Msg2Comment(msg^.Get(w,[s1,s2,s3,s4]));
+        Msg2Comment(msg^.Get(w,[s1,s2,s3,s4]),w,onqueue);
         aktfilepos:=oldpos;
         aktfilepos:=oldpos;
       end;
       end;