Browse Source

* $UNITPATH directive is now working

mazen 23 years ago
parent
commit
301bf08921
3 changed files with 85 additions and 67 deletions
  1. 59 53
      compiler/fmodule.pas
  2. 21 12
      compiler/fppu.pas
  3. 5 2
      compiler/parser.pas

+ 59 - 53
compiler/fmodule.pas

@@ -80,56 +80,59 @@ interface
        punitmap = ^tunitmap;
 {$endif NEWMAP}
 
-       tmodule = class(tmodulebase)
-          compiled,                 { unit is already compiled }
-          do_reload,                { force reloading of the unit }
-          do_compile,               { need to compile the sources }
-          sources_avail,            { if all sources are reachable }
-          sources_checked,          { if there is already done a check for the sources }
-          is_unit,
-          in_second_compile,        { is this unit being compiled for the 2nd time? }
-          in_second_load,           { is this unit PPU loaded a 2nd time? }
-          in_implementation,        { processing the implementation part? }
-          in_global     : boolean;  { allow global settings }
-          recompile_reason : trecompile_reason;  { the reason why the unit should be recompiled }
-          crc,
-          interface_crc : cardinal;
-          flags         : cardinal;  { the PPU flags }
-          islibrary     : boolean;  { if it is a library (win32 dll) }
-          map           : punitmap; { mapping of all used units }
-          unitcount     : longint;  { local unit counter }
-          globalsymtable,           { pointer to the global symtable of this unit }
-          localsymtable : tsymtable;{ pointer to the local symtable of this unit }
-          scanner       : pointer;  { scanner object used }
-          loaded_from   : tmodule;
-          uses_imports  : boolean;  { Set if the module imports from DLL's.}
-          imports       : tlinkedlist;
-          _exports      : tlinkedlist;
-          externals     : tlinkedlist; {Only for DLL scanners by using Unix-style $LINKLIB }
-          resourcefiles : tstringlist;
-
-          linkunitofiles,
-          linkunitstaticlibs,
-          linkunitsharedlibs,
-          linkotherofiles,           { objects,libs loaded from the source }
-          linkothersharedlibs,       { using $L or $LINKLIB or import lib (for linux) }
-          linkotherstaticlibs  : tlinkcontainer;
-
-          used_units           : tlinkedlist;
-          dependent_units      : tlinkedlist;
-
-          localunitsearchpath,           { local searchpaths }
-          localobjectsearchpath,
-          localincludesearchpath,
-          locallibrarysearchpath : TSearchPathList;
-
-          asmprefix     : pstring;  { prefix for the smartlink asmfiles }
-          librarydata   : tasmlibrarydata;   { librarydata for this module }
-          constructor create(const s:string;_is_unit:boolean);
-          destructor destroy;override;
-          procedure reset;virtual;
-          procedure numberunits;
-       end;
+      tmodule = class(tmodulebase)
+        compiled,                 { unit is already compiled }
+        do_reload,                { force reloading of the unit }
+        do_compile,               { need to compile the sources }
+        sources_avail,            { if all sources are reachable }
+        sources_checked,          { if there is already done a check for the sources }
+        is_unit,
+        in_second_compile,        { is this unit being compiled for the 2nd time? }
+        in_second_load,           { is this unit PPU loaded a 2nd time? }
+        in_implementation,        { processing the implementation part? }
+        in_global     : boolean;  { allow global settings }
+        recompile_reason : trecompile_reason;  { the reason why the unit should be recompiled }
+        crc,
+        interface_crc : cardinal;
+        flags         : cardinal;  { the PPU flags }
+        islibrary     : boolean;  { if it is a library (win32 dll) }
+        map           : punitmap; { mapping of all used units }
+        unitcount     : longint;  { local unit counter }
+        globalsymtable,           { pointer to the global symtable of this unit }
+        localsymtable : tsymtable;{ pointer to the local symtable of this unit }
+        scanner       : pointer;  { scanner object used }
+        loaded_from   : tmodule;
+        uses_imports  : boolean;  { Set if the module imports from DLL's.}
+        imports       : tlinkedlist;
+        _exports      : tlinkedlist;
+        externals     : tlinkedlist; {Only for DLL scanners by using Unix-style $LINKLIB }
+        resourcefiles : tstringlist;
+        linkunitofiles,
+        linkunitstaticlibs,
+        linkunitsharedlibs,
+        linkotherofiles,           { objects,libs loaded from the source }
+        linkothersharedlibs,       { using $L or $LINKLIB or import lib (for linux) }
+        linkotherstaticlibs  : tlinkcontainer;
+
+        used_units           : tlinkedlist;
+        dependent_units      : tlinkedlist;
+
+        localunitsearchpath,           { local searchpaths }
+        localobjectsearchpath,
+        localincludesearchpath,
+        locallibrarysearchpath : TSearchPathList;
+
+        asmprefix     : pstring;  { prefix for the smartlink asmfiles }
+        librarydata   : tasmlibrarydata;   { librarydata for this module }
+        {create creates a new module which name is stored in 's'. LoadedFrom
+        points to the module calling it. It is nil for the first compiled
+        module. This allow inheritence of all path lists. MUST pay attention
+        to that when creating link.res!!!!(mazen)}
+        constructor create(LoadedFrom:TModule;const s:string;_is_unit:boolean);
+        destructor destroy;override;
+        procedure reset;virtual;
+        procedure numberunits;
+      end;
 
        tused_unit = class(tlinkedlistitem)
           unitid          : longint;
@@ -354,7 +357,7 @@ uses
                                   TMODULE
  ****************************************************************************}
 
-    constructor tmodule.create(const s:string;_is_unit:boolean);
+    constructor tmodule.create(LoadedFrom:TModule;const s:string;_is_unit:boolean);
       var
         p : dirstr;
         n : namestr;
@@ -394,7 +397,7 @@ uses
         map:=nil;
         globalsymtable:=nil;
         localsymtable:=nil;
-        loaded_from:=nil;
+        loaded_from:=LoadedFrom;
         do_reload:=false;
         unitcount:=1;
         do_compile:=false;
@@ -603,7 +606,10 @@ uses
 end.
 {
   $Log$
-  Revision 1.28  2002-09-05 19:29:42  peter
+  Revision 1.29  2002-11-20 12:36:23  mazen
+  * $UNITPATH directive is now working
+
+  Revision 1.28  2002/09/05 19:29:42  peter
     * memdebug enhancements
 
   Revision 1.27  2002/08/16 15:31:08  peter

+ 21 - 12
compiler/fppu.pas

@@ -46,7 +46,7 @@ interface
           crc_array2 : pointer;
           crc_size2  : longint;
 {$endif def Test_Double_checksum}
-          constructor create(const s:string;const fn:string;_is_unit:boolean);
+          constructor create(LoadedFrom:TModule;const s:string;const fn:string;_is_unit:boolean);
           destructor destroy;override;
           procedure reset;override;
           function  openppu:boolean;
@@ -91,9 +91,9 @@ uses
                                 TPPUMODULE
  ****************************************************************************}
 
-    constructor tppumodule.create(const s:string;const fn:string;_is_unit:boolean);
+    constructor tppumodule.create(LoadedFrom:TModule;const s:string;const fn:string;_is_unit:boolean);
       begin
-        inherited create(s,_is_unit);
+        inherited create(LoadedFrom,s,_is_unit);
         ppufile:=nil;
       { search the PPU file if it is an unit }
         if is_unit then
@@ -334,12 +334,18 @@ uses
                SetFileName(hs,false);
              end;
           end;
-         if (not fnd) then
-          fnd:=SourceSearchPath('.');
-         if (not fnd) then
-          fnd:=SearchPathList(LocalUnitSearchPath);
-         if (not fnd) then
-          fnd:=SearchPathList(UnitSearchPath);
+          if(not fnd)and Assigned(Loaded_From)
+          then
+            fnd:=SearchPathList(Loaded_From.LocalUnitSearchPath);
+          if not fnd
+          then
+            fnd:=SourceSearchPath('.');
+          if not fnd
+          then
+            fnd:=SearchPathList(LocalUnitSearchPath);
+          if not fnd
+          then
+            fnd:=SearchPathList(UnitSearchPath);
 
          { try to find a file with the first 8 chars of the modulename, like
            dos }
@@ -1266,8 +1272,8 @@ uses
             else
           { generates a new unit info record }
              begin
-                current_module:=tppumodule.create(s,fn,true);
-                second_time:=false;
+               current_module:=tppumodule.create(old_current_module,s,fn,true);
+               second_time:=false;
              end;
             { close old_current_ppu on system that are
               short on file handles like DOS PM }
@@ -1319,7 +1325,10 @@ uses
 end.
 {
   $Log$
-  Revision 1.26  2002-11-15 01:58:46  peter
+  Revision 1.27  2002-11-20 12:36:24  mazen
+  * $UNITPATH directive is now working
+
+  Revision 1.26  2002/11/15 01:58:46  peter
     * merged changes from 1.0.7 up to 04-11
       - -V option for generating bug report tracing
       - more tracing for option parsing

+ 5 - 2
compiler/parser.pas

@@ -388,7 +388,7 @@ implementation
           current_module.reset
          else
           begin
-            current_module:=tppumodule.create(filename,'',false);
+            current_module:=tppumodule.create(nil,filename,'',false);
             main_module:=current_module;
           end;
 
@@ -618,7 +618,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.45  2002-10-07 19:29:52  peter
+  Revision 1.46  2002-11-20 12:36:24  mazen
+  * $UNITPATH directive is now working
+
+  Revision 1.45  2002/10/07 19:29:52  peter
     * Place old data in compile() in the heap to save stack
 
   Revision 1.44  2002/09/05 19:27:06  peter