mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 04:18:48 +02:00
IDEIntf: added IgnoreQuestions, compile package: ignore compile failures 24h, bug #16903
git-svn-id: trunk@26709 -
This commit is contained in:
parent
c7da8d084e
commit
d52620c7e3
@ -36,7 +36,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, FileProcs, DiffPatch, IDEProcs, AvgLvlTree,
|
||||
SynEditTypes, Laz_XMLCfg, LazConf, Dialogs, LCLProc;
|
||||
SynEditTypes, Laz_XMLCfg, LazConf, Dialogs, LCLProc, IDEDialogs;
|
||||
|
||||
{$ifdef Windows}
|
||||
{$define CaseInsensitiveFilenames}
|
||||
@ -170,35 +170,21 @@ type
|
||||
TLazFindInFileSearchOptions = set of TLazFindInFileSearchOption;
|
||||
|
||||
|
||||
{ TIHIngoreItem }
|
||||
{ TIHIgnoreIDEQuestionList }
|
||||
|
||||
TIHIgnoreItemDuration = (
|
||||
iiidIDERestart,
|
||||
iiid24H,
|
||||
iiidForever
|
||||
);
|
||||
TIHIgnoreItemDurations = set of TIHIgnoreItemDuration;
|
||||
|
||||
TIHIngoreItem = class
|
||||
Identifier: string;
|
||||
Date: TDateTime;
|
||||
Duration: TIHIgnoreItemDuration;
|
||||
end;
|
||||
|
||||
{ TIHIgnoreItemList }
|
||||
|
||||
TIHIgnoreItemList = class
|
||||
TIHIgnoreIDEQuestionList = class(TIgnoreIDEQuestionList)
|
||||
private
|
||||
FItems: TAvgLvlTree; // tree of TIHIngoreItem
|
||||
FItems: TAvgLvlTree; // tree of TIgnoreIDEQuestionItem
|
||||
function FindNode(const Identifier: string): TAvgLvlTreeNode;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure Clear;
|
||||
function Add(const Identifier: string;
|
||||
Duration: TIHIgnoreItemDuration): TIHIngoreItem;
|
||||
procedure Delete(const Identifier: string);
|
||||
function Find(const Identifier: string): TIHIngoreItem;
|
||||
const Duration: TIgnoreQuestionDuration;
|
||||
const Flag: string = ''): TIgnoreIDEQuestionItem; override;
|
||||
procedure Delete(const Identifier: string); override;
|
||||
function Find(const Identifier: string): TIgnoreIDEQuestionItem; override;
|
||||
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
|
||||
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
|
||||
end;
|
||||
@ -216,7 +202,7 @@ type
|
||||
FFindInFilesSearchOptions: TLazFindInFileSearchOptions;
|
||||
FFindAutoComplete: boolean;
|
||||
FFindOptions: TSynSearchOptions;
|
||||
FIgnores: TIHIgnoreItemList;
|
||||
FIgnores: TIHIgnoreIDEQuestionList;
|
||||
FLastConvertDelphiPackage: string;
|
||||
FLastConvertDelphiProject: string;
|
||||
FLastConvertDelphiUnit: string;
|
||||
@ -321,7 +307,7 @@ type
|
||||
property FileEncodings: TStringToStringTree read fFileEncodings write fFileEncodings;
|
||||
|
||||
// ignores
|
||||
property Ignores: TIHIgnoreItemList read FIgnores;
|
||||
property Ignores: TIHIgnoreIDEQuestionList read FIgnores;
|
||||
end;
|
||||
|
||||
const
|
||||
@ -352,7 +338,7 @@ const
|
||||
'Replace',
|
||||
'ReplaceAll'
|
||||
);
|
||||
IHIgnoreItemDurationNames: array[TIHIgnoreItemDuration] of string = (
|
||||
IHIgnoreItemDurationNames: array[TIgnoreQuestionDuration] of string = (
|
||||
'IDERestart',
|
||||
'24H',
|
||||
'Forever'
|
||||
@ -364,7 +350,7 @@ var
|
||||
function CompareIHIgnoreItems(Item1, Item2: Pointer): integer;
|
||||
function CompareAnsiStringWithIHIgnoreItem(AString, Item: Pointer): integer;
|
||||
|
||||
function NameToIHIgnoreItemDuration(const s: string): TIHIgnoreItemDuration;
|
||||
function NameToIHIgnoreItemDuration(const s: string): TIgnoreQuestionDuration;
|
||||
|
||||
|
||||
implementation
|
||||
@ -378,22 +364,22 @@ const
|
||||
|
||||
function CompareIHIgnoreItems(Item1, Item2: Pointer): integer;
|
||||
var
|
||||
IgnoreItem1: TIHIngoreItem absolute Item1;
|
||||
IgnoreItem2: TIHIngoreItem absolute Item2;
|
||||
IgnoreItem1: TIgnoreIDEQuestionItem absolute Item1;
|
||||
IgnoreItem2: TIgnoreIDEQuestionItem absolute Item2;
|
||||
begin
|
||||
Result:=SysUtils.CompareText(IgnoreItem1.Identifier,IgnoreItem2.Identifier);
|
||||
end;
|
||||
|
||||
function CompareAnsiStringWithIHIgnoreItem(AString, Item: Pointer): integer;
|
||||
var
|
||||
IgnoreItem: TIHIngoreItem absolute Item;
|
||||
IgnoreItem: TIgnoreIDEQuestionItem absolute Item;
|
||||
begin
|
||||
Result:=SysUtils.CompareText(AnsiString(AString),IgnoreItem.Identifier);
|
||||
end;
|
||||
|
||||
function NameToIHIgnoreItemDuration(const s: string): TIHIgnoreItemDuration;
|
||||
function NameToIHIgnoreItemDuration(const s: string): TIgnoreQuestionDuration;
|
||||
begin
|
||||
for Result:=low(TIHIgnoreItemDuration) to high(TIHIgnoreItemDuration) do
|
||||
for Result:=low(TIgnoreQuestionDuration) to high(TIgnoreQuestionDuration) do
|
||||
if SysUtils.CompareText(IHIgnoreItemDurationNames[Result],s)=0 then exit;
|
||||
Result:=iiidIDERestart;
|
||||
end;
|
||||
@ -435,13 +421,15 @@ begin
|
||||
|
||||
fFileEncodings:=TStringToStringTree.Create({$IFDEF CaseInsensitiveFilenames}false{$ELSE}true{$ENDIF});
|
||||
|
||||
FIgnores:=TIHIgnoreItemList.Create;
|
||||
FIgnores:=TIHIgnoreIDEQuestionList.Create;
|
||||
IgnoreQuestions:=FIgnores;
|
||||
|
||||
Clear;
|
||||
end;
|
||||
|
||||
destructor TInputHistories.Destroy;
|
||||
begin
|
||||
IgnoreQuestions:=nil;
|
||||
FreeAndNil(FIgnores);
|
||||
FreeAndNil(FHistoryLists);
|
||||
FreeAndNil(FFileDialogSettings.HistoryList);
|
||||
@ -1083,48 +1071,48 @@ begin
|
||||
XMLConfig.SetDeleteValue(Path+'UnitLinks/Value',UnitLinks,'');
|
||||
end;
|
||||
|
||||
{ TIHIgnoreItemList }
|
||||
{ TIHIgnoreIDEQuestionList }
|
||||
|
||||
function TIHIgnoreItemList.FindNode(const Identifier: string): TAvgLvlTreeNode;
|
||||
function TIHIgnoreIDEQuestionList.FindNode(const Identifier: string): TAvgLvlTreeNode;
|
||||
begin
|
||||
Result:=FItems.FindKey(Pointer(Identifier),@CompareAnsiStringWithIHIgnoreItem);
|
||||
end;
|
||||
|
||||
constructor TIHIgnoreItemList.Create;
|
||||
constructor TIHIgnoreIDEQuestionList.Create;
|
||||
begin
|
||||
FItems:=TAvgLvlTree.Create(@CompareIHIgnoreItems);
|
||||
end;
|
||||
|
||||
destructor TIHIgnoreItemList.Destroy;
|
||||
destructor TIHIgnoreIDEQuestionList.Destroy;
|
||||
begin
|
||||
FItems.FreeAndClear;
|
||||
FreeAndNil(FItems);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TIHIgnoreItemList.Clear;
|
||||
procedure TIHIgnoreIDEQuestionList.Clear;
|
||||
begin
|
||||
FItems.FreeAndClear;
|
||||
end;
|
||||
|
||||
function TIHIgnoreItemList.Add(const Identifier: string;
|
||||
Duration: TIHIgnoreItemDuration): TIHIngoreItem;
|
||||
function TIHIgnoreIDEQuestionList.Add(const Identifier: string;
|
||||
const Duration: TIgnoreQuestionDuration; const Flag: string): TIgnoreIDEQuestionItem;
|
||||
var
|
||||
Node: TAvgLvlTreeNode;
|
||||
begin
|
||||
Node:=FindNode(Identifier);
|
||||
if Node<>nil then begin
|
||||
Result:=TIHIngoreItem(Node.Data);
|
||||
Result:=TIgnoreIDEQuestionItem(Node.Data);
|
||||
end else begin
|
||||
Result:=TIHIngoreItem.Create;
|
||||
Result.Identifier:=Identifier;
|
||||
Result:=TIgnoreIDEQuestionItem.Create(Identifier);
|
||||
FItems.Add(Result);
|
||||
end;
|
||||
Result.Duration:=Duration;
|
||||
Result.Date:=Now;
|
||||
Result.Flag:=Flag;
|
||||
end;
|
||||
|
||||
procedure TIHIgnoreItemList.Delete(const Identifier: string);
|
||||
procedure TIHIgnoreIDEQuestionList.Delete(const Identifier: string);
|
||||
var
|
||||
Node: TAvgLvlTreeNode;
|
||||
begin
|
||||
@ -1133,18 +1121,18 @@ begin
|
||||
FItems.FreeAndDelete(Node);
|
||||
end;
|
||||
|
||||
function TIHIgnoreItemList.Find(const Identifier: string): TIHIngoreItem;
|
||||
function TIHIgnoreIDEQuestionList.Find(const Identifier: string): TIgnoreIDEQuestionItem;
|
||||
var
|
||||
Node: TAvgLvlTreeNode;
|
||||
begin
|
||||
Node:=FindNode(Identifier);
|
||||
if Node<>nil then
|
||||
Result:=TIHIngoreItem(Node.Data)
|
||||
Result:=TIgnoreIDEQuestionItem(Node.Data)
|
||||
else
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
procedure TIHIgnoreItemList.LoadFromXMLConfig(XMLConfig: TXMLConfig;
|
||||
procedure TIHIgnoreIDEQuestionList.LoadFromXMLConfig(XMLConfig: TXMLConfig;
|
||||
const Path: string);
|
||||
var
|
||||
Cnt: longint;
|
||||
@ -1152,35 +1140,44 @@ var
|
||||
SubPath: String;
|
||||
Identifier: String;
|
||||
ADate: TDateTime;
|
||||
ADuration: TIHIgnoreItemDuration;
|
||||
Item: TIHIngoreItem;
|
||||
ADuration: TIgnoreQuestionDuration;
|
||||
Item: TIgnoreIDEQuestionItem;
|
||||
CurNow: TDateTime;
|
||||
begin
|
||||
Clear;
|
||||
CurNow:=Now;
|
||||
Cnt:=XMLConfig.GetValue(Path+'Count',0);
|
||||
for i:=1 to Cnt do begin
|
||||
SubPath:=Path+'Item'+IntToStr(i)+'/';
|
||||
Identifier:=XMLConfig.GetValue(SubPath+'Name','');
|
||||
if Identifier='' then continue;
|
||||
if not CfgStrToDate(XMLConfig.GetValue(SubPath+'Date',''),ADate) then continue;
|
||||
ADuration:=NameToIHIgnoreItemDuration(XMLConfig.GetValue(SubPath+'Duration',''));
|
||||
if ADuration=iiidIDERestart then continue;
|
||||
ADuration:=NameToIHIgnoreItemDuration(XMLConfig.GetValue(SubPath+'Duration',
|
||||
IHIgnoreItemDurationNames[iiid24H]));
|
||||
//debugln(['TIHIgnoreIDEQuestionList.LoadFromXMLConfig Identifier="',Identifier,'" Date=',DateTimeToStr(ADate),' Diff=',DateTimeToStr(CurNow-ADate),' Duration=',IHIgnoreItemDurationNames[ADuration]]);
|
||||
case ADuration of
|
||||
iiidIDERestart: continue;
|
||||
iiid24H: if Abs(CurNow-ADate)>1 then continue;
|
||||
iiidForever: ;
|
||||
end;
|
||||
Item:=Add(Identifier,ADuration);
|
||||
Item.Date:=ADate;
|
||||
Item.Flag:=XMLConfig.GetValue(SubPath+'Flag','');
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TIHIgnoreItemList.SaveToXMLConfig(XMLConfig: TXMLConfig;
|
||||
procedure TIHIgnoreIDEQuestionList.SaveToXMLConfig(XMLConfig: TXMLConfig;
|
||||
const Path: string);
|
||||
var
|
||||
i: Integer;
|
||||
Node: TAvgLvlTreeNode;
|
||||
Item: TIHIngoreItem;
|
||||
Item: TIgnoreIDEQuestionItem;
|
||||
SubPath: String;
|
||||
begin
|
||||
i:=0;
|
||||
Node:=FItems.FindLowest;
|
||||
while Node<>nil do begin
|
||||
Item:=TIHIngoreItem(Node.Data);
|
||||
Item:=TIgnoreIDEQuestionItem(Node.Data);
|
||||
if (Item.Duration<>iiidIDERestart) and (Item.Identifier<>'') then begin
|
||||
inc(i);
|
||||
SubPath:=Path+'Item'+IntToStr(i)+'/';
|
||||
@ -1189,6 +1186,7 @@ begin
|
||||
XMLConfig.SetDeleteValue(SubPath+'Duration',
|
||||
IHIgnoreItemDurationNames[Item.Duration],
|
||||
IHIgnoreItemDurationNames[iiid24H]);
|
||||
XMLConfig.SetDeleteValue(SubPath+'Flag',Item.Flag,'');
|
||||
end;
|
||||
Node:=FItems.FindSuccessor(Node);
|
||||
end;
|
||||
|
@ -52,6 +52,40 @@ function IDEQuestionDialogAb(const aCaption, aMsg: string;
|
||||
DlgType: TMsgDlgType; Buttons: array of const;
|
||||
HideAbort: boolean; const HelpKeyword: string = ''): Integer;
|
||||
|
||||
type
|
||||
{ TIgnoreIDEQuestionItem }
|
||||
|
||||
TIgnoreQuestionDuration = (
|
||||
iiidIDERestart,
|
||||
iiid24H,
|
||||
iiidForever
|
||||
);
|
||||
TIgnoreQuestionDurations = set of TIgnoreQuestionDuration;
|
||||
|
||||
TIgnoreIDEQuestionItem = class
|
||||
private
|
||||
FIdentifier: string;
|
||||
public
|
||||
Date: TDateTime;
|
||||
Flag: string;
|
||||
Duration: TIgnoreQuestionDuration;
|
||||
constructor Create(const TheIdentifier: string);
|
||||
property Identifier: string read FIdentifier;
|
||||
end;
|
||||
|
||||
{ TIgnoreIDEQuestionList }
|
||||
|
||||
TIgnoreIDEQuestionList = class
|
||||
public
|
||||
function Add(const Identifier: string;
|
||||
const Duration: TIgnoreQuestionDuration;
|
||||
const Flag: string = ''): TIgnoreIDEQuestionItem; virtual; abstract;
|
||||
procedure Delete(const Identifier: string); virtual; abstract;
|
||||
function Find(const Identifier: string): TIgnoreIDEQuestionItem; virtual; abstract;
|
||||
end;
|
||||
|
||||
var
|
||||
IgnoreQuestions: TIgnoreIDEQuestionList = nil;
|
||||
|
||||
implementation
|
||||
|
||||
@ -105,5 +139,13 @@ begin
|
||||
Result:=IDEQuestionDialog(aCaption,aMsg,DlgType,NewButtons,HelpKeyword);
|
||||
end;
|
||||
|
||||
|
||||
{ TIgnoreIDEQuestionItem }
|
||||
|
||||
constructor TIgnoreIDEQuestionItem.Create(const TheIdentifier: string);
|
||||
begin
|
||||
fIdentifier:=TheIdentifier;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -268,9 +268,9 @@ type
|
||||
RenameDependencies: boolean);
|
||||
function SavePackageCompiledState(APackage: TLazPackage;
|
||||
const CompilerFilename, CompilerParams: string;
|
||||
Complete: boolean): TModalResult;
|
||||
Complete, ShowAbort: boolean): TModalResult;
|
||||
function LoadPackageCompiledState(APackage: TLazPackage;
|
||||
IgnoreErrors: boolean): TModalResult;
|
||||
IgnoreErrors, ShowAbort: boolean): TModalResult;
|
||||
function CheckCompileNeedDueToDependencies(FirstDependency: TPkgDependency;
|
||||
StateFileAge: longint): TModalResult;
|
||||
function ExtractCompilerParamsForBuildAll(const CompParams: string): string;
|
||||
@ -2702,7 +2702,7 @@ begin
|
||||
end;
|
||||
|
||||
function TLazPackageGraph.SavePackageCompiledState(APackage: TLazPackage;
|
||||
const CompilerFilename, CompilerParams: string; Complete: boolean
|
||||
const CompilerFilename, CompilerParams: string; Complete, ShowAbort: boolean
|
||||
): TModalResult;
|
||||
var
|
||||
XMLConfig: TXMLConfig;
|
||||
@ -2735,10 +2735,10 @@ begin
|
||||
APackage.Flags:=APackage.Flags+[lpfStateFileLoaded];
|
||||
except
|
||||
on E: Exception do begin
|
||||
Result:=IDEMessageDialog(lisPkgMangErrorWritingFile,
|
||||
Result:=IDEMessageDialogAb(lisPkgMangErrorWritingFile,
|
||||
Format(lisPkgMangUnableToWriteStateFileOfPackageError, ['"', StateFile,
|
||||
'"', #13, APackage.IDAsString, #13, E.Message]),
|
||||
mtError,[mbAbort,mbCancel]);
|
||||
mtError,[mbCancel],ShowAbort);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
@ -2747,7 +2747,7 @@ begin
|
||||
end;
|
||||
|
||||
function TLazPackageGraph.LoadPackageCompiledState(APackage: TLazPackage;
|
||||
IgnoreErrors: boolean): TModalResult;
|
||||
IgnoreErrors, ShowAbort: boolean): TModalResult;
|
||||
var
|
||||
XMLConfig: TXMLConfig;
|
||||
StateFile: String;
|
||||
@ -2784,10 +2784,10 @@ begin
|
||||
if IgnoreErrors then begin
|
||||
Result:=mrOk;
|
||||
end else begin
|
||||
Result:=IDEMessageDialog(lisPkgMangErrorReadingFile,
|
||||
Result:=IDEMessageDialogAb(lisPkgMangErrorReadingFile,
|
||||
Format(lisPkgMangUnableToReadStateFileOfPackageError, ['"',
|
||||
StateFile, '"', #13, APackage.IDAsString, #13, E.Message]),
|
||||
mtError,[mbCancel,mbAbort]);
|
||||
mtError,[mbCancel],ShowAbort);
|
||||
end;
|
||||
exit;
|
||||
end;
|
||||
@ -2822,7 +2822,7 @@ begin
|
||||
RequiredPackage:=Dependency.RequiredPackage;
|
||||
// check compile state file of required package
|
||||
if not RequiredPackage.AutoCreated then begin
|
||||
Result:=LoadPackageCompiledState(RequiredPackage,false);
|
||||
Result:=LoadPackageCompiledState(RequiredPackage,false,true);
|
||||
if Result<>mrOk then exit;
|
||||
Result:=mrYes;
|
||||
if not (lpfStateFileLoaded in RequiredPackage.Flags) then begin
|
||||
@ -2937,7 +2937,7 @@ begin
|
||||
|
||||
// check state file
|
||||
StateFilename:=APackage.GetStateFilename;
|
||||
Result:=LoadPackageCompiledState(APackage,false);
|
||||
Result:=LoadPackageCompiledState(APackage,false,true);
|
||||
if Result<>mrOk then exit;
|
||||
if not (lpfStateFileLoaded in APackage.Flags) then begin
|
||||
DebugLn('TLazPackageGraph.CheckIfPackageNeedsCompilation No state file for ',APackage.IDAsString);
|
||||
@ -3051,6 +3051,12 @@ end;
|
||||
function TLazPackageGraph.CompilePackage(APackage: TLazPackage;
|
||||
Flags: TPkgCompileFlags; ShowAbort: boolean; Globals: TGlobalCompilerOptions
|
||||
): TModalResult;
|
||||
|
||||
function GetIgnoreIdentifier: string;
|
||||
begin
|
||||
Result:='install_package_compile_failed:'+APackage.Filename;
|
||||
end;
|
||||
|
||||
var
|
||||
PkgCompileTool: TIDEExternalToolOptions;
|
||||
CompilerFilename: String;
|
||||
@ -3060,7 +3066,7 @@ var
|
||||
CompilePolicies: TPackageUpdatePolicies;
|
||||
BlockBegan: Boolean;
|
||||
NeedBuildAllFlag: Boolean;
|
||||
CompileResult: TModalResult;
|
||||
CompileResult, MsgResult: TModalResult;
|
||||
begin
|
||||
Result:=mrCancel;
|
||||
|
||||
@ -3207,7 +3213,7 @@ begin
|
||||
// write state file
|
||||
Result:=SavePackageCompiledState(APackage,
|
||||
CompilerFilename,CompilerParams,
|
||||
CompileResult=mrOk);
|
||||
CompileResult=mrOk,true);
|
||||
if Result<>mrOk then begin
|
||||
DebugLn(['TLazPackageGraph.CompilePackage SavePackageCompiledState failed: ',APackage.IDAsString]);
|
||||
exit;
|
||||
@ -3247,15 +3253,21 @@ begin
|
||||
if BlockBegan and (IDEMessagesWindow<>nil) then
|
||||
IDEMessagesWindow.EndBlock;
|
||||
if Result<>mrOk then begin
|
||||
if (APackage.AutoInstall<>pitNope) and (APackage.Installed=pitNope)
|
||||
and (OnUninstallPackage<>nil) then begin
|
||||
// package was tried to install, but failed
|
||||
if (APackage.AutoInstall<>pitNope)
|
||||
and (OnUninstallPackage<>nil)
|
||||
and (IgnoreQuestions<>nil)
|
||||
and (IgnoreQuestions.Find(GetIgnoreIdentifier)=nil)
|
||||
then begin
|
||||
// a package needed for installation failed to compile
|
||||
// -> ask user if the package should be removed from the installation
|
||||
// list
|
||||
if IDEMessageDialog(lisInstallationFailed,
|
||||
MsgResult:=IDEMessageDialog(lisInstallationFailed,
|
||||
Format(lisPkgMangThePackageFailedToCompileRemoveItFromTheInstallati,
|
||||
['"', APackage.IDAsString, '"', #13]), mtConfirmation,
|
||||
[mbYes,mbIgnore])=mrYes then
|
||||
[mbYes,mbIgnore]);
|
||||
if MsgResult=mrIgnore then
|
||||
IgnoreQuestions.Add(GetIgnoreIdentifier,iiid24H)
|
||||
else if MsgResult=mrYes then
|
||||
begin
|
||||
Result:=OnUninstallPackage(APackage,
|
||||
[puifDoNotConfirm,puifDoNotBuildIDE],true);
|
||||
|
Loading…
Reference in New Issue
Block a user