mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-15 04:19:30 +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;
|
||||
procedure initmoduleinfo(module:tmodulebase);
|
||||
procedure addunit(module:tmodulebase);
|
||||
procedure add_required_package(pkg:tpackage);
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -551,5 +552,19 @@ implementation
|
||||
containedmodules.add(module.modulename^,containedunit);
|
||||
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.
|
||||
|
||||
|
@ -56,6 +56,7 @@ interface
|
||||
package : tpackage;
|
||||
realpkgname : string;
|
||||
usedunits : longint;
|
||||
direct : boolean;
|
||||
end;
|
||||
ppackageentry=^tpackageentry;
|
||||
|
||||
|
@ -1555,7 +1555,7 @@ begin
|
||||
if ispara then
|
||||
parapackages.add(more,nil)
|
||||
else
|
||||
add_package(more,true);
|
||||
add_package(more,true,true);
|
||||
end;
|
||||
'p' :
|
||||
begin
|
||||
@ -3637,7 +3637,7 @@ begin
|
||||
FrameworkSearchPath.AddList(option.ParaFrameworkPath,true);
|
||||
packagesearchpath.addlist(option.parapackagepath,true);
|
||||
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 }
|
||||
if inputfilepath<>'' then
|
||||
|
@ -33,7 +33,7 @@ interface
|
||||
Function RewritePPU(const PPUFn:String;OutStream:TCStream):Boolean;
|
||||
procedure export_unit(u:tmodule);
|
||||
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_libs(l:tlinker);
|
||||
|
||||
@ -382,13 +382,17 @@ implementation
|
||||
|
||||
procedure load_packages;
|
||||
var
|
||||
i : longint;
|
||||
i,j : longint;
|
||||
pcp: tpcppackage;
|
||||
entry : ppackageentry;
|
||||
entry,
|
||||
entryreq : ppackageentry;
|
||||
name,
|
||||
uname : string;
|
||||
begin
|
||||
if not (tf_supports_packages in target_info.flags) then
|
||||
exit;
|
||||
for i:=0 to packagelist.count-1 do
|
||||
i:=0;
|
||||
while i<packagelist.count do
|
||||
begin
|
||||
entry:=ppackageentry(packagelist[i]);
|
||||
if assigned(entry^.package) then
|
||||
@ -397,11 +401,46 @@ implementation
|
||||
pcp:=tpcppackage.create(entry^.realpkgname);
|
||||
pcp.loadpcp;
|
||||
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;
|
||||
|
||||
|
||||
procedure add_package(const name:string;ignoreduplicates:boolean);
|
||||
procedure add_package(const name:string;ignoreduplicates:boolean;direct:boolean);
|
||||
var
|
||||
entry : ppackageentry;
|
||||
i : longint;
|
||||
@ -419,6 +458,7 @@ implementation
|
||||
entry^.package:=nil;
|
||||
entry^.realpkgname:=name;
|
||||
entry^.usedunits:=0;
|
||||
entry^.direct:=direct;
|
||||
packagelist.add(upper(name),entry);
|
||||
end;
|
||||
|
||||
|
@ -1384,6 +1384,7 @@ type
|
||||
force_init_final : boolean;
|
||||
uu : tused_unit;
|
||||
module_name: ansistring;
|
||||
pentry: ppackageentry;
|
||||
begin
|
||||
Status.IsPackage:=true;
|
||||
Status.IsExe:=true;
|
||||
@ -1482,7 +1483,7 @@ type
|
||||
module_name:=module_name+'.'+orgpattern;
|
||||
consume(_ID);
|
||||
end;
|
||||
add_package(module_name,false);
|
||||
add_package(module_name,false,true);
|
||||
end
|
||||
else
|
||||
consume(_ID);
|
||||
@ -1721,8 +1722,18 @@ type
|
||||
hp:=tmodule(loaded_units.first);
|
||||
while assigned(hp) do
|
||||
begin
|
||||
if (hp<>current_module) and not assigned(hp.package) then
|
||||
pkg.addunit(hp);
|
||||
if (hp<>current_module) then
|
||||
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);
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user