mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 22:09:32 +02:00
Merged revision(s) 32508-32510, 32512 from branches/svenbarth/packages:
Keep track whether a package was added directly through a requires section (or the command line) or indirectly. fpkg.pas, tpackageentry: + new field "direct" pkgutil.pas: + add_package: new parameter "direct" which sets the "direct" field of the new package entry options.pas: * TOption.interpret_option & read_arguments: adjust call to add_package() pmodules.pas: * proc_package: adjust call to add_package() ........ Also load all packages that are required by packages, but that are not part of the directly used packages. pkgutil.pas, load_packages: * check the list of required packages for packages that are not yet part of the package list and add these as indirect packages * establish the links to loaded packages in the required packages once all packages were loaded ........ fpcp.pas, tpcppackage: + new method add_required_package() to add a required package while ignoring duplicates ........ pmodules.pas, proc_package: * add all packages of loaded units as required packages ........ git-svn-id: trunk@33517 -
This commit is contained in:
parent
3e70ac05c2
commit
e8ede4c3e2
@ -57,6 +57,7 @@ interface
|
|||||||
function getmodulestream(module:tmodulebase):tcstream;
|
function getmodulestream(module:tmodulebase):tcstream;
|
||||||
procedure initmoduleinfo(module:tmodulebase);
|
procedure initmoduleinfo(module:tmodulebase);
|
||||||
procedure addunit(module:tmodulebase);
|
procedure addunit(module:tmodulebase);
|
||||||
|
procedure add_required_package(pkg:tpackage);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -551,5 +552,19 @@ implementation
|
|||||||
containedmodules.add(module.modulename^,containedunit);
|
containedmodules.add(module.modulename^,containedunit);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure tpcppackage.add_required_package(pkg:tpackage);
|
||||||
|
var
|
||||||
|
p : tpackage;
|
||||||
|
begin
|
||||||
|
p:=tpackage(requiredpackages.find(pkg.packagename^));
|
||||||
|
if not assigned(p) then
|
||||||
|
requiredpackages.Add(pkg.packagename^,pkg)
|
||||||
|
else
|
||||||
|
if p<>pkg then
|
||||||
|
internalerror(2015112302);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ interface
|
|||||||
package : tpackage;
|
package : tpackage;
|
||||||
realpkgname : string;
|
realpkgname : string;
|
||||||
usedunits : longint;
|
usedunits : longint;
|
||||||
|
direct : boolean;
|
||||||
end;
|
end;
|
||||||
ppackageentry=^tpackageentry;
|
ppackageentry=^tpackageentry;
|
||||||
|
|
||||||
|
@ -1555,7 +1555,7 @@ begin
|
|||||||
if ispara then
|
if ispara then
|
||||||
parapackages.add(more,nil)
|
parapackages.add(more,nil)
|
||||||
else
|
else
|
||||||
add_package(more,true);
|
add_package(more,true,true);
|
||||||
end;
|
end;
|
||||||
'p' :
|
'p' :
|
||||||
begin
|
begin
|
||||||
@ -3637,7 +3637,7 @@ begin
|
|||||||
FrameworkSearchPath.AddList(option.ParaFrameworkPath,true);
|
FrameworkSearchPath.AddList(option.ParaFrameworkPath,true);
|
||||||
packagesearchpath.addlist(option.parapackagepath,true);
|
packagesearchpath.addlist(option.parapackagepath,true);
|
||||||
for j:=0 to option.parapackages.count-1 do
|
for j:=0 to option.parapackages.count-1 do
|
||||||
add_package(option.parapackages.NameOfIndex(j),true);
|
add_package(option.parapackages.NameOfIndex(j),true,true);
|
||||||
|
|
||||||
{ add unit environment and exepath to the unit search path }
|
{ add unit environment and exepath to the unit search path }
|
||||||
if inputfilepath<>'' then
|
if inputfilepath<>'' then
|
||||||
|
@ -33,7 +33,7 @@ interface
|
|||||||
Function RewritePPU(const PPUFn:String;OutStream:TCStream):Boolean;
|
Function RewritePPU(const PPUFn:String;OutStream:TCStream):Boolean;
|
||||||
procedure export_unit(u:tmodule);
|
procedure export_unit(u:tmodule);
|
||||||
procedure load_packages;
|
procedure load_packages;
|
||||||
procedure add_package(const name:string;ignoreduplicates:boolean);
|
procedure add_package(const name:string;ignoreduplicates:boolean;direct:boolean);
|
||||||
procedure add_package_unit_ref(package:tpackage);
|
procedure add_package_unit_ref(package:tpackage);
|
||||||
procedure add_package_libs(l:tlinker);
|
procedure add_package_libs(l:tlinker);
|
||||||
|
|
||||||
@ -382,13 +382,17 @@ implementation
|
|||||||
|
|
||||||
procedure load_packages;
|
procedure load_packages;
|
||||||
var
|
var
|
||||||
i : longint;
|
i,j : longint;
|
||||||
pcp: tpcppackage;
|
pcp: tpcppackage;
|
||||||
entry : ppackageentry;
|
entry,
|
||||||
|
entryreq : ppackageentry;
|
||||||
|
name,
|
||||||
|
uname : string;
|
||||||
begin
|
begin
|
||||||
if not (tf_supports_packages in target_info.flags) then
|
if not (tf_supports_packages in target_info.flags) then
|
||||||
exit;
|
exit;
|
||||||
for i:=0 to packagelist.count-1 do
|
i:=0;
|
||||||
|
while i<packagelist.count do
|
||||||
begin
|
begin
|
||||||
entry:=ppackageentry(packagelist[i]);
|
entry:=ppackageentry(packagelist[i]);
|
||||||
if assigned(entry^.package) then
|
if assigned(entry^.package) then
|
||||||
@ -397,11 +401,46 @@ implementation
|
|||||||
pcp:=tpcppackage.create(entry^.realpkgname);
|
pcp:=tpcppackage.create(entry^.realpkgname);
|
||||||
pcp.loadpcp;
|
pcp.loadpcp;
|
||||||
entry^.package:=pcp;
|
entry^.package:=pcp;
|
||||||
|
|
||||||
|
{ add all required packages that are not yet part of packagelist }
|
||||||
|
for j:=0 to pcp.requiredpackages.count-1 do
|
||||||
|
begin
|
||||||
|
name:=pcp.requiredpackages.NameOfIndex(j);
|
||||||
|
uname:=upper(name);
|
||||||
|
if not assigned(packagelist.Find(uname)) then
|
||||||
|
begin
|
||||||
|
New(entryreq);
|
||||||
|
entryreq^.realpkgname:=name;
|
||||||
|
entryreq^.package:=nil;
|
||||||
|
entryreq^.usedunits:=0;
|
||||||
|
entryreq^.direct:=false;
|
||||||
|
packagelist.add(uname,entryreq);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Inc(i);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ all packages are now loaded, so we can fill in the links of the required packages }
|
||||||
|
for i:=0 to packagelist.count-1 do
|
||||||
|
begin
|
||||||
|
entry:=ppackageentry(packagelist[i]);
|
||||||
|
if not assigned(entry^.package) then
|
||||||
|
internalerror(2015111301);
|
||||||
|
for j:=0 to entry^.package.requiredpackages.count-1 do
|
||||||
|
begin
|
||||||
|
if assigned(entry^.package.requiredpackages[j]) then
|
||||||
|
internalerror(2015111303);
|
||||||
|
entryreq:=packagelist.find(upper(entry^.package.requiredpackages.NameOfIndex(j)));
|
||||||
|
if not assigned(entryreq) then
|
||||||
|
internalerror(2015111302);
|
||||||
|
entry^.package.requiredpackages[j]:=entryreq^.package;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure add_package(const name:string;ignoreduplicates:boolean);
|
procedure add_package(const name:string;ignoreduplicates:boolean;direct:boolean);
|
||||||
var
|
var
|
||||||
entry : ppackageentry;
|
entry : ppackageentry;
|
||||||
i : longint;
|
i : longint;
|
||||||
@ -419,6 +458,7 @@ implementation
|
|||||||
entry^.package:=nil;
|
entry^.package:=nil;
|
||||||
entry^.realpkgname:=name;
|
entry^.realpkgname:=name;
|
||||||
entry^.usedunits:=0;
|
entry^.usedunits:=0;
|
||||||
|
entry^.direct:=direct;
|
||||||
packagelist.add(upper(name),entry);
|
packagelist.add(upper(name),entry);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -1384,6 +1384,7 @@ type
|
|||||||
force_init_final : boolean;
|
force_init_final : boolean;
|
||||||
uu : tused_unit;
|
uu : tused_unit;
|
||||||
module_name: ansistring;
|
module_name: ansistring;
|
||||||
|
pentry: ppackageentry;
|
||||||
begin
|
begin
|
||||||
Status.IsPackage:=true;
|
Status.IsPackage:=true;
|
||||||
Status.IsExe:=true;
|
Status.IsExe:=true;
|
||||||
@ -1482,7 +1483,7 @@ type
|
|||||||
module_name:=module_name+'.'+orgpattern;
|
module_name:=module_name+'.'+orgpattern;
|
||||||
consume(_ID);
|
consume(_ID);
|
||||||
end;
|
end;
|
||||||
add_package(module_name,false);
|
add_package(module_name,false,true);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
consume(_ID);
|
consume(_ID);
|
||||||
@ -1721,8 +1722,18 @@ type
|
|||||||
hp:=tmodule(loaded_units.first);
|
hp:=tmodule(loaded_units.first);
|
||||||
while assigned(hp) do
|
while assigned(hp) do
|
||||||
begin
|
begin
|
||||||
if (hp<>current_module) and not assigned(hp.package) then
|
if (hp<>current_module) then
|
||||||
pkg.addunit(hp);
|
begin
|
||||||
|
if not assigned(hp.package) then
|
||||||
|
pkg.addunit(hp)
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
pentry:=ppackageentry(packagelist.find(hp.package.packagename^));
|
||||||
|
if not assigned(pentry) then
|
||||||
|
internalerror(2015112301);
|
||||||
|
pkg.add_required_package(hp.package);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
hp:=tmodule(hp.next);
|
hp:=tmodule(hp.next);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user