IDE: compiler options: show options dialog: show execute before and after tool as well

git-svn-id: trunk@60680 -
This commit is contained in:
mattias 2019-03-15 13:39:51 +00:00
parent f9b4f6ae8d
commit 2f1e9f4be2

View File

@ -35,7 +35,7 @@ unit ShowCompilerOpts;
interface interface
uses uses
Classes, SysUtils, Classes, SysUtils, contnrs,
// LCL // LCL
Forms, Controls, Buttons, StdCtrls, ComCtrls, ExtCtrls, Forms, Controls, Buttons, StdCtrls, ComCtrls, ExtCtrls,
// LazUtils // LazUtils
@ -43,18 +43,25 @@ uses
// CodeTools // CodeTools
CodeToolsCfgScript, CodeToolsCfgScript,
// IdeIntf // IdeIntf
BaseIDEIntf, LazIDEIntf, IDEImagesIntf, CompOptsIntf, ProjectIntf, PackageIntf, BaseIDEIntf, LazIDEIntf, IDEImagesIntf, CompOptsIntf, ProjectIntf,
PackageIntf, MacroIntf,
// IDE // IDE
LazarusIDEStrConsts, Project, PackageDefs, LazarusIDEStrConsts, Project, PackageDefs,
CompilerOptions, ModeMatrixOpts, MiscOptions; CompilerOptions, ModeMatrixOpts, MiscOptions;
type type
TShowCompToolOpts = class
CompOpts: TCompilationToolOptions;
Sheet: TTabSheet;
Memo: TMemo;
MultiLineCheckBox: TCheckBox;
end;
{ TShowCompilerOptionsDlg } { TShowCompilerOptionsDlg }
TShowCompilerOptionsDlg = class(TForm) TShowCompilerOptionsDlg = class(TForm)
CloseButton: TBitBtn; CloseButton: TBitBtn;
CmdLineMemo: TMEMO; CmdLineMemo: TMemo;
CmdLineParamsTabSheet: TTabSheet; CmdLineParamsTabSheet: TTabSheet;
InheritedParamsTabSheet: TTabSheet; InheritedParamsTabSheet: TTabSheet;
InhItemMemo: TMemo; InhItemMemo: TMemo;
@ -75,10 +82,15 @@ type
ImageIndexRequired: Integer; ImageIndexRequired: Integer;
ImageIndexPackage: Integer; ImageIndexPackage: Integer;
InheritedChildDatas: TFPList; // list of PInheritedNodeData InheritedChildDatas: TFPList; // list of PInheritedNodeData
FToolOptions: TObjectList; // list of TShowCompToolOpts
FUpdatingMultiline: boolean;
procedure ClearInheritedTree; procedure ClearInheritedTree;
procedure SetCompilerOpts(const AValue: TBaseCompilerOptions); procedure SetCompilerOpts(const AValue: TBaseCompilerOptions);
procedure FillMemo(Memo: TMemo; Params: string);
procedure UpdateMemo; procedure UpdateMemo;
procedure UpdateInheritedTree; procedure UpdateInheritedTree;
procedure UpdateExecuteBeforeAfter;
procedure UpdateToolMemo(Opts: TShowCompToolOpts);
public public
property CompilerOpts: TBaseCompilerOptions read FCompilerOpts write SetCompilerOpts; property CompilerOpts: TBaseCompilerOptions read FCompilerOpts write SetCompilerOpts;
end; end;
@ -169,12 +181,38 @@ begin
end; end;
procedure TShowCompilerOptionsDlg.MultilineCheckBoxChange(Sender: TObject); procedure TShowCompilerOptionsDlg.MultilineCheckBoxChange(Sender: TObject);
var
CheckBox: TCheckBox;
Checked: Boolean;
i: Integer;
Opts: TShowCompToolOpts;
begin begin
UpdateMemo; if FUpdatingMultiline then exit;
CheckBox:=Sender as TCheckBox;
Checked:=CheckBox.Checked;
FUpdatingMultiline:=true;
try
MultilineCheckBox.Checked:=Checked;
UpdateMemo;
for i:=0 to FToolOptions.Count-1 do
begin
Opts:=TShowCompToolOpts(FToolOptions[i]);
if Opts.MultiLineCheckBox<>nil then begin
Opts.MultiLineCheckBox.Checked:=Checked;
UpdateToolMemo(Opts);
end;
end;
finally
FUpdatingMultiline:=false;
end;
end; end;
procedure TShowCompilerOptionsDlg.FormCreate(Sender: TObject); procedure TShowCompilerOptionsDlg.FormCreate(Sender: TObject);
begin begin
FToolOptions:=TObjectList.Create(true);
ImageIndexPackage := IDEImages.LoadImage('item_package'); ImageIndexPackage := IDEImages.LoadImage('item_package');
ImageIndexRequired := IDEImages.LoadImage('pkg_required'); ImageIndexRequired := IDEImages.LoadImage('pkg_required');
ImageIndexInherited := IDEImages.LoadImage('pkg_inherited'); ImageIndexInherited := IDEImages.LoadImage('pkg_inherited');
@ -186,7 +224,7 @@ begin
RelativePathsCheckBox.Caption:=lisShowRelativePaths; RelativePathsCheckBox.Caption:=lisShowRelativePaths;
RelativePathsCheckBox.Checked:=not MiscellaneousOptions.ShowCompOptFullFilenames; RelativePathsCheckBox.Checked:=not MiscellaneousOptions.ShowCompOptFullFilenames;
MultilineCheckBox.Caption:=lisShowMultipleLines; MultilineCheckBox.Caption:=lisShowMultipleLines;
MultilineCheckBox.Checked:=not MiscellaneousOptions.ShowCompOptMultiLine; MultilineCheckBox.Checked:=MiscellaneousOptions.ShowCompOptMultiLine;
InheritedParamsTabSheet.Caption:=lisInheritedParameters; InheritedParamsTabSheet.Caption:=lisInheritedParameters;
InhTreeView.Images := IDEImages.Images_16; InhTreeView.Images := IDEImages.Images_16;
@ -201,6 +239,8 @@ begin
MiscellaneousOptions.ShowCompOptFullFilenames:=not RelativePathsCheckBox.Checked; MiscellaneousOptions.ShowCompOptFullFilenames:=not RelativePathsCheckBox.Checked;
MiscellaneousOptions.ShowCompOptMultiLine:=MultilineCheckBox.Checked; MiscellaneousOptions.ShowCompOptMultiLine:=MultilineCheckBox.Checked;
MiscellaneousOptions.Save; MiscellaneousOptions.Save;
FreeAndNil(FToolOptions);
end; end;
procedure TShowCompilerOptionsDlg.FormDestroy(Sender: TObject); procedure TShowCompilerOptionsDlg.FormDestroy(Sender: TObject);
@ -215,13 +255,33 @@ begin
FCompilerOpts:=AValue; FCompilerOpts:=AValue;
UpdateMemo; UpdateMemo;
UpdateInheritedTree; UpdateInheritedTree;
UpdateExecuteBeforeAfter;
end;
procedure TShowCompilerOptionsDlg.FillMemo(Memo: TMemo; Params: string);
var
ParamList: TStringList;
begin
if Memo=nil then exit;
if MultilineCheckBox.Checked then begin
ParamList:=TStringList.Create;
try
SplitCmdLineParams(Params,ParamList);
Memo.Lines.Assign(ParamList);
finally
ParamList.Free;
end;
Memo.ScrollBars:=ssAutoBoth;
end else begin
Memo.ScrollBars:=ssAutoVertical;
Memo.Lines.Text:=Params;
end;
end; end;
procedure TShowCompilerOptionsDlg.UpdateMemo; procedure TShowCompilerOptionsDlg.UpdateMemo;
var var
Flags: TCompilerCmdLineOptions; Flags: TCompilerCmdLineOptions;
CurOptions, CompPath: String; CurOptions, CompPath: String;
ParamList: TStrings;
begin begin
if CompilerOpts=nil then exit; if CompilerOpts=nil then exit;
@ -230,20 +290,9 @@ begin
Include(Flags,ccloAbsolutePaths); Include(Flags,ccloAbsolutePaths);
CurOptions := CompilerOpts.MakeOptionsString(Flags); CurOptions := CompilerOpts.MakeOptionsString(Flags);
CompPath:=CompilerOpts.ParsedOpts.GetParsedValue(pcosCompilerPath); CompPath:=CompilerOpts.ParsedOpts.GetParsedValue(pcosCompilerPath);
if MultilineCheckBox.Checked then begin if Pos(' ',CompPath)>0 then
ParamList:=TStringList.Create; CompPath:=QuotedStr(CompPath);
try FillMemo(CmdLineMemo,CompPath+' '+CurOptions);
ParamList.Add(CompPath);
SplitCmdLineParams(CurOptions,ParamList);
CmdLineMemo.Lines.Assign(ParamList);
finally
ParamList.Free;
end;
CmdLineMemo.ScrollBars:=ssAutoBoth;
end else begin
CmdLineMemo.ScrollBars:=ssAutoVertical;
CmdLineMemo.Lines.Text:=QuotedStr(CompPath)+' '+CurOptions;
end;
end; end;
procedure TShowCompilerOptionsDlg.UpdateInheritedTree; procedure TShowCompilerOptionsDlg.UpdateInheritedTree;
@ -430,5 +479,101 @@ begin
end; end;
end; end;
procedure TShowCompilerOptionsDlg.UpdateExecuteBeforeAfter;
var
PgIndex, ToolIndex: integer;
procedure AddTool(CompOpts: TCompilationToolOptions; aCaption: string);
const
Space = 6;
var
ShowOpts: TShowCompToolOpts;
Sheet: TTabSheet;
Memo: TMemo;
CheckBox: TCheckBox;
begin
if ToolIndex>=FToolOptions.Count then begin
ShowOpts:=TShowCompToolOpts.Create;
ShowOpts.CompOpts:=CompOpts;
FToolOptions.Add(ShowOpts);
end else
ShowOpts:=TShowCompToolOpts(FToolOptions[ToolIndex]);
inc(ToolIndex);
if CompOpts.CompileReasons=[] then begin
// this tool is never called -> skip
if ShowOpts.Sheet<>nil then begin
ShowOpts.Sheet.Free;
ShowOpts.Sheet:=nil;
end;
exit;
end;
if ShowOpts.Sheet=nil then
begin
Sheet:=PageControl1.AddTabSheet;
ShowOpts.Sheet:=Sheet;
Sheet.Name:='TabSheet_Tool'+IntToStr(ToolIndex);
end else
Sheet:=ShowOpts.Sheet;
inc(PgIndex);
Sheet.Caption:=aCaption;
if ShowOpts.Memo=nil then begin
Memo:=TMemo.Create(Sheet);
ShowOpts.Memo:=Memo;
Memo.Name:='Memo_Tool'+IntToStr(ToolIndex);
Memo.Parent:=Sheet;
end else
Memo:=ShowOpts.Memo;
if ShowOpts.MultiLineCheckBox=nil then begin
CheckBox:=TCheckBox.Create(Sheet);
ShowOpts.MultiLineCheckBox:=CheckBox;
CheckBox.Name:='MulitlineCheckBox_Tool'+IntToStr(ToolIndex);
CheckBox.Parent:=Sheet;
CheckBox.Checked:=MultilineCheckBox.Checked;
end else
CheckBox:=ShowOpts.MultiLineCheckBox;
CheckBox.Left:=Space;
CheckBox.AnchorParallel(akBottom,Space,Sheet);
CheckBox.Anchors:=[akLeft,akBottom];
CheckBox.Caption:=MultilineCheckBox.Caption;
CheckBox.Checked:=MultilineCheckBox.Checked;
CheckBox.OnChange:=@MultilineCheckBoxChange;
Memo.WordWrap:=true;
Memo.Align:=alTop;
Memo.AnchorToNeighbour(akBottom,Space,CheckBox);
UpdateToolMemo(ShowOpts);
end;
var
OldPageIndex: integer;
begin
OldPageIndex:=PageControl1.PageIndex;
PgIndex:=2;
ToolIndex:=0;
DisableAutoSizing;
try
AddTool(CompilerOpts.ExecuteBefore,'Execute Before');
AddTool(CompilerOpts.ExecuteAfter,'Execute After');
PageControl1.PageIndex:=OldPageIndex;
finally
EnableAutoSizing;
end;
end;
procedure TShowCompilerOptionsDlg.UpdateToolMemo(Opts: TShowCompToolOpts);
var
Params: String;
begin
Params:=Opts.CompOpts.Command;
IDEMacros.SubstituteMacros(Params);
FillMemo(Opts.Memo,Params);
end;
end. end.