mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-05 11:38:04 +02:00
ide: Added ability to add fpmake-dependencies to projects
git-svn-id: trunk@58374 -
This commit is contained in:
parent
9069f48fa7
commit
0141dd2967
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -10191,6 +10191,8 @@ packager/adddirtopkgdlg.lfm svneol=native#text/plain
|
||||
packager/adddirtopkgdlg.pas svneol=native#text/plain
|
||||
packager/addfiletoapackagedlg.lfm svneol=native#text/plain
|
||||
packager/addfiletoapackagedlg.pas svneol=native#text/pascal
|
||||
packager/addfpmakedependencydlg.lfm svneol=native#text/plain
|
||||
packager/addfpmakedependencydlg.pas svneol=native#text/pascal
|
||||
packager/addpkgdependencydlg.lfm svneol=native#text/plain
|
||||
packager/addpkgdependencydlg.pas svneol=native#text/pascal
|
||||
packager/addtopackagedlg.lfm svneol=native#text/plain
|
||||
@ -10202,6 +10204,7 @@ packager/cleanpkgdeps.lfm svneol=native#text/plain
|
||||
packager/cleanpkgdeps.pas svneol=native#text/plain
|
||||
packager/confirmpkglistdlg.lfm svneol=native#text/plain
|
||||
packager/confirmpkglistdlg.pas svneol=native#text/plain
|
||||
packager/fppkghelper.pas svneol=native#text/pascal
|
||||
packager/frames/package_description_options.lfm svneol=native#text/plain
|
||||
packager/frames/package_description_options.pas svneol=native#text/pascal
|
||||
packager/frames/package_i18n_options.lfm svneol=native#text/plain
|
||||
|
@ -4647,6 +4647,7 @@ resourcestring
|
||||
lisPckEditRemovedRequiredPackages = 'Removed required packages';
|
||||
lisPckEditDefault = '%s, default: %s';
|
||||
lisPckEditAvailableOnline = '(available online)';
|
||||
lisPckEditFPMakePackage = '(fpmake)';
|
||||
lisPckEditDependencyProperties = 'Dependency Properties';
|
||||
lisFilesHasRegisterProcedureInPackageUsesSection = 'Files: %s, has Register '
|
||||
+'procedure: %s, in package uses section: %s';
|
||||
|
@ -4619,9 +4619,13 @@ end;
|
||||
|
||||
procedure TProject.GetAllRequiredPackages(var List: TFPList;
|
||||
ReqFlags: TPkgIntfRequiredFlags; MinPolicy: TPackageUpdatePolicy);
|
||||
var
|
||||
FPMakeList: TFPList;
|
||||
begin
|
||||
if Assigned(OnGetAllRequiredPackages) then
|
||||
OnGetAllRequiredPackages(nil,FirstRequiredDependency,List,ReqFlags,MinPolicy);
|
||||
if Assigned(OnGetAllRequiredPackages) then begin
|
||||
OnGetAllRequiredPackages(nil,FirstRequiredDependency,List,FPMakeList,ReqFlags,MinPolicy);
|
||||
FPMakeList.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TProject.AddPackageDependency(const PackageName: string);
|
||||
@ -4631,6 +4635,7 @@ begin
|
||||
if FindDependencyByNameInList(FirstRequiredDependency,pdlRequires,PackageName)
|
||||
<>nil then exit;
|
||||
PkgDependency:=TPkgDependency.Create;
|
||||
PkgDependency.DependencyType:=pdtLazarus;
|
||||
PkgDependency.PackageName:=PackageName;
|
||||
AddRequiredDependency(PkgDependency);
|
||||
end;
|
||||
|
@ -163,5 +163,9 @@ object ProjectInspectorForm: TProjectInspectorForm
|
||||
Caption = 'Add requirement'
|
||||
OnClick = mnuAddReqClick
|
||||
end
|
||||
object mnuAddFPMakeReq: TMenuItem
|
||||
Caption = 'Add FPMake requirement'
|
||||
OnClick = mnuAddFPMakeReqClick
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -64,7 +64,7 @@ uses
|
||||
// IDE
|
||||
LazarusIDEStrConsts, IDEProcs, DialogProcs, IDEOptionDefs, EnvironmentOpts,
|
||||
PackageDefs, Project, PackageEditor, AddToProjectDlg, AddPkgDependencyDlg,
|
||||
InputHistory, MainBase, ProjPackChecks, PackageLinks;
|
||||
InputHistory, MainBase, ProjPackChecks, PackageLinks, AddFPMakeDependencyDlg;
|
||||
|
||||
type
|
||||
TOnAddUnitToProject =
|
||||
@ -93,6 +93,7 @@ type
|
||||
FilterEdit: TTreeFilterEdit;
|
||||
MenuItem1: TMenuItem;
|
||||
MenuItem2: TMenuItem;
|
||||
mnuAddFPMakeReq: TMenuItem;
|
||||
mnuAddEditorFiles: TMenuItem;
|
||||
mnuAddDiskFile: TMenuItem;
|
||||
mnuAddDiskFiles: TMenuItem;
|
||||
@ -126,6 +127,7 @@ type
|
||||
procedure mnuAddBitBtnClick(Sender: TObject);
|
||||
procedure mnuAddDiskFilesClick(Sender: TObject);
|
||||
procedure mnuAddEditorFilesClick(Sender: TObject);
|
||||
procedure mnuAddFPMakeReqClick(Sender: TObject);
|
||||
procedure mnuAddReqClick(Sender: TObject);
|
||||
procedure MoveDependencyUpClick(Sender: TObject);
|
||||
procedure MoveDependencyDownClick(Sender: TObject);
|
||||
@ -177,6 +179,7 @@ type
|
||||
function AddOneFile(aFilename: string): TModalResult;
|
||||
procedure DoAddMoreDialog(AInitTab: TAddToProjectType);
|
||||
procedure DoAddDepDialog;
|
||||
procedure DoAddFPMakeDepDialog;
|
||||
procedure FreeNodeData(Typ: TPENodeType);
|
||||
function CreateNodeData(Typ: TPENodeType; aName: string; aRemoved: boolean): TPENodeData;
|
||||
procedure SetDependencyDefaultFilename(AsPreferred: boolean);
|
||||
@ -377,6 +380,11 @@ begin
|
||||
DoAddMoreDialog(a2pEditorFiles);
|
||||
end;
|
||||
|
||||
procedure TProjectInspectorForm.mnuAddFPMakeReqClick(Sender: TObject);
|
||||
begin
|
||||
DoAddFPMakeDepDialog;
|
||||
end;
|
||||
|
||||
procedure TProjectInspectorForm.mnuAddReqClick(Sender: TObject);
|
||||
begin
|
||||
DoAddDepDialog;
|
||||
@ -526,6 +534,28 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TProjectInspectorForm.DoAddFPMakeDepDialog;
|
||||
var
|
||||
Deps: TPkgDependencyList;
|
||||
i: Integer;
|
||||
Resu: TModalResult;
|
||||
begin
|
||||
Resu:=ShowAddFPMakeDependencyDlg(LazProject, Deps);
|
||||
try
|
||||
if (Resu<>mrOK) or (Deps.Count=0) then exit;
|
||||
try
|
||||
BeginUpdate;
|
||||
for i := 0 to Deps.Count-1 do
|
||||
OnAddDependency(Self, Deps[i]);
|
||||
FNextSelectedPart:=Deps[Deps.Count-1];
|
||||
finally
|
||||
EndUpdate;
|
||||
end;
|
||||
finally
|
||||
Deps.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TProjectInspectorForm.CopyMoveToDirMenuItemClick(Sender: TObject);
|
||||
begin
|
||||
OnCopyMoveFiles(Self);
|
||||
@ -651,7 +681,8 @@ begin
|
||||
else
|
||||
SingleSelectedDep:=nil;
|
||||
inc(CanRemoveCount);
|
||||
inc(CanOpenCount);
|
||||
if Dependency.DependencyType=pdtLazarus then
|
||||
inc(CanOpenCount);
|
||||
if Dependency.RequiredPackage<>nil then
|
||||
inc(HasValidDep);
|
||||
if (Dependency.DefaultFilename<>'') then
|
||||
@ -766,7 +797,7 @@ begin
|
||||
PkgLinks.Free;
|
||||
Exit;
|
||||
end;
|
||||
end else if Item is TPkgDependency then begin
|
||||
end else if (Item is TPkgDependency) and (TPkgDependency(Item).DependencyType=pdtLazarus) then begin
|
||||
CurDependency:=TPkgDependency(Item);
|
||||
if CurDependency.LoadPackageResult = lprSuccess then begin
|
||||
if PackageEditingInterface.DoOpenPackageWithName(CurDependency.PackageName,[],false)<>mrOk then begin
|
||||
@ -1194,6 +1225,8 @@ begin
|
||||
if OPMInterface<>nil then
|
||||
if FindOnlinePackageLink(Dependency)<>nil then
|
||||
NodeText:=NodeText+' '+lisPckEditAvailableOnline;
|
||||
if Dependency.DependencyType=pdtFPMake then
|
||||
NodeText:=NodeText+' '+lisPckEditFPMakePackage;
|
||||
// Add the required package under the branch
|
||||
ANodeData := CreateNodeData(penDependency, Dependency.PackageName, False);
|
||||
RequiredBranch.AddNodeData(NodeText, ANodeData);
|
||||
@ -1279,7 +1312,7 @@ begin
|
||||
for i:=0 to ItemsTreeView.Items.Count-1 do begin
|
||||
TVNode:=ItemsTreeView.Items[i];
|
||||
if not GetNodeDataItem(TVNode,NodeData,Item) then continue;
|
||||
if not (Item is TPkgDependency) then continue;
|
||||
if not (Item is TPkgDependency) or (TPkgDependency(Item).DependencyType=pdtFPMake) then continue;
|
||||
CurDependency:=TPkgDependency(Item);
|
||||
NodeText:=CurDependency.AsString;
|
||||
ImageIndex:=ImageIndexRequired;
|
||||
@ -1536,7 +1569,7 @@ begin
|
||||
if CurUnitInfo<>LazProject.MainUnitInfo then
|
||||
inc(CanRemoveCount);
|
||||
end else if Item is TPkgDependency then begin
|
||||
if not NodeData.Removed then begin
|
||||
if not NodeData.Removed and (TPkgDependency(Item).DependencyType=pdtLazarus) then begin
|
||||
inc(CanRemoveCount);
|
||||
inc(CanOpenCount);
|
||||
end;
|
||||
|
85
packager/addfpmakedependencydlg.lfm
Normal file
85
packager/addfpmakedependencydlg.lfm
Normal file
@ -0,0 +1,85 @@
|
||||
object AddFPMakeDependencyDialog: TAddFPMakeDependencyDialog
|
||||
Left = 1470
|
||||
Height = 300
|
||||
Top = 366
|
||||
Width = 450
|
||||
Caption = 'AddFPMakeDependencyDialog'
|
||||
ClientHeight = 300
|
||||
ClientWidth = 450
|
||||
LCLVersion = '1.9.0.0'
|
||||
object BP: TButtonPanel
|
||||
Left = 6
|
||||
Height = 46
|
||||
Top = 248
|
||||
Width = 438
|
||||
OKButton.Name = 'OKButton'
|
||||
OKButton.DefaultCaption = True
|
||||
OKButton.OnClick = OKButtonClick
|
||||
HelpButton.Name = 'HelpButton'
|
||||
HelpButton.DefaultCaption = True
|
||||
CloseButton.Name = 'CloseButton'
|
||||
CloseButton.Caption = 'Install'
|
||||
CloseButton.DefaultCaption = False
|
||||
CancelButton.Name = 'CancelButton'
|
||||
CancelButton.DefaultCaption = True
|
||||
TabOrder = 0
|
||||
ShowButtons = [pbOK, pbCancel, pbHelp]
|
||||
ShowGlyphs = []
|
||||
end
|
||||
object DependPkgNameLabel: TLabel
|
||||
AnchorSideTop.Control = DependPkgNameFilter
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = DependPkgNameFilter
|
||||
Left = -22
|
||||
Height = 20
|
||||
Top = 15
|
||||
Width = 145
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Top = 3
|
||||
BorderSpacing.Right = 6
|
||||
BorderSpacing.CellAlignHorizontal = ccaLeftTop
|
||||
BorderSpacing.CellAlignVertical = ccaCenter
|
||||
Caption = 'DependPkgNameLabel'
|
||||
ParentColor = False
|
||||
ParentFont = False
|
||||
end
|
||||
object DependPkgNameFilter: TListFilterEdit
|
||||
AnchorSideLeft.Control = DependPkgNameListBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 129
|
||||
Height = 37
|
||||
Top = 7
|
||||
Width = 313
|
||||
ButtonWidth = 23
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Top = 3
|
||||
BorderSpacing.Right = 8
|
||||
NumGlyphs = 1
|
||||
MaxLength = 0
|
||||
ParentFont = False
|
||||
TabOrder = 1
|
||||
FilteredListbox = DependPkgNameListBox
|
||||
end
|
||||
object DependPkgNameListBox: TListBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = DependPkgNameFilter
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 129
|
||||
Height = 200
|
||||
Top = 44
|
||||
Width = 313
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Top = 6
|
||||
BorderSpacing.Bottom = 6
|
||||
ItemHeight = 16
|
||||
MultiSelect = True
|
||||
Options = []
|
||||
ParentFont = False
|
||||
ScrollWidth = 311
|
||||
Style = lbOwnerDrawVariable
|
||||
TabOrder = 2
|
||||
TopIndex = -1
|
||||
end
|
||||
end
|
128
packager/addfpmakedependencydlg.pas
Normal file
128
packager/addfpmakedependencydlg.pas
Normal file
@ -0,0 +1,128 @@
|
||||
unit AddFPMakeDependencyDlg;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ButtonPanel, StdCtrls,
|
||||
ListFilterEdit, fgl,
|
||||
ProjPackCommon,
|
||||
PackageDefs,
|
||||
LazarusIDEStrConsts,
|
||||
IDEWindowIntf,
|
||||
AddPkgDependencyDlg,
|
||||
// fppkg
|
||||
FppkgHelper;
|
||||
|
||||
type
|
||||
|
||||
{ TAddFPMakeDependencyDialog }
|
||||
|
||||
TAddFPMakeDependencyDialog = class(TForm)
|
||||
BP: TButtonPanel;
|
||||
DependPkgNameFilter: TListFilterEdit;
|
||||
DependPkgNameLabel: TLabel;
|
||||
DependPkgNameListBox: TListBox;
|
||||
procedure OKButtonClick(Sender: TObject);
|
||||
private
|
||||
FResultDependencies: TPkgDependencyList;
|
||||
FPackageNameList: TStringList;
|
||||
procedure UpdateAvailableDependencyNames;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
function ShowAddFPMakeDependencyDlg(AProjPack: IProjPack;
|
||||
out AResultDependencies: TPkgDependencyList): TModalResult;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
function ShowAddFPMakeDependencyDlg(AProjPack: IProjPack; out AResultDependencies: TPkgDependencyList): TModalResult;
|
||||
var
|
||||
AddDepDialog: TAddFPMakeDependencyDialog;
|
||||
begin
|
||||
AddDepDialog:=TAddFPMakeDependencyDialog.Create(nil);
|
||||
AddDepDialog.UpdateAvailableDependencyNames;
|
||||
|
||||
Result:=AddDepDialog.ShowModal;
|
||||
if Result=mrOk then
|
||||
begin
|
||||
AResultDependencies:=AddDepDialog.FResultDependencies;
|
||||
AddDepDialog.fResultDependencies:=nil;
|
||||
end
|
||||
else
|
||||
begin
|
||||
AResultDependencies:=nil;
|
||||
end;
|
||||
AddDepDialog.Free;
|
||||
end;
|
||||
|
||||
{ TAddFPMakeDependencyDialog }
|
||||
|
||||
procedure TAddFPMakeDependencyDialog.OKButtonClick(Sender: TObject);
|
||||
var
|
||||
NewDependency: TPkgDependency;
|
||||
i: Integer;
|
||||
begin
|
||||
// Add all selected packages.
|
||||
FResultDependencies := TPkgDependencyList.Create; // Will be freed by the caller.
|
||||
if DependPkgNameListBox.SelCount > 0 then
|
||||
begin
|
||||
for i := 0 to DependPkgNameListBox.Count-1 do
|
||||
begin
|
||||
if DependPkgNameListBox.Selected[i] then
|
||||
begin
|
||||
NewDependency := TPkgDependency.Create; // Will be added to package graph.
|
||||
NewDependency.PackageName := DependPkgNameListBox.Items[i];
|
||||
NewDependency.DependencyType := pdtFPMake;
|
||||
//if not CheckAddingDependency(fProjPack, NewDependency) then exit;
|
||||
FResultDependencies.Add(NewDependency);
|
||||
NewDependency := nil;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
ModalResult := mrOk;
|
||||
end;
|
||||
|
||||
procedure TAddFPMakeDependencyDialog.UpdateAvailableDependencyNames;
|
||||
begin
|
||||
FPackageNameList.Clear;
|
||||
TFppkgHelper.Instance.ListPackages(FPackageNameList);
|
||||
|
||||
FPackageNameList.Sort;
|
||||
|
||||
DependPkgNameFilter.Items.BeginUpdate;
|
||||
try
|
||||
DependPkgNameFilter.Items.Clear;
|
||||
DependPkgNameFilter.Items.Assign(FPackageNameList);
|
||||
DependPkgNameFilter.InvalidateFilter;
|
||||
finally
|
||||
DependPkgNameFilter.Items.EndUpdate;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TAddFPMakeDependencyDialog.Create(TheOwner: TComponent);
|
||||
begin
|
||||
inherited Create(TheOwner);
|
||||
FPackageNameList := TStringList.Create;
|
||||
|
||||
Caption:=lisProjAddNewRequirement;
|
||||
|
||||
DependPkgNameLabel.Caption:=lisProjAddPackageName;
|
||||
BP.CloseButton.Caption := lisPckEditInstall;
|
||||
|
||||
IDEDialogLayoutList.ApplyLayout(Self,450,300);
|
||||
end;
|
||||
|
||||
destructor TAddFPMakeDependencyDialog.Destroy;
|
||||
begin
|
||||
FPackageNameList.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
108
packager/fppkghelper.pas
Normal file
108
packager/fppkghelper.pas
Normal file
@ -0,0 +1,108 @@
|
||||
unit FppkgHelper;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes,
|
||||
SysUtils,
|
||||
fprepos,
|
||||
pkgFppkg;
|
||||
|
||||
type
|
||||
|
||||
{ TFppkgHelper }
|
||||
|
||||
TFppkgHelper = class
|
||||
private
|
||||
FFPpkg: TpkgFPpkg;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
class function Instance: TFppkgHelper;
|
||||
function HasPackage(const PackageName: string): Boolean;
|
||||
procedure ListPackages(AList: TStringList);
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
var
|
||||
GFppkgHelper: TFppkgHelper = nil;
|
||||
|
||||
{ TFppkgHelper }
|
||||
|
||||
constructor TFppkgHelper.Create;
|
||||
var
|
||||
FPpkg: TpkgFPpkg;
|
||||
begin
|
||||
FPpkg := TpkgFPpkg.Create(nil);
|
||||
try
|
||||
FPpkg.InitializeGlobalOptions('');
|
||||
FPpkg.InitializeCompilerOptions;
|
||||
|
||||
FPpkg.CompilerOptions.CheckCompilerValues;
|
||||
FPpkg.FpmakeCompilerOptions.CheckCompilerValues;
|
||||
|
||||
FPpkg.LoadLocalAvailableMirrors;
|
||||
|
||||
FPpkg.ScanPackages;
|
||||
|
||||
FFPpkg := FPpkg;
|
||||
FPpkg := nil;
|
||||
finally
|
||||
FPpkg.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
destructor TFppkgHelper.Destroy;
|
||||
begin
|
||||
FFPpkg.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
class function TFppkgHelper.Instance: TFppkgHelper;
|
||||
begin
|
||||
if not Assigned(GFppkgHelper) then
|
||||
GFppkgHelper := TFppkgHelper.Create;
|
||||
Result := GFppkgHelper;
|
||||
end;
|
||||
|
||||
function TFppkgHelper.HasPackage(const PackageName: string): Boolean;
|
||||
begin
|
||||
Result :=
|
||||
Assigned(FFPpkg.FindPackage(PackageName,pkgpkInstalled)) or
|
||||
Assigned(FFPpkg.FindPackage(PackageName,pkgpkAvailable)) or
|
||||
Assigned(FFPpkg.FindPackage(PackageName,pkgpkBoth));
|
||||
|
||||
if not Result then
|
||||
begin
|
||||
// rescan and try again
|
||||
FFppkg.LoadLocalAvailableMirrors;
|
||||
FFppkg.ScanPackages;
|
||||
|
||||
Result :=
|
||||
Assigned(FFPpkg.FindPackage(PackageName,pkgpkInstalled)) or
|
||||
Assigned(FFPpkg.FindPackage(PackageName,pkgpkAvailable)) or
|
||||
Assigned(FFPpkg.FindPackage(PackageName,pkgpkBoth));
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TFppkgHelper.ListPackages(AList: TStringList);
|
||||
var
|
||||
I, J: Integer;
|
||||
Repository: TFPRepository;
|
||||
begin
|
||||
for I := 0 to FFPpkg.RepositoryList.Count -1 do
|
||||
begin
|
||||
Repository := FFPpkg.RepositoryList.Items[I] as TFPRepository;
|
||||
for J := 0 to Repository.PackageCount -1 do
|
||||
begin
|
||||
AList.AddObject(Repository.Packages[J].Name, Repository.Packages[J]);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
finalization
|
||||
GFppkgHelper.Free;
|
||||
end.
|
@ -70,7 +70,7 @@ type
|
||||
TGetAllRequiredPackagesEvent =
|
||||
procedure(APackage: TLazPackage; // if not nil then ignore FirstDependency and do not add APackage to Result
|
||||
FirstDependency: TPkgDependency;
|
||||
out List: TFPList;
|
||||
out List, FPMakeList: TFPList;
|
||||
Flags: TPkgIntfRequiredFlags = [];
|
||||
MinPolicy: TPackageUpdatePolicy = low(TPackageUpdatePolicy)) of object;
|
||||
TGetDependencyOwnerDescription =
|
||||
@ -229,12 +229,26 @@ type
|
||||
pdlRequires,
|
||||
pdlUsedBy
|
||||
);
|
||||
|
||||
|
||||
TPkgDependencyType = (
|
||||
pdtLazarus,
|
||||
pdtFPMake
|
||||
);
|
||||
|
||||
const
|
||||
PkgDependencyTypeNames: array[TPkgDependencyType] of string = (
|
||||
'Lazarus',
|
||||
'FPMake'
|
||||
);
|
||||
|
||||
type
|
||||
|
||||
{ TPkgDependency }
|
||||
|
||||
TPkgDependency = class(TPkgDependencyID)
|
||||
private
|
||||
FDefaultFilename: string;
|
||||
FDependencyType: TPkgDependencyType;
|
||||
FHoldPackage: boolean;
|
||||
FMarkerFlags: TPKgMarkerFlags;
|
||||
FOwner: TObject;
|
||||
@ -291,10 +305,11 @@ type
|
||||
property DefaultFilename: string read FDefaultFilename write FDefaultFilename;
|
||||
property PreferDefaultFilename: boolean read FPreferDefaultFilename write FPreferDefaultFilename;
|
||||
property RequiredPackage: TLazPackage read GetRequiredPackage write SetRequiredPackage;
|
||||
property DependencyType: TPkgDependencyType read FDependencyType write FDependencyType;
|
||||
end;
|
||||
PPkgDependency = ^TPkgDependency;
|
||||
|
||||
|
||||
|
||||
|
||||
{ TPkgPair }
|
||||
|
||||
TPkgPair = class
|
||||
@ -683,7 +698,7 @@ type
|
||||
function CreateDependencyWithOwner(NewOwner: TObject;
|
||||
WithMinVersion: boolean = false): TPkgDependency;
|
||||
function Requires(APackage: TLazPackage): boolean;
|
||||
procedure GetAllRequiredPackages(var List: TFPList; WithSelf: boolean;
|
||||
procedure GetAllRequiredPackages(var List, FPMakeList: TFPList; WithSelf: boolean;
|
||||
aFlags: TPkgIntfRequiredFlags = [];
|
||||
MinPolicy: TPackageUpdatePolicy = low(TPackageUpdatePolicy));
|
||||
// components
|
||||
@ -1745,6 +1760,7 @@ end;
|
||||
|
||||
procedure TPkgDependency.SetRequiredPackage(AValue: TLazPackage);
|
||||
begin
|
||||
Assert((FDependencyType=pdtLazarus) or not assigned(AValue), 'Not possible to set a reference to a LazPackage into an FPMake-dependency');
|
||||
RequiredIDEPackage := AValue;
|
||||
end;
|
||||
|
||||
@ -1796,6 +1812,10 @@ begin
|
||||
if FileVersion=1 then ;
|
||||
Clear;
|
||||
PackageName:=XMLConfig.GetValue(Path+'PackageName/Value','');
|
||||
if SameText(XMLConfig.GetValue(Path+'DependencyType/Value',''), PkgDependencyTypeNames[pdtFPMake]) then
|
||||
DependencyType:=pdtFPMake
|
||||
else
|
||||
DependencyType:=pdtLazarus;
|
||||
PkgVersionLoadFromXMLConfig(MaxVersion,XMLConfig,Path+'MaxVersion/',FileVersion);
|
||||
PkgVersionLoadFromXMLConfig(MinVersion,XMLConfig,Path+'MinVersion/',FileVersion);
|
||||
if XMLConfig.GetValue(Path+'MaxVersion/Valid',false) then
|
||||
@ -1830,6 +1850,7 @@ begin
|
||||
XMLConfig.SetDeleteValue(Path+'MinVersion/Valid',pdfMinVersion in FFlags,false);
|
||||
SaveFilename('DefaultFilename/Value',FDefaultFilename);
|
||||
XMLConfig.SetDeleteValue(Path+'DefaultFilename/Prefer',PreferDefaultFilename,false);
|
||||
XMLConfig.SetDeleteValue(Path+'DependencyType/Value',PkgDependencyTypeNames[DependencyType],PkgDependencyTypeNames[pdtLazarus]);
|
||||
end;
|
||||
|
||||
function TPkgDependency.Compare(Dependency2: TPkgDependency): integer;
|
||||
@ -3672,12 +3693,12 @@ begin
|
||||
Result:=podDefault;
|
||||
end;
|
||||
|
||||
procedure TLazPackage.GetAllRequiredPackages(var List: TFPList;
|
||||
procedure TLazPackage.GetAllRequiredPackages(var List, FPMakeList: TFPList;
|
||||
WithSelf: boolean; aFlags: TPkgIntfRequiredFlags;
|
||||
MinPolicy: TPackageUpdatePolicy);
|
||||
begin
|
||||
if Assigned(OnGetAllRequiredPackages) then
|
||||
OnGetAllRequiredPackages(Self,FirstRequiredDependency,List,aFlags,MinPolicy);
|
||||
OnGetAllRequiredPackages(Self,FirstRequiredDependency,List,FPMakeList,aFlags,MinPolicy);
|
||||
if WithSelf then begin
|
||||
if List=nil then List:=TFPList.Create;
|
||||
if List.IndexOf(Self)<0 then
|
||||
@ -3691,11 +3712,14 @@ end;
|
||||
procedure TLazPackage.GetInheritedCompilerOptions(var OptionsList: TFPList);
|
||||
var
|
||||
PkgList: TFPList; // list of TLazPackage
|
||||
FPMakeList: TFPList;
|
||||
begin
|
||||
PkgList:=nil;
|
||||
GetAllRequiredPackages(PkgList,false,[pirCompileOrder]);
|
||||
FPMakeList:=nil;
|
||||
GetAllRequiredPackages(PkgList,FPMakeList,false,[pirCompileOrder]);
|
||||
OptionsList:=GetUsageOptionsList(PkgList);
|
||||
PkgList.Free;
|
||||
FPMakeList.Free;
|
||||
end;
|
||||
|
||||
function TLazPackage.GetCompileSourceFilename: string;
|
||||
|
@ -61,8 +61,8 @@ uses
|
||||
// IDE
|
||||
LazarusIDEStrConsts, IDECmdLine, EnvironmentOpts, IDEProcs, LazConf,
|
||||
TransferMacros, DialogProcs, IDETranslations, CompilerOptions, PackageLinks,
|
||||
PackageDefs, ComponentReg;
|
||||
|
||||
PackageDefs, ComponentReg, ExtTools, FppkgHelper;
|
||||
|
||||
const
|
||||
MakefileCompileVersion = 2;
|
||||
// 2 : changed macro format from %() to $()
|
||||
@ -338,12 +338,18 @@ type
|
||||
function GetBrokenDependenciesWhenChangingPkgID(APackage: TLazPackage;
|
||||
const NewName: string; NewVersion: TPkgVersion): TFPList;
|
||||
procedure GetPackagesChangedOnDisk(out ListOfPackages: TStringList; IgnoreModifiedFlag: boolean = False); // returns list of new filename and TLazPackage
|
||||
procedure GetAllRequiredPackages(APackage: TLazPackage; // if not nil then ignore FirstDependency and do not add APackage to Result
|
||||
FirstDependency: TPkgDependency;
|
||||
out List, FPMakeList: TFPList;
|
||||
Flags: TPkgIntfRequiredFlags = [];
|
||||
MinPolicy: TPackageUpdatePolicy = low(TPackageUpdatePolicy)
|
||||
); overload; // for single search use FindDependencyRecursively
|
||||
procedure GetAllRequiredPackages(APackage: TLazPackage; // if not nil then ignore FirstDependency and do not add APackage to Result
|
||||
FirstDependency: TPkgDependency;
|
||||
out List: TFPList;
|
||||
Flags: TPkgIntfRequiredFlags = [];
|
||||
MinPolicy: TPackageUpdatePolicy = low(TPackageUpdatePolicy)
|
||||
); // for single search use FindDependencyRecursively
|
||||
); overload;
|
||||
procedure SortDependencyListTopologicallyOld(
|
||||
var FirstDependency: TPkgDependency; TopLevelFirst: boolean);
|
||||
procedure IterateAllComponentClasses(Event: TIterateComponentClassesEvent);
|
||||
@ -1474,7 +1480,7 @@ function TLazPackageGraph.FindDependencyRecursively(
|
||||
Result:=CurDependency;
|
||||
exit;
|
||||
end;
|
||||
if CurDependency.LoadPackageResult=lprSuccess then begin
|
||||
if (CurDependency.DependencyType=pdtLazarus) and (CurDependency.LoadPackageResult=lprSuccess) then begin
|
||||
RequiredPackage:=CurDependency.RequiredPackage;
|
||||
if (not (lpfVisited in RequiredPackage.Flags)) then begin
|
||||
RequiredPackage.Flags:=RequiredPackage.Flags+[lpfVisited];
|
||||
@ -1541,7 +1547,7 @@ function TLazPackageGraph.FindConflictRecursively(
|
||||
end;
|
||||
if CurDependency.LoadPackageResult=lprSuccess then begin
|
||||
RequiredPackage:=CurDependency.RequiredPackage;
|
||||
if (not (lpfVisited in RequiredPackage.Flags)) then begin
|
||||
if Assigned(RequiredPackage) and (not (lpfVisited in RequiredPackage.Flags)) then begin
|
||||
RequiredPackage.Flags:=RequiredPackage.Flags+[lpfVisited];
|
||||
Result:=Find(RequiredPackage.FirstRequiredDependency);
|
||||
if Result<>nil then exit;
|
||||
@ -2192,6 +2198,7 @@ procedure TLazPackageGraph.LoadStaticBasePackages;
|
||||
Dependency:=TPkgDependency.Create;
|
||||
Dependency.Owner:=Self;
|
||||
Dependency.PackageName:=PkgName;
|
||||
Dependency.DependencyType:=pdtLazarus;
|
||||
Dependency.AddToList(FirstAutoInstallDependency,pdlRequires);
|
||||
Quiet:=false;
|
||||
OpenInstalledDependency(Dependency,pitStatic,Quiet);
|
||||
@ -2230,6 +2237,7 @@ begin
|
||||
if Dependency<>nil then continue;
|
||||
Dependency:=TPkgDependency.Create;
|
||||
Dependency.Owner:=Self;
|
||||
Dependency.DependencyType:=pdtLazarus;
|
||||
Dependency.PackageName:=PackageName;
|
||||
Dependency.AddToList(FirstAutoInstallDependency,pdlRequires);
|
||||
if OpenDependency(Dependency,false)<>lprSuccess then begin
|
||||
@ -2422,15 +2430,17 @@ function TLazPackageGraph.FindBrokenDependencyPath(APackage: TLazPackage;
|
||||
while Dependency<>nil do begin
|
||||
if Dependency.LoadPackageResult=lprSuccess then begin
|
||||
// dependency ok
|
||||
RequiredPackage:=Dependency.RequiredPackage;
|
||||
if not (lpfVisited in RequiredPackage.Flags) then begin
|
||||
RequiredPackage.Flags:=RequiredPackage.Flags+[lpfVisited];
|
||||
FindBroken(RequiredPackage.FirstRequiredDependency,PathList);
|
||||
if PathList<>nil then begin
|
||||
// broken dependency found
|
||||
// -> add current package to list
|
||||
PathList.Insert(0,RequiredPackage);
|
||||
exit;
|
||||
if Dependency.DependencyType=pdtLazarus then begin
|
||||
RequiredPackage:=Dependency.RequiredPackage;
|
||||
if not (lpfVisited in RequiredPackage.Flags) then begin
|
||||
RequiredPackage.Flags:=RequiredPackage.Flags+[lpfVisited];
|
||||
FindBroken(RequiredPackage.FirstRequiredDependency,PathList);
|
||||
if PathList<>nil then begin
|
||||
// broken dependency found
|
||||
// -> add current package to list
|
||||
PathList.Insert(0,RequiredPackage);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end else begin
|
||||
@ -2467,10 +2477,12 @@ function TLazPackageGraph.FindAllBrokenDependencies(APackage: TLazPackage;
|
||||
while Dependency<>nil do begin
|
||||
if Dependency.LoadPackageResult=lprSuccess then begin
|
||||
// dependency ok
|
||||
RequiredPackage:=Dependency.RequiredPackage;
|
||||
if not (lpfVisited in RequiredPackage.Flags) then begin
|
||||
RequiredPackage.Flags:=RequiredPackage.Flags+[lpfVisited];
|
||||
FindBroken(RequiredPackage.FirstRequiredDependency,DepList);
|
||||
if Dependency.DependencyType=pdtLazarus then begin
|
||||
RequiredPackage:=Dependency.RequiredPackage;
|
||||
if not (lpfVisited in RequiredPackage.Flags) then begin
|
||||
RequiredPackage.Flags:=RequiredPackage.Flags+[lpfVisited];
|
||||
FindBroken(RequiredPackage.FirstRequiredDependency,DepList);
|
||||
end;
|
||||
end;
|
||||
end else begin
|
||||
// broken dependency found
|
||||
@ -2506,22 +2518,24 @@ function TLazPackageGraph.FindCycleDependencyPath(APackage: TLazPackage;
|
||||
if Dependency.LoadPackageResult=lprSuccess then begin
|
||||
// dependency ok
|
||||
RequiredPackage:=Dependency.RequiredPackage;
|
||||
if lpfCycle in RequiredPackage.Flags then begin
|
||||
// cycle detected
|
||||
PathList:=TFPList.Create;
|
||||
PathList.Add(RequiredPackage);
|
||||
exit;
|
||||
end;
|
||||
if not (lpfVisited in RequiredPackage.Flags) then begin
|
||||
RequiredPackage.Flags:=RequiredPackage.Flags+[lpfVisited,lpfCycle];
|
||||
FindCycle(RequiredPackage.FirstRequiredDependency,PathList);
|
||||
if PathList<>nil then begin
|
||||
if Dependency.DependencyType=pdtLazarus then begin
|
||||
if lpfCycle in RequiredPackage.Flags then begin
|
||||
// cycle detected
|
||||
// -> add current package to list
|
||||
PathList.Insert(0,RequiredPackage);
|
||||
PathList:=TFPList.Create;
|
||||
PathList.Add(RequiredPackage);
|
||||
exit;
|
||||
end;
|
||||
RequiredPackage.Flags:=RequiredPackage.Flags-[lpfCycle];
|
||||
if not (lpfVisited in RequiredPackage.Flags) then begin
|
||||
RequiredPackage.Flags:=RequiredPackage.Flags+[lpfVisited,lpfCycle];
|
||||
FindCycle(RequiredPackage.FirstRequiredDependency,PathList);
|
||||
if PathList<>nil then begin
|
||||
// cycle detected
|
||||
// -> add current package to list
|
||||
PathList.Insert(0,RequiredPackage);
|
||||
exit;
|
||||
end;
|
||||
RequiredPackage.Flags:=RequiredPackage.Flags-[lpfCycle];
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
Dependency:=Dependency.NextRequiresDependency;
|
||||
@ -2634,7 +2648,7 @@ var
|
||||
RequiredPackage: TLazPackage;
|
||||
begin
|
||||
while Dependency<>nil do begin
|
||||
if Dependency.LoadPackageResult=lprSuccess then begin
|
||||
if (Dependency.DependencyType=pdtLazarus) and (Dependency.LoadPackageResult=lprSuccess) then begin
|
||||
RequiredPackage:=Dependency.RequiredPackage;
|
||||
if not (lpfVisited in RequiredPackage.Flags) then begin
|
||||
if CheckPkg(RequiredPackage,PathList) then exit;
|
||||
@ -3365,7 +3379,10 @@ begin
|
||||
while Dependency<>nil do begin
|
||||
if (Dependency.LoadPackageResult=lprSuccess) then begin
|
||||
RequiredPackage:=Dependency.RequiredPackage;
|
||||
if SkipDesignTimePackages and (RequiredPackage.PackageType=lptDesignTime)
|
||||
if Dependency.DependencyType=pdtFPMake
|
||||
then begin
|
||||
// skip
|
||||
end else if SkipDesignTimePackages and (RequiredPackage.PackageType=lptDesignTime)
|
||||
then begin
|
||||
// skip
|
||||
end else begin
|
||||
@ -3824,6 +3841,7 @@ var
|
||||
|
||||
var
|
||||
PkgList: TFPList;
|
||||
FPMakeList: TFPList;
|
||||
i: Integer;
|
||||
Flags: TPkgCompileFlags;
|
||||
ReqFlags: TPkgIntfRequiredFlags;
|
||||
@ -3843,99 +3861,101 @@ begin
|
||||
ReqFlags:=[pirCompileOrder];
|
||||
if SkipDesignTimePackages then
|
||||
Include(ReqFlags,pirSkipDesignTimeOnly);
|
||||
GetAllRequiredPackages(APackage,FirstDependency,PkgList,ReqFlags,Policy);
|
||||
if PkgList<>nil then begin
|
||||
GetAllRequiredPackages(APackage,FirstDependency,PkgList,FPMakeList,ReqFlags,Policy);
|
||||
if (PkgList<>nil) or (FPMakeList<>nil) then begin
|
||||
//DebugLn('TLazPackageGraph.CompileRequiredPackages B Count=',IntToStr(PkgList.Count));
|
||||
BuildItems:=nil;
|
||||
ToolGroup:=nil;
|
||||
BeginUpdate(false);
|
||||
try
|
||||
for i:=PkgList.Count-1 downto 0 do begin
|
||||
CurPkg:=TLazPackage(PkgList[i]);
|
||||
if SkipDesignTimePackages and (CurPkg.PackageType=lptDesignTime) then
|
||||
PkgList.Delete(i);
|
||||
CurPkg.Flags:=CurPkg.Flags-[lpfNeedGroupCompile];
|
||||
end;
|
||||
if Assigned(OnBeforeCompilePackages) then
|
||||
begin
|
||||
Result:=OnBeforeCompilePackages(PkgList);
|
||||
if Result<>mrOk then exit;
|
||||
end;
|
||||
|
||||
// prepare output directories, basic checks
|
||||
Flags:=[pcfDoNotCompileDependencies,pcfDoNotSaveEditorFiles,pcfGroupCompile];
|
||||
if SkipDesignTimePackages then
|
||||
Include(Flags,pcfSkipDesignTimePackages);
|
||||
if Policy=pupAsNeeded then
|
||||
Include(Flags,pcfOnlyIfNeeded)
|
||||
else
|
||||
Include(Flags,pcfCleanCompile);
|
||||
repeat
|
||||
BuildItems:=TObjectList.Create(true);
|
||||
for i:=0 to PkgList.Count-1 do begin
|
||||
if (PkgList<>nil) then begin
|
||||
for i:=PkgList.Count-1 downto 0 do begin
|
||||
CurPkg:=TLazPackage(PkgList[i]);
|
||||
BuildItem:=TLazPkgGraphBuildItem.Create(nil);
|
||||
BuildItem.LazPackage:=CurPkg;
|
||||
BuildItems.Add(BuildItem);
|
||||
Result:=CompilePackage(CurPkg,Flags,false,BuildItem);
|
||||
if Result<>mrOk then exit;
|
||||
|
||||
if (BuildItem<>nil) and (not (lpfNeedGroupCompile in CurPkg.Flags))
|
||||
then begin
|
||||
// package is up-to-date
|
||||
//debugln(['TLazPackageGraph.CompileRequiredPackages no build needed: pkg=',CurPkg.Name]);
|
||||
BuildItems.Remove(BuildItem);
|
||||
end;
|
||||
if SkipDesignTimePackages and (CurPkg.PackageType=lptDesignTime) then
|
||||
PkgList.Delete(i);
|
||||
CurPkg.Flags:=CurPkg.Flags-[lpfNeedGroupCompile];
|
||||
end;
|
||||
|
||||
if FirstDependency<>nil then
|
||||
if Assigned(OnBeforeCompilePackages) then
|
||||
begin
|
||||
if not OnCheckInterPkgFiles(FirstDependency.Owner,PkgList,FilesChanged)
|
||||
then exit(mrCancel);
|
||||
if FilesChanged then
|
||||
FreeAndNil(BuildItems);
|
||||
Result:=OnBeforeCompilePackages(PkgList);
|
||||
if Result<>mrOk then exit;
|
||||
end;
|
||||
until BuildItems<>nil;
|
||||
|
||||
// add tool dependencies
|
||||
for i:=0 to BuildItems.Count-1 do begin
|
||||
BuildItem:=TLazPkgGraphBuildItem(BuildItems[i]);
|
||||
CurPkg:=BuildItem.LazPackage;
|
||||
if BuildItem.Count=0 then continue;
|
||||
// prepare output directories, basic checks
|
||||
Flags:=[pcfDoNotCompileDependencies,pcfDoNotSaveEditorFiles,pcfGroupCompile];
|
||||
if SkipDesignTimePackages then
|
||||
Include(Flags,pcfSkipDesignTimePackages);
|
||||
if Policy=pupAsNeeded then
|
||||
Include(Flags,pcfOnlyIfNeeded)
|
||||
else
|
||||
Include(Flags,pcfCleanCompile);
|
||||
repeat
|
||||
BuildItems:=TObjectList.Create(true);
|
||||
for i:=0 to PkgList.Count-1 do begin
|
||||
CurPkg:=TLazPackage(PkgList[i]);
|
||||
BuildItem:=TLazPkgGraphBuildItem.Create(nil);
|
||||
BuildItem.LazPackage:=CurPkg;
|
||||
BuildItems.Add(BuildItem);
|
||||
Result:=CompilePackage(CurPkg,Flags,false,BuildItem);
|
||||
if Result<>mrOk then exit;
|
||||
|
||||
// add tools to ToolGroup
|
||||
if ToolGroup=nil then
|
||||
ToolGroup:=TExternalToolGroup.Create(nil);
|
||||
for j:=0 to BuildItem.Count-1 do
|
||||
BuildItem[j].Group:=ToolGroup;
|
||||
|
||||
// estimate load
|
||||
for j:=0 to BuildItem.Count-1 do begin
|
||||
Tool1:=BuildItem[j];
|
||||
if Tool1.Data is TLazPkgGraphExtToolData then begin
|
||||
Tool1.EstimatedLoad:=EstimateCompileLoad(CurPkg);
|
||||
//debugln(['TLazPackageGraph.CompileRequiredPackages ',CurPkg.Name,' EstimatedLoad=',Tool1.EstimatedLoad]);
|
||||
if (BuildItem<>nil) and (not (lpfNeedGroupCompile in CurPkg.Flags))
|
||||
then begin
|
||||
// package is up-to-date
|
||||
//debugln(['TLazPackageGraph.CompileRequiredPackages no build needed: pkg=',CurPkg.Name]);
|
||||
BuildItems.Remove(BuildItem);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
// add dependencies between tools of this package (execute before, compile, after)
|
||||
for j:=1 to BuildItem.Count-1 do begin
|
||||
Tool1:=BuildItem[j-1];
|
||||
Tool2:=BuildItem[j];
|
||||
Tool2.AddExecuteBefore(Tool1);
|
||||
end;
|
||||
if FirstDependency<>nil then
|
||||
begin
|
||||
if not OnCheckInterPkgFiles(FirstDependency.Owner,PkgList,FilesChanged)
|
||||
then exit(mrCancel);
|
||||
if FilesChanged then
|
||||
FreeAndNil(BuildItems);
|
||||
end;
|
||||
until BuildItems<>nil;
|
||||
|
||||
// add dependencies between packages
|
||||
aDependency:=CurPkg.FirstRequiredDependency;
|
||||
while aDependency<>nil do begin
|
||||
RequiredBuildItem:=PkgToBuildItem(aDependency.RequiredPackage);
|
||||
aDependency:=aDependency.NextRequiresDependency;
|
||||
if RequiredBuildItem=nil then continue;
|
||||
if not (lpfNeedGroupCompile in RequiredBuildItem.LazPackage.Flags) then
|
||||
continue;
|
||||
Tool1:=BuildItem.GetFirstOrDummy;
|
||||
Tool2:=RequiredBuildItem.GetLastOrDummy;
|
||||
Tool1.AddExecuteBefore(Tool2);
|
||||
// add tool dependencies
|
||||
for i:=0 to BuildItems.Count-1 do begin
|
||||
BuildItem:=TLazPkgGraphBuildItem(BuildItems[i]);
|
||||
CurPkg:=BuildItem.LazPackage;
|
||||
if BuildItem.Count=0 then continue;
|
||||
|
||||
// add tools to ToolGroup
|
||||
if ToolGroup=nil then
|
||||
ToolGroup:=TExternalToolGroup.Create(nil);
|
||||
for j:=0 to BuildItem.Count-1 do
|
||||
BuildItem[j].Group:=ToolGroup;
|
||||
|
||||
// estimate load
|
||||
for j:=0 to BuildItem.Count-1 do begin
|
||||
Tool1:=BuildItem[j];
|
||||
if Tool1.Data is TLazPkgGraphExtToolData then begin
|
||||
Tool1.EstimatedLoad:=EstimateCompileLoad(CurPkg);
|
||||
//debugln(['TLazPackageGraph.CompileRequiredPackages ',CurPkg.Name,' EstimatedLoad=',Tool1.EstimatedLoad]);
|
||||
end;
|
||||
end;
|
||||
|
||||
// add dependencies between tools of this package (execute before, compile, after)
|
||||
for j:=1 to BuildItem.Count-1 do begin
|
||||
Tool1:=BuildItem[j-1];
|
||||
Tool2:=BuildItem[j];
|
||||
Tool2.AddExecuteBefore(Tool1);
|
||||
end;
|
||||
|
||||
// add dependencies between packages
|
||||
aDependency:=CurPkg.FirstRequiredDependency;
|
||||
while aDependency<>nil do begin
|
||||
RequiredBuildItem:=PkgToBuildItem(aDependency.RequiredPackage);
|
||||
aDependency:=aDependency.NextRequiresDependency;
|
||||
if RequiredBuildItem=nil then continue;
|
||||
if not (lpfNeedGroupCompile in RequiredBuildItem.LazPackage.Flags) then
|
||||
continue;
|
||||
Tool1:=BuildItem.GetFirstOrDummy;
|
||||
Tool2:=RequiredBuildItem.GetLastOrDummy;
|
||||
Tool1.AddExecuteBefore(Tool2);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -3952,6 +3972,7 @@ begin
|
||||
FreeAndNil(ToolGroup);
|
||||
FreeAndNil(BuildItems);
|
||||
FreeAndNil(PkgList);
|
||||
FreeAndNil(FPMakeList);
|
||||
EndUpdate;
|
||||
end;
|
||||
end;
|
||||
@ -5306,7 +5327,7 @@ var
|
||||
begin
|
||||
GetAllRequiredPackages(nil,FirstDependency,List);
|
||||
List.Free;
|
||||
|
||||
|
||||
// Bucket sort dependencies
|
||||
MaxLvl:=0;
|
||||
Dependency:=FirstDependency;
|
||||
@ -5493,6 +5514,7 @@ var
|
||||
NewDependency: TPkgDependency;
|
||||
begin
|
||||
NewDependency:=TPkgDependency.Create;
|
||||
NewDependency.DependencyType:=pdtLazarus;
|
||||
NewDependency.PackageName:=RequiredPackage.Name;
|
||||
AddDependencyToPackage(APackage,NewDependency);
|
||||
end;
|
||||
@ -5588,65 +5610,73 @@ begin
|
||||
APackage:=FindPackageWithName(Dependency.PackageName,nil);
|
||||
if APackage=nil then begin
|
||||
// no package with same name open
|
||||
// -> try package links
|
||||
IgnoreFiles:=nil;
|
||||
try
|
||||
repeat
|
||||
PkgLink:=LazPackageLinks.FindLinkWithDependencyWithIgnore(Dependency,IgnoreFiles);
|
||||
if (PkgLink=nil) then break;
|
||||
//debugln(['TLazPackageGraph.OpenDependency PkgLink=',PkgLink.GetEffectiveFilename,' global=',PkgLink.Origin=ploGlobal]);
|
||||
PkgLink.Reference;
|
||||
try
|
||||
MsgResult:=OpenDependencyWithPackageLink(Dependency,PkgLink,ShowAbort);
|
||||
if MsgResult=mrOk then break;
|
||||
if IgnoreFiles=nil then
|
||||
IgnoreFiles:=TFilenameToStringTree.Create(false);
|
||||
IgnoreFiles[PkgLink.GetEffectiveFilename]:='1';
|
||||
LazPackageLinks.RemoveUserLink(PkgLink);
|
||||
finally
|
||||
PkgLink.Release;
|
||||
end;
|
||||
until MsgResult=mrAbort;
|
||||
finally
|
||||
IgnoreFiles.Free;
|
||||
end;
|
||||
// try defaultfilename
|
||||
if (Dependency.LoadPackageResult=lprNotFound)
|
||||
and (Dependency.DefaultFilename<>'') then begin
|
||||
AFilename:=Dependency.FindDefaultFilename;
|
||||
if AFilename<>'' then begin
|
||||
if pvPkgSearch in Verbosity then
|
||||
debugln(['Info: (lazarus) Open dependency ['+Dependency.PackageName+']: trying resolved default filename: "'+PreferredFilename+'" ...']);
|
||||
OpenFile(AFilename);
|
||||
if Dependency.DependencyType=pdtLazarus then begin
|
||||
// -> try package links
|
||||
IgnoreFiles:=nil;
|
||||
try
|
||||
repeat
|
||||
PkgLink:=LazPackageLinks.FindLinkWithDependencyWithIgnore(Dependency,IgnoreFiles);
|
||||
if (PkgLink=nil) then break;
|
||||
//debugln(['TLazPackageGraph.OpenDependency PkgLink=',PkgLink.GetEffectiveFilename,' global=',PkgLink.Origin=ploGlobal]);
|
||||
PkgLink.Reference;
|
||||
try
|
||||
MsgResult:=OpenDependencyWithPackageLink(Dependency,PkgLink,ShowAbort);
|
||||
if MsgResult=mrOk then break;
|
||||
if IgnoreFiles=nil then
|
||||
IgnoreFiles:=TFilenameToStringTree.Create(false);
|
||||
IgnoreFiles[PkgLink.GetEffectiveFilename]:='1';
|
||||
LazPackageLinks.RemoveUserLink(PkgLink);
|
||||
finally
|
||||
PkgLink.Release;
|
||||
end;
|
||||
until MsgResult=mrAbort;
|
||||
finally
|
||||
IgnoreFiles.Free;
|
||||
end;
|
||||
end;
|
||||
// try in owner directory (some projects put all their packages into
|
||||
// one directory)
|
||||
if Dependency.LoadPackageResult=lprNotFound then begin
|
||||
CurDir:=GetDependencyOwnerDirectory(Dependency);
|
||||
if (CurDir<>'') then begin
|
||||
if pvPkgSearch in Verbosity then
|
||||
debugln(['Info: (lazarus) Open dependency ['+Dependency.PackageName+']: trying in owner directory "'+AppendPathDelim(CurDir)+'" ...']);
|
||||
AFilename:=CodeToolBoss.DirectoryCachePool.FindDiskFilename(
|
||||
AppendPathDelim(CurDir)+Dependency.PackageName+'.lpk');
|
||||
if FileExistsCached(AFilename) then begin
|
||||
// try defaultfilename
|
||||
if (Dependency.LoadPackageResult=lprNotFound)
|
||||
and (Dependency.DefaultFilename<>'') then begin
|
||||
AFilename:=Dependency.FindDefaultFilename;
|
||||
if AFilename<>'' then begin
|
||||
if pvPkgSearch in Verbosity then
|
||||
debugln(['Info: (lazarus) Open dependency ['+Dependency.PackageName+']: trying resolved default filename: "'+PreferredFilename+'" ...']);
|
||||
OpenFile(AFilename);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
// try a package that provides this package
|
||||
if Dependency.LoadPackageResult=lprNotFound then begin
|
||||
for i:=0 to Count-1 do begin
|
||||
APackage:=Packages[i];
|
||||
if APackage=Dependency.Owner then continue;
|
||||
if APackage.ProvidesPackage(Dependency.PackageName) then begin
|
||||
Dependency.RequiredPackage:=APackage;
|
||||
Dependency.LoadPackageResult:=lprSuccess;
|
||||
// try in owner directory (some projects put all their packages into
|
||||
// one directory)
|
||||
if Dependency.LoadPackageResult=lprNotFound then begin
|
||||
CurDir:=GetDependencyOwnerDirectory(Dependency);
|
||||
if (CurDir<>'') then begin
|
||||
if pvPkgSearch in Verbosity then
|
||||
debugln(['Info: (lazarus) Open dependency ['+Dependency.PackageName+']: Success. Package "'+APackage.IDAsString+'" provides '+Dependency.AsString]);
|
||||
break;
|
||||
debugln(['Info: (lazarus) Open dependency ['+Dependency.PackageName+']: trying in owner directory "'+AppendPathDelim(CurDir)+'" ...']);
|
||||
AFilename:=CodeToolBoss.DirectoryCachePool.FindDiskFilename(
|
||||
AppendPathDelim(CurDir)+Dependency.PackageName+'.lpk');
|
||||
if FileExistsCached(AFilename) then begin
|
||||
OpenFile(AFilename);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
// try a package that provides this package
|
||||
if Dependency.LoadPackageResult=lprNotFound then begin
|
||||
for i:=0 to Count-1 do begin
|
||||
APackage:=Packages[i];
|
||||
if APackage=Dependency.Owner then continue;
|
||||
if APackage.ProvidesPackage(Dependency.PackageName) then begin
|
||||
Dependency.RequiredPackage:=APackage;
|
||||
Dependency.LoadPackageResult:=lprSuccess;
|
||||
if pvPkgSearch in Verbosity then
|
||||
debugln(['Info: (lazarus) Open dependency ['+Dependency.PackageName+']: Success. Package "'+APackage.IDAsString+'" provides '+Dependency.AsString]);
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end else begin
|
||||
// FPMake-dependency
|
||||
if TFppkgHelper.Instance.HasPackage(Dependency.PackageName) then
|
||||
Dependency.LoadPackageResult:=lprSuccess
|
||||
else
|
||||
Dependency.LoadPackageResult:=lprNotFound;
|
||||
end;
|
||||
end else begin
|
||||
// there is already a package with this name, but wrong version open
|
||||
@ -5966,7 +5996,7 @@ begin
|
||||
end;
|
||||
|
||||
procedure TLazPackageGraph.GetAllRequiredPackages(APackage: TLazPackage;
|
||||
FirstDependency: TPkgDependency; out List: TFPList;
|
||||
FirstDependency: TPkgDependency; out List, FPMakeList: TFPList;
|
||||
Flags: TPkgIntfRequiredFlags; MinPolicy: TPackageUpdatePolicy);
|
||||
// returns packages in topological order, beginning with the top level package
|
||||
|
||||
@ -5984,28 +6014,35 @@ procedure TLazPackageGraph.GetAllRequiredPackages(APackage: TLazPackage;
|
||||
//debugln('TLazPackageGraph.GetAllRequiredPackages A ',Dependency.AsString,' ',dbgs(ord(Dependency.LoadPackageResult)),' ',dbgs(ord(lprSuccess)));
|
||||
if Dependency.LoadPackageResult<>lprSuccess then continue;
|
||||
//debugln('TLazPackageGraph.GetAllRequiredPackages B ',Dependency.AsString);
|
||||
RequiredPackage:=Dependency.RequiredPackage;
|
||||
if (lpfVisited in RequiredPackage.Flags) then begin
|
||||
// already visited
|
||||
if HighestLevel<RequiredPackage.TopologicalLevel then
|
||||
HighestLevel:=RequiredPackage.TopologicalLevel;
|
||||
continue;
|
||||
end;
|
||||
RequiredPackage.Flags:=RequiredPackage.Flags+[lpfVisited];
|
||||
if ord(RequiredPackage.AutoUpdate)<ord(MinPolicy) then
|
||||
continue; // skip manually updated packages
|
||||
if (pirSkipDesignTimeOnly in Flags)
|
||||
and (RequiredPackage.PackageType=lptDesignTime) then
|
||||
continue; // skip designtime (only) packages
|
||||
if not (pirNotRecursive in Flags) then begin
|
||||
GetTopologicalOrder(RequiredPackage.FirstRequiredDependency,DepLevel);
|
||||
RequiredPackage.TopologicalLevel:=DepLevel+1;
|
||||
if HighestLevel<RequiredPackage.TopologicalLevel then
|
||||
HighestLevel:=RequiredPackage.TopologicalLevel;
|
||||
if Dependency.DependencyType=pdtLazarus then begin
|
||||
RequiredPackage:=Dependency.RequiredPackage;
|
||||
if (lpfVisited in RequiredPackage.Flags) then begin
|
||||
// already visited
|
||||
if HighestLevel<RequiredPackage.TopologicalLevel then
|
||||
HighestLevel:=RequiredPackage.TopologicalLevel;
|
||||
continue;
|
||||
end;
|
||||
RequiredPackage.Flags:=RequiredPackage.Flags+[lpfVisited];
|
||||
if ord(RequiredPackage.AutoUpdate)<ord(MinPolicy) then
|
||||
continue; // skip manually updated packages
|
||||
if (pirSkipDesignTimeOnly in Flags)
|
||||
and (RequiredPackage.PackageType=lptDesignTime) then
|
||||
continue; // skip designtime (only) packages
|
||||
if not (pirNotRecursive in Flags) then begin
|
||||
GetTopologicalOrder(RequiredPackage.FirstRequiredDependency,DepLevel);
|
||||
RequiredPackage.TopologicalLevel:=DepLevel+1;
|
||||
if HighestLevel<RequiredPackage.TopologicalLevel then
|
||||
HighestLevel:=RequiredPackage.TopologicalLevel;
|
||||
end;
|
||||
if List=nil then List:=TFPList.Create;
|
||||
List.Add(RequiredPackage);
|
||||
end else begin
|
||||
// FPMake dependency
|
||||
// ToDo: Handle package-dependencies (or not?) and version-checks
|
||||
if FPMakeList=nil then FPMakeList := TFPList.Create;
|
||||
FPMakeList.Add(Dependency);
|
||||
end;
|
||||
// add package behind its requirements
|
||||
if List=nil then List:=TFPList.Create;
|
||||
List.Add(RequiredPackage);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -6015,6 +6052,7 @@ var
|
||||
DepLevel: integer;
|
||||
begin
|
||||
List:=nil;
|
||||
FPMakeList:=nil;
|
||||
MarkAllPackagesAsNotVisited;
|
||||
if APackage<>nil then begin
|
||||
FirstDependency:=APackage.FirstRequiredDependency;
|
||||
@ -6038,6 +6076,20 @@ begin
|
||||
// debugln(['TLazPackageGraph.GetAllRequiredPackages ',i,'/',List.Count-1,' ',TLazPackage(List[i]).Name,' ',TLazPackage(List[i]).TopologicalLevel]);
|
||||
end;
|
||||
|
||||
procedure TLazPackageGraph.GetAllRequiredPackages(APackage: TLazPackage;
|
||||
FirstDependency: TPkgDependency; out List: TFPList;
|
||||
Flags: TPkgIntfRequiredFlags; MinPolicy: TPackageUpdatePolicy);
|
||||
var
|
||||
FPMakeList: TFPList;
|
||||
begin
|
||||
FPMakeList := nil;
|
||||
try
|
||||
GetAllRequiredPackages(APackage, FirstDependency, List, FPMakeList, Flags, MinPolicy);
|
||||
finally
|
||||
FPMakeList.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLazPackageGraph.GetConnectionsTree(FirstDependency: TPkgDependency;
|
||||
var PkgList: TFPList; var Tree: TPkgPairTree);
|
||||
|
||||
|
@ -641,6 +641,7 @@ begin
|
||||
NewDependency:=TPkgDependency.Create;
|
||||
try
|
||||
NewDependency.PackageName:=APackageName;
|
||||
NewDependency.DependencyType:=pdtLazarus;
|
||||
LoadResult:=PackageGraph.OpenDependency(NewDependency,false);
|
||||
if LoadResult<>lprSuccess then exit;
|
||||
finally
|
||||
@ -1592,6 +1593,7 @@ begin
|
||||
//DebugLn('TPkgManager.LoadInstalledPackage PackageName="',PackageName,'" Quiet=',Quiet);
|
||||
NewDependency:=TPkgDependency.Create;
|
||||
NewDependency.Owner:=Self;
|
||||
NewDependency.DependencyType:=pdtLazarus;
|
||||
NewDependency.PackageName:=PackageName;
|
||||
PackageGraph.OpenInstalledDependency(NewDependency,pitStatic,Quiet);
|
||||
Result:=NewDependency.RequiredPackage;
|
||||
@ -5351,6 +5353,7 @@ end;
|
||||
function TPkgManager.DoInstallPackage(APackage: TLazPackage): TModalResult;
|
||||
var
|
||||
PkgList: TFPList;
|
||||
FPMakeList: TFPList;
|
||||
|
||||
function GetPkgListIndex(APackage: TLazPackage): integer;
|
||||
begin
|
||||
@ -5432,6 +5435,7 @@ begin
|
||||
|
||||
PackageGraph.BeginUpdate(true);
|
||||
PkgList:=nil;
|
||||
FPMakeList:=nil;
|
||||
try
|
||||
|
||||
// check if package is designtime package
|
||||
@ -5470,7 +5474,7 @@ begin
|
||||
if Result<>mrOk then exit;
|
||||
|
||||
// get all required packages, which will also be auto installed
|
||||
APackage.GetAllRequiredPackages(PkgList,false);
|
||||
APackage.GetAllRequiredPackages(PkgList,FPMakeList,false);
|
||||
if PkgList=nil then PkgList:=TFPList.Create;
|
||||
|
||||
// remove packages already marked for installation
|
||||
@ -5526,6 +5530,7 @@ begin
|
||||
finally
|
||||
PackageGraph.EndUpdate;
|
||||
PkgList.Free;
|
||||
FPMakeList.Free;
|
||||
end;
|
||||
|
||||
if NeedSaving then begin
|
||||
|
Loading…
Reference in New Issue
Block a user