IDE: added package type runtime only

git-svn-id: trunk@34645 -
This commit is contained in:
mattias 2012-01-07 19:33:50 +00:00
parent 258078f4d0
commit a20722e7dc
9 changed files with 194 additions and 67 deletions

View File

@ -1896,6 +1896,7 @@
<UnitName Value="WatchPropertyDlg"/>
</Item421>
</Files>
<Type Value="RunTimeOnly"/>
<RequiredPkgs Count="6">
<Item1>
<PackageName Value="LCL"/>

View File

@ -3027,6 +3027,18 @@ resourcestring
lisUnableToRead = 'Unable to read %s';
lisErrorReadingPackageListFromFile = 'Error reading package list from file%'
+'s%s%s%s';
lisDuplicate = 'Duplicate';
lisThePackageIsAlreadyInTheList = 'The package %s is already in the list';
lisConflict = 'Conflict';
lisThereIsAlreadyAPackageInTheList = 'There is already a package %s in the '
+'list';
lisNotADesigntimePackage = 'Not a designtime package';
lisThePackageCanNotBeInstalledBecauseItRequiresWhichI = 'The package %s can '
+'not be installed, because it requires the package "%s", which is a runtime only '
+'package.';
lisUninstall = 'Uninstall %s';
lisThePackageIsNotADesignTimePackageItCanNotBeInstall = 'The package %s is '
+'not a design time package. It can not be installed in the IDE';
lisUninstallImpossible = 'Uninstall impossible';
lisThePackageCanNotBeUninstalledBecauseItIsNeededByTh = 'The package %s can '
+'not be uninstalled, because it is needed by the IDE itself.';
@ -4105,9 +4117,11 @@ resourcestring
lisBuildNumber = 'Build number';
lisPckOptsAutomaticallyIncrementVersionOnBuild = 'Automatically increment version on build';
lisPckOptsPackageType = 'Package type';
lisPckOptsDesigntimeOnly = 'Designtime only';
lisPckOptsRuntimeOnly = 'Runtime only';
lisPckOptsDesigntime = 'Designtime';
lisPckOptsRuntime = 'Runtime';
lisPckOptsDesigntimeAndRuntime = 'Designtime and runtime';
lisRuntimeOnlyCanNotBeInstalledInIDE = 'Runtime only, can not be installed '
+'in IDE';
lisPckOptsUpdateRebuild = 'Update / Rebuild';
lisPckOptsAutomaticallyRebuildAsNeeded = 'Automatically rebuild as needed';
lisPckOptsAutoRebuildWhenRebuildingAll = 'Auto rebuild when rebuilding all';

View File

@ -12,11 +12,12 @@ inherited PackageIntegrationOptionsFrame: TPackageIntegrationOptionsFrame
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 116
Height = 124
Top = 0
Width = 461
Anchors = [akTop, akLeft, akRight]
AutoFill = True
AutoSize = True
Caption = 'PackageType'
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
@ -26,13 +27,14 @@ inherited PackageIntegrationOptionsFrame: TPackageIntegrationOptionsFrame
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 98
ClientHeight = 108
ClientWidth = 457
ItemIndex = 2
Items.Strings = (
'Designtime only'
'Runtime only'
'Designtime'
'Runtime'
'Designtime and Runtime'
'Runtime only, can not be installed in IDE'
)
OnClick = PkgTypeRadioGroupClick
TabOrder = 0
@ -44,11 +46,12 @@ inherited PackageIntegrationOptionsFrame: TPackageIntegrationOptionsFrame
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 116
Top = 122
Height = 100
Top = 130
Width = 461
Anchors = [akTop, akLeft, akRight]
AutoFill = True
AutoSize = True
BorderSpacing.Top = 6
Caption = 'Update/Rebuild'
ChildSizing.LeftRightSpacing = 6
@ -59,7 +62,7 @@ inherited PackageIntegrationOptionsFrame: TPackageIntegrationOptionsFrame
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 98
ClientHeight = 84
ClientWidth = 457
ItemIndex = 0
Items.Strings = (
@ -76,21 +79,21 @@ inherited PackageIntegrationOptionsFrame: TPackageIntegrationOptionsFrame
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 53
Top = 244
Height = 52
Top = 236
Width = 461
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 6
Caption = 'LazDoc - Lazarus documentation'
ClientHeight = 35
ClientHeight = 36
ClientWidth = 457
TabOrder = 2
object LazDocPathEdit: TEdit
AnchorSideLeft.Control = LazDocGroupBox
AnchorSideTop.Control = LazDocGroupBox
Left = 6
Height = 23
Height = 24
Top = 6
Width = 365
Anchors = [akTop, akLeft, akRight]

View File

@ -33,6 +33,8 @@ type
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
function PkgTypeToCaption(t: TLazPackageType): string;
function CaptionToPkgType(s: string): TLazPackageType;
end;
implementation
@ -42,10 +44,14 @@ implementation
{ TPackageIntegrationOptionsFrame }
procedure TPackageIntegrationOptionsFrame.PkgTypeRadioGroupClick(Sender: TObject);
var
NewPkgType: TLazPackageType;
begin
if (PkgTypeRadioGroup.ItemIndex = 1) and (FLazPackage.PackageType <> lptRunTime) then
begin
// user sets to runtime only
NewPkgType:=CaptionToPkgType(PkgTypeRadioGroup.Items[PkgTypeRadioGroup.ItemIndex]);
if (FStoredPkgType<>PkgTypeRadioGroup.ItemIndex)
and (NewPkgType in [lptRunTime,lptRunTimeOnly])
then begin
// user sets to runtime
if (FLazPackage.AutoInstall <> pitNope) then
ShowMsgPackageTypeMustBeDesign;
end;
@ -118,9 +124,10 @@ end;
procedure TPackageIntegrationOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
begin
PkgTypeRadioGroup.Caption := lisPckOptsPackageType;
PkgTypeRadioGroup.Items[0] := lisPckOptsDesigntimeOnly;
PkgTypeRadioGroup.Items[1] := lisPckOptsRuntimeOnly;
PkgTypeRadioGroup.Items[2] := lisPckOptsDesigntimeAndRuntime;
PkgTypeRadioGroup.Items[0] := PkgTypeToCaption(lptRunAndDesignTime);
PkgTypeRadioGroup.Items[1] := PkgTypeToCaption(lptDesignTime);
PkgTypeRadioGroup.Items[2] := PkgTypeToCaption(lptRunTime);
PkgTypeRadioGroup.Items[3] := PkgTypeToCaption(lptRunTimeOnly);
UpdateRadioGroup.Caption := lisPckOptsUpdateRebuild;
UpdateRadioGroup.Items[0] := lisPckOptsAutomaticallyRebuildAsNeeded;
UpdateRadioGroup.Items[1] := lisPckOptsAutoRebuildWhenRebuildingAll;
@ -147,14 +154,12 @@ end;
procedure TPackageIntegrationOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
var
LazPackage: TLazPackage absolute AOptions;
i: Integer;
begin
FLazPackage := LazPackage;
case LazPackage.PackageType of
lptDesignTime: PkgTypeRadioGroup.ItemIndex := 0;
lptRunTime: PkgTypeRadioGroup.ItemIndex := 1;
else
PkgTypeRadioGroup.ItemIndex := 2;
end;
for i:=0 to PkgTypeRadioGroup.Items.Count-1 do
if PkgTypeRadioGroup.Items[i]=PkgTypeToCaption(LazPackage.PackageType) then
PkgTypeRadioGroup.ItemIndex:=i;
FStoredPkgType := PkgTypeRadioGroup.ItemIndex;
case LazPackage.AutoUpdate of
pupAsNeeded: UpdateRadioGroup.ItemIndex := 0;
@ -181,17 +186,13 @@ end;
function TPackageIntegrationOptionsFrame.Check: Boolean;
var
NewPackageType: TLazPackageType;
NewPkgType: TLazPackageType;
begin
case PkgTypeRadioGroup.ItemIndex of
0: NewPackageType := lptDesignTime;
1: NewPackageType := lptRunTime;
else
NewPackageType := lptRunAndDesignTime;
end;
if NewPackageType <> FLazPackage.PackageType then
NewPkgType:=CaptionToPkgType(PkgTypeRadioGroup.Items[PkgTypeRadioGroup.ItemIndex]);
if NewPkgType <> FLazPackage.PackageType then
begin
if (NewPackageType = lptRunTime) and (FLazPackage.AutoInstall <> pitNope) then
if (NewPkgType in [lptRunTime,lptRunTimeOnly])
and (FLazPackage.AutoInstall <> pitNope) then
begin
if ShowMsgPackageTypeMustBeDesign then
Exit(False);
@ -203,22 +204,16 @@ end;
procedure TPackageIntegrationOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
var
LazPackage: TLazPackage absolute AOptions;
NewPackageType: TLazPackageType;
NewPkgType: TLazPackageType;
begin
case PkgTypeRadioGroup.ItemIndex of
0: NewPackageType := lptDesignTime;
1: NewPackageType := lptRunTime;
else
NewPackageType := lptRunAndDesignTime;
end;
LazPackage.PackageType := NewPackageType;
NewPkgType:=CaptionToPkgType(PkgTypeRadioGroup.Items[PkgTypeRadioGroup.ItemIndex]);
LazPackage.PackageType := NewPkgType;
case UpdateRadioGroup.ItemIndex of
2: LazPackage.AutoUpdate := pupManually;
1: LazPackage.AutoUpdate := pupOnRebuildingAll;
else
LazPackage.AutoUpdate := pupAsNeeded;
end;
LazPackage.LazDocPaths := LazDocPathEdit.Text;
end;
@ -227,6 +222,28 @@ begin
Result := TLazPackage;
end;
function TPackageIntegrationOptionsFrame.PkgTypeToCaption(t: TLazPackageType
): string;
begin
case t of
lptRunTime: Result:=lisPckOptsRuntime;
lptDesignTime: Result:=lisPckOptsDesigntime;
lptRunAndDesignTime: Result:=lisPckOptsDesigntimeAndRuntime;
lptRunTimeOnly: Result:=lisRuntimeOnlyCanNotBeInstalledInIDE;
else Result:='?'+IntToStr(ord(t));
end;
end;
function TPackageIntegrationOptionsFrame.CaptionToPkgType(s: string
): TLazPackageType;
var
t: TLazPackageType;
begin
for t:=Low(TLazPackageType) to high(TLazPackageType) do
if s=PkgTypeToCaption(t) then exit(t);
Result:=lptRunTime;
end;
initialization
RegisterIDEOptionsEditor(GroupPackage, TPackageIntegrationOptionsFrame,
PackageOptionsIntegration);

View File

@ -41,8 +41,8 @@ uses
Classes, SysUtils, contnrs, LCLProc, Forms, Controls, Graphics, Dialogs,
KeywordFuncLists, StdCtrls, Buttons, FileUtil, ExtCtrls, ComCtrls, EditBtn,
AVL_Tree, Laz_XMLCfg, TreeFilterEdit, PackageIntf, IDEImagesIntf, IDEHelpIntf,
LazarusIDEStrConsts, EnvironmentOpts, InputHistory, LazConf, IDEProcs,
PackageDefs, PackageSystem, PackageLinks, IDEContextHelpEdit;
IDEDialogs, LazarusIDEStrConsts, EnvironmentOpts, InputHistory, LazConf,
IDEProcs, PackageDefs, PackageSystem, PackageLinks, IDEContextHelpEdit;
type
TOnCheckInstallPackageList =
@ -696,6 +696,7 @@ var
Additions: TObjectList;
TVNode: TTreeNode;
PkgName: String;
ConflictDep: TPkgDependency;
begin
Additions:=TObjectList.Create(false);
NewPackageID:=TLazPackageID.Create;
@ -713,8 +714,8 @@ begin
end;
// check if already in list
if NewInstalledPackagesContains(NewPackageID) then begin
MessageDlg('Double',
'The package '+NewPackageID.Name+' is already in the list',mtError,
MessageDlg(lisDuplicate,
Format(lisThePackageIsAlreadyInTheList, [NewPackageID.Name]), mtError,
[mbCancel],0);
TVNode.Selected:=false;
exit;
@ -722,8 +723,8 @@ begin
// check if a package with same name is already in the list
j:=IndexOfNewInstalledPkgByName(NewPackageID.Name);
if j>=0 then begin
MessageDlg('Conflict',
'There is already a package '+NewPackageID.Name+' in the list',
MessageDlg(lisConflict,
Format(lisThereIsAlreadyAPackageInTheList, [NewPackageID.Name]),
mtError,[mbCancel],0);
TVNode.Selected:=false;
exit;
@ -732,15 +733,26 @@ begin
// installation in the IDE
APackage:=PackageGraph.FindPackageWithID(NewPackageID);
if APackage<>nil then begin
if APackage.PackageType=lptRunTime then begin
MessageDlg('Not a designtime package',
'The package '+APackage.IDAsString+' is not a design time package.'
+' It can not be installed in the IDE',mtError,
[mbCancel],0);
if APackage.PackageType in [lptRunTime,lptRunTimeOnly] then begin
IDEMessageDialog(lisNotADesigntimePackage,
Format(lisThePackageIsNotADesignTimePackageItCanNotBeInstall, [
APackage.IDAsString]), mtError,
[mbCancel]);
TVNode.Selected:=false;
exit;
end;
ConflictDep:=PackageGraph.FindRuntimePkgOnlyRecursively(
APackage.FirstRequiredDependency);
if ConflictDep<>nil then begin
IDEMessageDialog(lisNotADesigntimePackage,
Format(lisThePackageCanNotBeInstalledBecauseItRequiresWhichI, [
APackage.Name, ConflictDep.AsString]),
mtError,[mbCancel]);
TVNode.Selected:=false;
exit;
end;
end;
// ok => add to list
Additions.Add(NewPackageID);
NewPackageID:=TLazPackageID.Create;

View File

@ -489,11 +489,14 @@ type
TLazPackageType = (
lptRunTime, // RunTime packages can't register anything in the IDE.
// They can be used by designtime packages.
lptDesignTime, // DesignTime packages can register anything in the IDE
// and should not be compiled into projects.
// The IDE calls the 'register' procedures of each unit.
lptRunAndDesignTime // RunAndDesignTime packages can do anything.
lptRunAndDesignTime,// RunAndDesignTime packages can do anything.
lptRunTimeOnly // as lptRunTime, but they can not be used in the IDE
);
TLazPackageTypes = set of TLazPackageType;
TLazPackageFlag = (
lpfAutoIncrementVersionOnBuild, // increment version before
@ -850,7 +853,7 @@ const
'Unit', 'Virtual Unit', 'Main Unit',
'LFM', 'LRS', 'Include', 'Issues', 'Text', 'Binary');
LazPackageTypeIdents: array[TLazPackageType] of string = (
'RunTime', 'DesignTime', 'RunAndDesignTime');
'RunTime', 'DesignTime', 'RunAndDesignTime', 'RunTimeOnly');
AutoUpdateNames: array[TPackageUpdatePolicy] of string = (
'Manually', 'OnRebuildingAll', 'AsNeeded');
@ -932,6 +935,7 @@ var
Package1: TLazPackage; // don't use it - only for options dialog
function dbgs(p: TPackageUpdatePolicy): string; overload;
function dbgs(p: TLazPackageType): string; overload;
function PackagePathToStr(PathList: TFPList): string;
implementation
@ -1411,6 +1415,11 @@ begin
Result:=GetEnumName(TypeInfo(p),ord(p));
end;
function dbgs(p: TLazPackageType): string;
begin
Result:=LazPackageTypeIdents[p];
end;
function PackagePathToStr(PathList: TFPList): string;
var
i: Integer;

View File

@ -663,7 +663,8 @@ begin
PkgEditMenuSectionDependency.Visible:=false;
SetItem(PkgEditMenuAddToProject,@AddToProjectClick,true,CanBeAddedToProject);
SetItem(PkgEditMenuInstall,@InstallClick,true,not LazPackage.AutoCreated);
SetItem(PkgEditMenuInstall,@InstallClick,true,(not LazPackage.AutoCreated)
and (LazPackage.PackageType in [lptDesignTime,lptRunAndDesignTime]));
SetItem(PkgEditMenuUninstall,@UninstallClick,true,
(LazPackage.Installed<>pitNope) or (LazPackage.AutoInstall<>pitNope));
@ -720,7 +721,8 @@ begin
AddPopupMenuItem(lisPckEditAddToProject, @AddToProjectClick,
CanBeAddedToProject);
AddPopupMenuItem(lisPckEditInstall, @InstallClick,not LazPackage.AutoCreated);
AddPopupMenuItem(lisPckEditInstall, @InstallClick,(not LazPackage.AutoCreated)
and (LazPackage.PackageType in [lptDesignTime,lptRunAndDesignTime]));
AddPopupMenuItem(lisPckEditUninstall, @UninstallClick,
(LazPackage.Installed<>pitNope) or (LazPackage.AutoInstall<>pitNope));

View File

@ -238,6 +238,8 @@ type
const PkgName: string): TPkgDependency;
function FindConflictRecursively(FirstDependency: TPkgDependency;
PkgID: TLazPackageID): TPkgDependency;
function FindRuntimePkgOnlyRecursively(FirstDependency: TPkgDependency
): TPkgDependency;
function FindUnit(StartPackage: TLazPackage; const TheUnitName: string;
WithRequiredPackages, IgnoreDeleted: boolean): TPkgFile;
function FindUnitInAllPackages(const TheUnitName: string;
@ -1123,6 +1125,35 @@ begin
Result:=Find(FirstDependency);
end;
function TLazPackageGraph.FindRuntimePkgOnlyRecursively(
FirstDependency: TPkgDependency): TPkgDependency;
// returns one dependency using a runtime only package
function Find(CurDependency: TPkgDependency): TPkgDependency;
var
RequiredPackage: TLazPackage;
begin
while CurDependency<>nil do begin
if CurDependency.LoadPackageResult=lprSuccess then begin
RequiredPackage:=CurDependency.RequiredPackage;
if (not (lpfVisited in RequiredPackage.Flags)) then begin
if RequiredPackage.PackageType=lptRunTimeOnly then
exit(CurDependency);
RequiredPackage.Flags:=RequiredPackage.Flags+[lpfVisited];
Result:=Find(RequiredPackage.FirstRequiredDependency);
if Result<>nil then exit;
end;
end;
CurDependency:=CurDependency.NextRequiresDependency;
end;
Result:=nil;
end;
begin
MarkAllPackagesAsNotVisited;
Result:=Find(FirstDependency);
end;
function TLazPackageGraph.FindUnit(StartPackage: TLazPackage;
const TheUnitName: string;
WithRequiredPackages, IgnoreDeleted: boolean): TPkgFile;
@ -2319,7 +2350,7 @@ begin
APackage:=TLazPackage(PkgList[i]);
if (APackage=nil) or APackage.AutoCreated
or IsStaticBasePackage(APackage.Name)
or (APackage.PackageType=lptRunTime)
or (APackage.PackageType in [lptRunTime,lptRunTimeOnly])
then continue;
StaticPackagesInc:=StaticPackagesInc
+ExtractFileNameOnly(APackage.GetCompileSourceFilename)

View File

@ -1373,7 +1373,7 @@ begin
and (not Dependency.RequiredPackage.AutoCreated)
and (not PackageGraph.IsStaticBasePackage(Dependency.PackageName))
and (not Dependency.RequiredPackage.Missing)
and (Dependency.RequiredPackage.PackageType<>lptRunTime)
and (not (Dependency.RequiredPackage.PackageType in [lptRunTime,lptRunTimeOnly]))
then begin
if sl.IndexOf(Dependency.PackageName)<0 then begin
sl.Add(Dependency.PackageName);
@ -3596,6 +3596,8 @@ var
RequiredPackage: TLazPackage;
BuildIDEFlags: TBuildLazarusFlags;
Msg: string;
Btns: TMsgDlgButtons;
ConflictDep: TPkgDependency;
begin
if not MainIDE.DoResetToolStatus([rfInteractive]) then exit(mrCancel);
@ -3603,14 +3605,29 @@ begin
PkgList:=nil;
try
// check if package is designtime package
if APackage.PackageType=lptRunTime then begin
if APackage.PackageType in [lptRunTime,lptRunTimeOnly] then begin
Btns:=[mbAbort];
if APackage.PackageType=lptRunTime then
Include(Btns,mbIgnore);
Result:=IDEMessageDialog(lisPkgMangPackageIsNoDesigntimePackage,
Format(lisPkgMangThePackageIsARuntimeOnlyPackageRuntimeOnlyPackages,
[APackage.IDAsString, #13]),
mtError,[mbIgnore,mbAbort]);
mtError,Btns);
if Result<>mrIgnore then exit;
end;
// check if package requires a runtime only package
ConflictDep:=PackageGraph.FindRuntimePkgOnlyRecursively(
APackage.FirstRequiredDependency);
if ConflictDep<>nil then begin
IDEQuestionDialog(lisNotADesigntimePackage,
Format(lisThePackageCanNotBeInstalledBecauseItRequiresWhichI, [
APackage.Name, ConflictDep.AsString]),
mtError,
[mrCancel]
);
exit;
end;
// save package
if APackage.IsVirtual or APackage.Modified then begin
Result:=DoSavePackage(APackage,[]);
@ -3803,6 +3820,7 @@ var
ADependency: TPkgDependency;
NextDependency: TPkgDependency;
SaveFlags: TPkgSaveFlags;
ConflictDep: TPkgDependency;
begin
Result:=false;
PkgList:=nil;
@ -3819,10 +3837,30 @@ begin
ADependency:=NewFirstAutoInstallDependency;
while ADependency<>nil do begin
NextDependency:=ADependency.NextRequiresDependency;
if (ADependency.RequiredPackage<>nil)
and (ADependency.RequiredPackage.PackageType=lptRunTime) then begin
// top level dependency on runtime package => delete
DeleteDependencyInList(ADependency,NewFirstAutoInstallDependency,pdlRequires);
if (ADependency.RequiredPackage<>nil) then begin
if (ADependency.RequiredPackage.PackageType in [lptRunTime,lptRunTimeOnly])
then begin
// top level dependency on runtime package => delete
DeleteDependencyInList(ADependency,NewFirstAutoInstallDependency,pdlRequires);
end else begin
ConflictDep:=PackageGraph.FindRuntimePkgOnlyRecursively(
ADependency.RequiredPackage.FirstRequiredDependency);
//debugln(['TPkgManager.CheckInstallPackageList ',ADependency.RequiredPackage.Name,' ',ConflictDep<>nil]);
if ConflictDep<>nil then begin
if not (piiifQuiet in Flags) then begin
if IDEQuestionDialog(lisNotADesigntimePackage,
Format(lisThePackageCanNotBeInstalledBecauseItRequiresWhichI, [
ADependency.RequiredPackage.Name, ConflictDep.AsString]),
mtError,
[mrYes, Format(lisUninstall, [ADependency.RequiredPackage.Name]), mrCancel]
)<>mrYes
then
exit;
end;
// dependency needs a runtime only package => delete
DeleteDependencyInList(ADependency,NewFirstAutoInstallDependency,pdlRequires);
end;
end;
end;
ADependency:=NextDependency;
end;