mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-11-04 09:39:32 +01:00 
			
		
		
		
	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 -
		
			
				
	
	
		
			124 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			ObjectPascal
		
	
	
	
	
	
			
		
		
	
	
			124 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			ObjectPascal
		
	
	
	
	
	
{
 | 
						|
    Copyright (c) 2013-2016 by Free Pascal Development Team
 | 
						|
 | 
						|
    This unit implements basic parts of the package system
 | 
						|
 | 
						|
    This program is free software; you can redistribute it and/or modify
 | 
						|
    it under the terms of the GNU General Public License as published by
 | 
						|
    the Free Software Foundation; either version 2 of the License, or
 | 
						|
    (at your option) any later version.
 | 
						|
 | 
						|
    This program is distributed in the hope that it will be useful,
 | 
						|
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
						|
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
						|
    GNU General Public License for more details.
 | 
						|
 | 
						|
    You should have received a copy of the GNU General Public License
 | 
						|
    along with this program; if not, write to the Free Software
 | 
						|
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 | 
						|
 | 
						|
 ****************************************************************************
 | 
						|
}
 | 
						|
unit fpkg;
 | 
						|
 | 
						|
{$i fpcdefs.inc}
 | 
						|
 | 
						|
interface
 | 
						|
 | 
						|
  uses
 | 
						|
    cclasses,
 | 
						|
    globtype,
 | 
						|
    finput;
 | 
						|
 | 
						|
  type
 | 
						|
    tcontainedunit=record
 | 
						|
      module:tmodulebase;
 | 
						|
      ppufile:tpathstr;
 | 
						|
      offset:longint;
 | 
						|
      size:longint;
 | 
						|
    end;
 | 
						|
    pcontainedunit=^tcontainedunit;
 | 
						|
 | 
						|
    tpackage=class
 | 
						|
    public
 | 
						|
      realpackagename,
 | 
						|
      packagename : pshortstring;
 | 
						|
      containedmodules : TFPHashList;
 | 
						|
      requiredpackages : TFPHashObjectList;
 | 
						|
      pcpfilename,
 | 
						|
      ppafilename,
 | 
						|
      pplfilename : tpathstr;
 | 
						|
      constructor create(const pn:string);
 | 
						|
      destructor destroy;override;
 | 
						|
    end;
 | 
						|
 | 
						|
    tpackageentry=record
 | 
						|
      package : tpackage;
 | 
						|
      realpkgname : string;
 | 
						|
      usedunits : longint;
 | 
						|
      direct : boolean;
 | 
						|
    end;
 | 
						|
    ppackageentry=^tpackageentry;
 | 
						|
 | 
						|
implementation
 | 
						|
 | 
						|
  uses
 | 
						|
    cutils,globals;
 | 
						|
 | 
						|
  { tpackage }
 | 
						|
 | 
						|
  constructor tpackage.create(const pn: string);
 | 
						|
    begin
 | 
						|
      realpackagename:=stringdup(pn);
 | 
						|
      packagename:=stringdup(upper(pn));
 | 
						|
      containedmodules:=TFPHashList.Create;
 | 
						|
      requiredpackages:=TFPHashObjectList.Create(false);
 | 
						|
    end;
 | 
						|
 | 
						|
  destructor tpackage.destroy;
 | 
						|
    var
 | 
						|
      p : pcontainedunit;
 | 
						|
      i : longint;
 | 
						|
    begin
 | 
						|
      if assigned(containedmodules) then
 | 
						|
        for i:=0 to containedmodules.count-1 do
 | 
						|
          begin
 | 
						|
            p:=pcontainedunit(containedmodules[i]);
 | 
						|
            dispose(p);
 | 
						|
          end;
 | 
						|
      containedmodules.free;
 | 
						|
      requiredpackages.free;
 | 
						|
      inherited destroy;
 | 
						|
    end;
 | 
						|
 | 
						|
 | 
						|
    procedure packageinit;
 | 
						|
      begin
 | 
						|
        packagelist:=TFPHashList.Create;
 | 
						|
      end;
 | 
						|
 | 
						|
 | 
						|
    procedure packagedone;
 | 
						|
      var
 | 
						|
        i : longint;
 | 
						|
        pkgentry : ppackageentry;
 | 
						|
      begin
 | 
						|
        if assigned(packagelist) then
 | 
						|
          begin
 | 
						|
            for i:=0 to packagelist.count-1 do
 | 
						|
              begin
 | 
						|
                pkgentry:=ppackageentry(packagelist[i]);
 | 
						|
                pkgentry^.package.free;
 | 
						|
                dispose(pkgentry);
 | 
						|
              end;
 | 
						|
          end;
 | 
						|
        packagelist.Free;
 | 
						|
        packagelist:=nil;
 | 
						|
      end;
 | 
						|
 | 
						|
 | 
						|
initialization
 | 
						|
  register_initdone_proc(@packageinit,@packagedone);
 | 
						|
end.
 | 
						|
 |