Browse Source

Correctly create import libraries for packages as well.

pkgutil.pas, createimportlibfromexternals:
  * instead of processing units without the uf_in_library flag, only process those that don't have a package reference set (thus becoming part of the program/library or the package)
  - remove unneeded "pkg" parameter
pmodules.pas:
  + proc_package: create the import library if the package requires other packages
  * proc_program: adjust call to createimportlibfromexternals

git-svn-id: branches/svenbarth/packages@29043 -
svenbarth 10 years ago
parent
commit
3eacfce4b4
2 changed files with 42 additions and 54 deletions
  1. 37 53
      compiler/pkgutil.pas
  2. 5 1
      compiler/pmodules.pas

+ 37 - 53
compiler/pkgutil.pas

@@ -29,7 +29,7 @@ interface
   uses
   uses
     fmodule,fpkg;
     fmodule,fpkg;
 
 
-  procedure createimportlibfromexternals(pkg:tpackage);
+  procedure createimportlibfromexternals;
   Function RewritePPU(const PPUFn,PPLFn:String):Boolean;
   Function RewritePPU(const PPUFn,PPLFn:String):Boolean;
   procedure export_unit(u:tmodule);
   procedure export_unit(u:tmodule);
   procedure load_packages;
   procedure load_packages;
@@ -444,7 +444,7 @@ implementation
     end;
     end;
 
 
 
 
-  procedure createimportlibfromexternals(pkg:tpackage);
+  procedure createimportlibfromexternals;
     type
     type
       tcacheentry=record
       tcacheentry=record
         pkg:tpackage;
         pkg:tpackage;
@@ -670,64 +670,48 @@ implementation
       { check each external asm symbol of each unit of the package whether it is
       { check each external asm symbol of each unit of the package whether it is
         contained in the unit of a loaded package (and thus an import entry
         contained in the unit of a loaded package (and thus an import entry
         is needed) }
         is needed) }
-      if assigned(pkg) then
-        begin
-          { ToDo }
-          { we were called from a package file }
-          (*for i:=0 to pkg.containedmodules.count-1 do
-            begin
-              unitentry:=pcontainedunit(pkg.containedmodules[i]);
-              processasmsyms(tmodule(unitentry^.module).globalasmsyms);
-            end;
-          { also process the package's module }
-          processasmsyms(tasmdata(current_module.asmdata).asmsymboldict);*)
-        end
-      else
-        begin
-          alreadyloaded:=tfpobjectlist.create(false);
-          { we were called from a program/library }
+      alreadyloaded:=tfpobjectlist.create(false);
+      { we were called from a program/library }
 
 
-          { first pass to find all symbols that were not loaded by asm name }
-          module:=tmodule(loaded_units.first);
-          while assigned(module) do
+      { first pass to find all symbols that were not loaded by asm name }
+      module:=tmodule(loaded_units.first);
+      while assigned(module) do
+        begin
+          writeln('processing imported symbols of unit ', module.modulename^);
+          if not assigned(module.package) then
             begin
             begin
-              writeln('processing imported symbols of unit ', module.modulename^);
-              //if not assigned(module.package) then
-              if (uf_in_library and module.flags)=0 then
-                begin
-                  processimportedsyms(module.unitimportsyms);
-                  { this unit is not part of a package }
-                  (*if module=current_module then
-                    { this is the main file, which does not fill globalasmsyms }
-                    processasmsyms(tasmdata(module.asmdata).asmsymboldict)
-                  else
-                    { this is an ordinary unit }
-                    processasmsyms(module.globalasmsyms);*)
-                end
+              processimportedsyms(module.unitimportsyms);
+              { this unit is not part of a package }
+              (*if module=current_module then
+                { this is the main file, which does not fill globalasmsyms }
+                processasmsyms(tasmdata(module.asmdata).asmsymboldict)
               else
               else
-                writeln(module.modulename^, ' is a package unit; ignoring');
-              module:=tmodule(module.next);
-            end;
+                { this is an ordinary unit }
+                processasmsyms(module.globalasmsyms);*)
+            end
+          else
+            writeln(module.modulename^, ' is a package unit; ignoring');
+          module:=tmodule(module.next);
+        end;
 
 
-          { second pass to find all symbols that were loaded by asm name }
-          module:=tmodule(loaded_units.first);
-          while assigned(module) do
+      { second pass to find all symbols that were loaded by asm name }
+      module:=tmodule(loaded_units.first);
+      while assigned(module) do
+        begin
+          if not assigned(module.package) then
             begin
             begin
-              if (uf_in_library and module.flags)=0 then
-                begin
-                  writeln('processing assembler symbols of unit ', module.modulename^);
-                  if module=current_module then
-                    { this is the main file, which does not fill globalasmsyms }
-                    processasmsyms(tasmdata(module.asmdata).asmsymboldict)
-                  else
-                    { this is an ordinary unit }
-                    processasmsyms(module.globalasmsyms);
-                end;
-              module:=tmodule(module.next);
+              writeln('processing assembler symbols of unit ', module.modulename^);
+              if module=current_module then
+                { this is the main file, which does not fill globalasmsyms }
+                processasmsyms(tasmdata(module.asmdata).asmsymboldict)
+              else
+                { this is an ordinary unit }
+                processasmsyms(module.globalasmsyms);
             end;
             end;
-
-          alreadyloaded.free;
+          module:=tmodule(module.next);
         end;
         end;
+
+      alreadyloaded.free;
       for i:=0 to cache.count-1 do
       for i:=0 to cache.count-1 do
         dispose(pcacheentry(cache[i]));
         dispose(pcacheentry(cache[i]));
     end;
     end;

+ 5 - 1
compiler/pmodules.pas

@@ -1570,6 +1570,10 @@ type
 
 
          exportlib.ignoreduplicates:=false;
          exportlib.ignoreduplicates:=false;
 
 
+         { create import libraries for all packages }
+         if packagelist.count>0 then
+           createimportlibfromexternals;
+
          { generate imports }
          { generate imports }
          if current_module.ImportLibraryList.Count>0 then
          if current_module.ImportLibraryList.Count>0 then
            importlib.generatelib;
            importlib.generatelib;
@@ -2086,7 +2090,7 @@ type
 
 
          { create import libraries for all packages }
          { create import libraries for all packages }
          if packagelist.count>0 then
          if packagelist.count>0 then
-           createimportlibfromexternals(nil);
+           createimportlibfromexternals;
 
 
          { generate imports }
          { generate imports }
          if current_module.ImportLibraryList.Count>0 then
          if current_module.ImportLibraryList.Count>0 then