mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 20:47:58 +02:00
Packager: When opening a project, automatically resolve broken package dependency if the package is available online and opkman is installed.
git-svn-id: trunk@56690 -
This commit is contained in:
parent
e014476d9e
commit
687b78901e
@ -107,9 +107,8 @@ type
|
||||
|
||||
TOPMInterface = class
|
||||
public
|
||||
{confirmation/install/extract/download dialogs will be displayed in the center of ParentForm}
|
||||
function InstallPackages(APkgLinks: TList; AParentForm: TForm;
|
||||
var ANeedToRebuild: Boolean): TModalResult; virtual; abstract;
|
||||
{confirmation/install/extract/download dialogs will be displayed in the center of WorkArea}
|
||||
function InstallPackages(APkgLinks: TList; var ANeedToRebuild: Boolean): TModalResult; virtual; abstract;
|
||||
end;
|
||||
|
||||
var
|
||||
|
@ -4297,6 +4297,9 @@ resourcestring
|
||||
lisPkgMangTheFollowingPackageFailedToLoad = 'The following package failed to load:';
|
||||
lisPkgMangTheFollowingPackagesFailedToLoad = 'The following packages failed to load:';
|
||||
lisMissingPackages = 'Missing Packages';
|
||||
lisInstallPackages = 'Install Packages';
|
||||
lisInstallPackagesMsg = 'The following package(s) are not installed, but available in the main repository: %s.' +
|
||||
sLineBreak + 'Do you wish to install missing packages?';
|
||||
lisOtherSourcesPathOfPackageContainsDirectoryWhichIsA = 'other sources path '
|
||||
+'of package "%s" contains directory "%s", which is already in the unit '
|
||||
+'search path.';
|
||||
|
@ -232,6 +232,7 @@ var
|
||||
PackageLink: TPackageLink;
|
||||
PkgList: TList;
|
||||
begin
|
||||
ANeedToRebuild := False;
|
||||
Result := mrOk;
|
||||
PkgList := TList.Create;
|
||||
try
|
||||
@ -245,7 +246,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
if PkgList.Count > 0 then
|
||||
Result := OPMInterface.InstallPackages(PkgList, Self, ANeedToRebuild);
|
||||
Result := OPMInterface.InstallPackages(PkgList, ANeedToRebuild);
|
||||
finally
|
||||
PkgList.Free;
|
||||
PkgList := nil;
|
||||
|
@ -204,6 +204,8 @@ type
|
||||
function MoveFiles(TargetFilesEdit, SrcFilesEdit: IFilesEditorInterface;
|
||||
IDEFiles: TFPList; TargetDirectory: string): boolean;
|
||||
function CopyMoveFiles(Sender: TObject): boolean;
|
||||
function ResolveBrokenDependenciesOnline(ABrokenDependencies: TFPList;
|
||||
var ANeedToRebuild: Boolean): TModalResult;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
@ -3306,22 +3308,67 @@ begin
|
||||
Result:=mrOk;
|
||||
end;
|
||||
|
||||
function TPkgManager.ResolveBrokenDependenciesOnline(ABrokenDependencies: TFPList;
|
||||
var ANeedToRebuild: Boolean): TModalResult;
|
||||
var
|
||||
Dependency: TPkgDependency;
|
||||
I: Integer;
|
||||
PkgLinks: TList;
|
||||
PkgLinksStr: String;
|
||||
PackageLink: TPackageLink;
|
||||
begin
|
||||
Result := mrCancel;
|
||||
PkgLinks := TList.Create;
|
||||
try
|
||||
PkgLinksStr := '';
|
||||
for I := 0 to ABrokenDependencies.Count - 1 do begin
|
||||
Dependency := TPkgDependency(ABrokenDependencies[i]);
|
||||
PackageLink := LazPackageLinks.FindLinkWithPkgName(Dependency.AsString);
|
||||
if (PackageLink <> nil) and (PackageLink.Origin = ploOnline) then begin
|
||||
if PkgLinksStr = '' then
|
||||
PkgLinksStr := '"' + PackageLink.Name + '"'
|
||||
else
|
||||
PkgLinksStr := PkgLinksStr + ', ' + '"' + PackageLink.Name + '"';
|
||||
PkgLinks.Add(PackageLink);
|
||||
end;
|
||||
end;
|
||||
if PkgLinks.Count > 0 then begin
|
||||
if IDEMessageDialog(lisInstallPackages, Format(lisInstallPackagesMsg, [PkgLinksStr]), mtConfirmation, [mbYes, mbNo]) = mrYes then
|
||||
Result := OPMInterface.InstallPackages(PkgLinks, ANeedToRebuild);
|
||||
end;
|
||||
finally
|
||||
PkgLinks.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TPkgManager.OpenProjectDependencies(AProject: TProject;
|
||||
ReportMissing: boolean): TModalResult;
|
||||
var
|
||||
BrokenDependencies: TFPList;
|
||||
NeedToRebuild: Boolean;
|
||||
begin
|
||||
NeedToRebuild := False;
|
||||
Result:=mrOk;
|
||||
PackageGraph.OpenRequiredDependencyList(AProject.FirstRequiredDependency);
|
||||
if ReportMissing then begin
|
||||
BrokenDependencies:=PackageGraph.FindAllBrokenDependencies(nil,
|
||||
AProject.FirstRequiredDependency);
|
||||
if BrokenDependencies<>nil then begin
|
||||
Result:=ShowBrokenDependenciesReport(BrokenDependencies);
|
||||
if OPMInterface <> nil then begin
|
||||
ResolveBrokenDependenciesOnline(BrokenDependencies, NeedToRebuild);
|
||||
BrokenDependencies := PackageGraph.FindAllBrokenDependencies(nil, AProject.FirstRequiredDependency);
|
||||
if BrokenDependencies <> nil then
|
||||
Result := ShowBrokenDependenciesReport(BrokenDependencies);
|
||||
end
|
||||
else
|
||||
Result:=ShowBrokenDependenciesReport(BrokenDependencies);
|
||||
BrokenDependencies.Free;
|
||||
end;
|
||||
end;
|
||||
LazPackageLinks.SaveUserLinks;
|
||||
|
||||
if (OPMInterface <> nil) and (NeedToRebuild) then
|
||||
MainIDEInterface.DoBuildLazarus([])
|
||||
end;
|
||||
|
||||
function TPkgManager.AddProjectDependency(AProject: TProject;
|
||||
|
Loading…
Reference in New Issue
Block a user