Browse Source

* first look for ppu in cwd and outputpath and after that for source
in cwd
* fixpath() for not linux makes path now lowercase so comparing paths
with different cases (sometimes a drive letter could be
uppercased) gives the expected results
* sources_checked flag if there was already a full search for sources
which aren't found, so another scan isn't done when checking for the
sources only when recompile is needed

peter 25 years ago
parent
commit
0d58e53bfc
3 changed files with 114 additions and 64 deletions
  1. 86 61
      compiler/files.pas
  2. 15 1
      compiler/globals.pas
  3. 13 2
      compiler/pmodules.pas

+ 86 - 61
compiler/files.pas

@@ -177,6 +177,7 @@ unit files;
           do_assemble,              { only assemble the object, don't recompile }
           do_assemble,              { only assemble the object, don't recompile }
           do_compile,               { need to compile the sources }
           do_compile,               { need to compile the sources }
           sources_avail,            { if all sources are reachable }
           sources_avail,            { if all sources are reachable }
+          sources_checked,          { if there is already done a check for the sources }
           is_unit,
           is_unit,
           in_compile,               { is it being compiled ?? }
           in_compile,               { is it being compiled ?? }
           in_second_compile,        { is this unit being compiled for the 2nd time? }
           in_second_compile,        { is this unit being compiled for the 2nd time? }
@@ -1005,76 +1006,73 @@ end;
            UnitExists:=FileExists(Singlepathstring+FileName+ext);
            UnitExists:=FileExists(Singlepathstring+FileName+ext);
          end;
          end;
 
 
-         Function SearchPath(const s:string):boolean;
+         Function PPUSearchPath(const s:string):boolean;
+         var
+           found   : boolean;
+         begin
+           Found:=false;
+           singlepathstring:=FixPath(s,false);
+         { Check for PPU file }
+           Found:=UnitExists(target_info.unitext);
+           if Found then
+            Begin
+              SetFileName(SinglePathString+FileName,false);
+              Found:=OpenPPU;
+            End;
+           PPUSearchPath:=Found;
+         end;
+
+         Function SourceSearchPath(const s:string):boolean;
          var
          var
            found   : boolean;
            found   : boolean;
            ext     : string[8];
            ext     : string[8];
          begin
          begin
            Found:=false;
            Found:=false;
            singlepathstring:=FixPath(s,false);
            singlepathstring:=FixPath(s,false);
-           if not onlysource then
-            begin
-{$ifdef CHECKPPL}
-            { Check for PPL file }
-              if not Found then
-               begin
-                 Found:=UnitExists(target_info.unitlibext);
-                 if Found then
-                  Begin
-                    SetFileName(SinglePathString+FileName,false);
-                    Found:=OpenPPU;
-                  End;
-                end;
-{$endif CHECKPPL}
-            { Check for PPU file }
-              if not Found then
-               begin
-                 Found:=UnitExists(target_info.unitext);
-                 if Found then
-                  Begin
-                    SetFileName(SinglePathString+FileName,false);
-                    Found:=OpenPPU;
-                  End;
-               end;
-            end;
          { Check for Sources }
          { Check for Sources }
-           if not Found then
+           ppufile:=nil;
+           do_compile:=true;
+           recompile_reason:=rr_noppu;
+         {Check for .pp file}
+           Found:=UnitExists(target_os.sourceext);
+           if Found then
+            Ext:=target_os.sourceext
+           else
             begin
             begin
-              ppufile:=nil;
-              do_compile:=true;
-              recompile_reason:=rr_noppu;
-            {Check for .pp file}
-              Found:=UnitExists(target_os.sourceext);
-              if Found then
-               Ext:=target_os.sourceext
-              else
-               begin
-               {Check for .pas}
-                 Found:=UnitExists(target_os.pasext);
-                 if Found then
-                  Ext:=target_os.pasext;
-               end;
-              stringdispose(mainsource);
+            {Check for .pas}
+              Found:=UnitExists(target_os.pasext);
               if Found then
               if Found then
-               begin
-                 sources_avail:=true;
-               {Load Filenames when found}
-                 mainsource:=StringDup(SinglePathString+FileName+Ext);
-                 SetFileName(SinglePathString+FileName,false);
-               end
-              else
-               sources_avail:=false;
+               Ext:=target_os.pasext;
             end;
             end;
-           SearchPath:=Found;
+           stringdispose(mainsource);
+           if Found then
+            begin
+              sources_avail:=true;
+            {Load Filenames when found}
+              mainsource:=StringDup(SinglePathString+FileName+Ext);
+              SetFileName(SinglePathString+FileName,false);
+            end
+           else
+            sources_avail:=false;
+           SourceSearchPath:=Found;
+         end;
+
+         Function SearchPath(const s:string):boolean;
+         var
+           found : boolean;
+         begin
+           { First check for a ppu, then for the source }
+           found:=false;
+           if not onlysource then
+            found:=PPUSearchPath(s);
+           if not found then
+            found:=SourceSearchPath(s);
+           SearchPath:=found;
          end;
          end;
 
 
          Function SearchPathList(list:TSearchPathList):boolean;
          Function SearchPathList(list:TSearchPathList):boolean;
          var
          var
-         {$IFDEF NEWST}
-           hp : PStringItem;
-         {$ELSE NEWST}
            hp : PStringQueueItem;
            hp : PStringQueueItem;
-         {$ENDIF NEWST}
            found : boolean;
            found : boolean;
          begin
          begin
            found:=false;
            found:=false;
@@ -1094,10 +1092,20 @@ end;
        begin
        begin
          filename:=FixFileName(n);
          filename:=FixFileName(n);
          { try to find unit
          { try to find unit
-            1. cwd
-            2. local unit path
-            3. global unit path }
-         fnd:=SearchPath('.');
+            1. look for ppu in cwd
+            2. look for ppu in outputpath if set, this is tp7 compatible (PFV)
+            3. look for source in cwd
+            4. local unit pathlist
+            5. global unit pathlist }
+         fnd:=false;
+         if not onlysource then
+          begin
+            fnd:=PPUSearchPath('.');
+            if (not fnd) and (current_module^.outputpath^<>'') then
+             fnd:=PPUSearchPath(current_module^.outputpath^);
+           end;
+         if (not fnd) then
+          fnd:=SourceSearchPath('.');
          if (not fnd) then
          if (not fnd) then
           fnd:=SearchPathList(current_module^.LocalUnitSearchPath);
           fnd:=SearchPathList(current_module^.LocalUnitSearchPath);
          if (not fnd) then
          if (not fnd) then
@@ -1262,6 +1270,7 @@ end;
         do_assemble:=false;
         do_assemble:=false;
         do_compile:=false;
         do_compile:=false;
         sources_avail:=true;
         sources_avail:=true;
+        sources_checked:=false;
         compiled:=false;
         compiled:=false;
         recompile_reason:=rr_unknown;
         recompile_reason:=rr_unknown;
         in_second_load:=false;
         in_second_load:=false;
@@ -1276,7 +1285,13 @@ end;
         _exports:=new(plinkedlist,init);
         _exports:=new(plinkedlist,init);
       { search the PPU file if it is an unit }
       { search the PPU file if it is an unit }
         if is_unit then
         if is_unit then
-         search_unit(modulename^,false);
+         begin
+           search_unit(modulename^,false);
+           { it the sources_available is changed then we know that
+             the sources aren't available }
+           if not sources_avail then
+            sources_checked:=true;
+         end;
       end;
       end;
 
 
 
 
@@ -1393,7 +1408,17 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.117  2000-02-28 17:23:56  daniel
+  Revision 1.118  2000-06-15 18:10:11  peter
+    * first look for ppu in cwd and outputpath and after that for source
+      in cwd
+    * fixpath() for not linux makes path now lowercase so comparing paths
+      with different cases (sometimes a drive letter could be
+      uppercased) gives the expected results
+    * sources_checked flag if there was already a full search for sources
+      which aren't found, so another scan isn't done when checking for the
+      sources only when recompile is needed
+
+  Revision 1.117  2000/02/28 17:23:56  daniel
   * Current work of symtable integration committed. The symtable can be
   * Current work of symtable integration committed. The symtable can be
     activated by defining 'newst', but doesn't compile yet. Changes in type
     activated by defining 'newst', but doesn't compile yet. Changes in type
     checking and oop are completed. What is left is to write a new
     checking and oop are completed. What is left is to write a new

+ 15 - 1
compiler/globals.pas

@@ -995,7 +995,11 @@ implementation
         if (not allowdot) and (s='.'+DirSep) then
         if (not allowdot) and (s='.'+DirSep) then
          s:='';
          s:='';
         { return }
         { return }
+{$ifdef linux}
         FixPath:=s;
         FixPath:=s;
+{$else}
+        FixPath:=Lower(s);
+{$endif}
       end;
       end;
 
 
 
 
@@ -1568,7 +1572,17 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.64  2000-06-11 07:00:21  peter
+  Revision 1.65  2000-06-15 18:10:11  peter
+    * first look for ppu in cwd and outputpath and after that for source
+      in cwd
+    * fixpath() for not linux makes path now lowercase so comparing paths
+      with different cases (sometimes a drive letter could be
+      uppercased) gives the expected results
+    * sources_checked flag if there was already a full search for sources
+      which aren't found, so another scan isn't done when checking for the
+      sources only when recompile is needed
+
+  Revision 1.64  2000/06/11 07:00:21  peter
     * fixed pchar->string conversion for delphi mode
     * fixed pchar->string conversion for delphi mode
 
 
   Revision 1.63  2000/05/12 08:58:51  pierre
   Revision 1.63  2000/05/12 08:58:51  pierre

+ 13 - 2
compiler/pmodules.pas

@@ -447,7 +447,8 @@ unit pmodules;
                 current_ppu:=nil;
                 current_ppu:=nil;
               end;
               end;
            { recompile the unit or give a fatal error if sources not available }
            { recompile the unit or give a fatal error if sources not available }
-             if not(current_module^.sources_avail) then
+             if not(current_module^.sources_avail) and
+                not(current_module^.sources_checked) then
                if (not current_module^.search_unit(current_module^.modulename^,true))
                if (not current_module^.search_unit(current_module^.modulename^,true))
                   and (length(current_module^.modulename^)>8) then
                   and (length(current_module^.modulename^)>8) then
                  current_module^.search_unit(copy(current_module^.modulename^,1,8),true);
                  current_module^.search_unit(copy(current_module^.modulename^,1,8),true);
@@ -1706,7 +1707,17 @@ unit pmodules;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.196  2000-06-01 19:09:57  peter
+  Revision 1.197  2000-06-15 18:10:11  peter
+    * first look for ppu in cwd and outputpath and after that for source
+      in cwd
+    * fixpath() for not linux makes path now lowercase so comparing paths
+      with different cases (sometimes a drive letter could be
+      uppercased) gives the expected results
+    * sources_checked flag if there was already a full search for sources
+      which aren't found, so another scan isn't done when checking for the
+      sources only when recompile is needed
+
+  Revision 1.196  2000/06/01 19:09:57  peter
     * made resourcestrings OOP so it's easier to handle it per module
     * made resourcestrings OOP so it's easier to handle it per module
 
 
   Revision 1.195  2000/05/11 09:40:11  pierre
   Revision 1.195  2000/05/11 09:40:11  pierre