Преглед на файлове

Add the possibility to load all packages supplied as parameters.

pkgutil.pas:
  + new function load_packages to load all packages supplied as parameters
pmodules.pas, proc_program:
  * use load_packages to load all packages before any unit is loaded

git-svn-id: branches/svenbarth/packages@28849 -
svenbarth преди 10 години
родител
ревизия
c0d577fd69
променени са 2 файла, в които са добавени 28 реда и са изтрити 2 реда
  1. 24 2
      compiler/pkgutil.pas
  2. 4 0
      compiler/pmodules.pas

+ 24 - 2
compiler/pkgutil.pas

@@ -32,6 +32,7 @@ interface
   procedure createimportlibfromexports;
   Function RewritePPU(const PPUFn,PPLFn:String):Boolean;
   procedure export_unit(u:tmodule);
+  procedure load_packages;
 
 implementation
 
@@ -39,9 +40,9 @@ implementation
     sysutils,
     globtype,systems,
     cutils,cclasses,
-    verbose,
+    globals,verbose,
     symtype,symconst,symsym,symdef,symbase,symtable,
-    ppu,entfile,
+    ppu,entfile,fpcp,fpkg,
     export;
 
   procedure procexport(const s : string);
@@ -384,6 +385,27 @@ implementation
     end;
 
 
+  procedure load_packages;
+    var
+      i : longint;
+      pcp: tpcppackage;
+      entry : ppackageentry;
+    begin
+      if not (tf_supports_packages in target_info.flags) then
+        exit;
+      for i:=0 to packagelist.count-1 do
+        begin
+          entry:=ppackageentry(packagelist[i]);
+          if assigned(entry^.package) then
+            internalerror(2013053104);
+          Comment(V_Info,'Loading package: '+entry^.realpkgname);
+          pcp:=tpcppackage.create(entry^.realpkgname);
+          pcp.loadpcp;
+          entry^.package:=pcp;
+        end;
+    end;
+
+
   procedure createimportlibfromexports;
     var
       hp : texported_item;

+ 4 - 0
compiler/pmodules.pas

@@ -1774,6 +1774,10 @@ type
              setupglobalswitches;
            end;
 
+         { load all packages, so we know whether a unit is contained inside a
+           package or not }
+         load_packages;
+
          { global switches are read, so further changes aren't allowed }
          current_module.in_global:=false;