mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 05:59:28 +02:00
IDE: compiler options: show options dialog: show execute before and after tool as well
git-svn-id: trunk@60680 -
This commit is contained in:
parent
f9b4f6ae8d
commit
2f1e9f4be2
@ -35,7 +35,7 @@ unit ShowCompilerOpts;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils,
|
||||
Classes, SysUtils, contnrs,
|
||||
// LCL
|
||||
Forms, Controls, Buttons, StdCtrls, ComCtrls, ExtCtrls,
|
||||
// LazUtils
|
||||
@ -43,18 +43,25 @@ uses
|
||||
// CodeTools
|
||||
CodeToolsCfgScript,
|
||||
// IdeIntf
|
||||
BaseIDEIntf, LazIDEIntf, IDEImagesIntf, CompOptsIntf, ProjectIntf, PackageIntf,
|
||||
BaseIDEIntf, LazIDEIntf, IDEImagesIntf, CompOptsIntf, ProjectIntf,
|
||||
PackageIntf, MacroIntf,
|
||||
// IDE
|
||||
LazarusIDEStrConsts, Project, PackageDefs,
|
||||
CompilerOptions, ModeMatrixOpts, MiscOptions;
|
||||
|
||||
type
|
||||
TShowCompToolOpts = class
|
||||
CompOpts: TCompilationToolOptions;
|
||||
Sheet: TTabSheet;
|
||||
Memo: TMemo;
|
||||
MultiLineCheckBox: TCheckBox;
|
||||
end;
|
||||
|
||||
{ TShowCompilerOptionsDlg }
|
||||
|
||||
TShowCompilerOptionsDlg = class(TForm)
|
||||
CloseButton: TBitBtn;
|
||||
CmdLineMemo: TMEMO;
|
||||
CmdLineMemo: TMemo;
|
||||
CmdLineParamsTabSheet: TTabSheet;
|
||||
InheritedParamsTabSheet: TTabSheet;
|
||||
InhItemMemo: TMemo;
|
||||
@ -75,10 +82,15 @@ type
|
||||
ImageIndexRequired: Integer;
|
||||
ImageIndexPackage: Integer;
|
||||
InheritedChildDatas: TFPList; // list of PInheritedNodeData
|
||||
FToolOptions: TObjectList; // list of TShowCompToolOpts
|
||||
FUpdatingMultiline: boolean;
|
||||
procedure ClearInheritedTree;
|
||||
procedure SetCompilerOpts(const AValue: TBaseCompilerOptions);
|
||||
procedure FillMemo(Memo: TMemo; Params: string);
|
||||
procedure UpdateMemo;
|
||||
procedure UpdateInheritedTree;
|
||||
procedure UpdateExecuteBeforeAfter;
|
||||
procedure UpdateToolMemo(Opts: TShowCompToolOpts);
|
||||
public
|
||||
property CompilerOpts: TBaseCompilerOptions read FCompilerOpts write SetCompilerOpts;
|
||||
end;
|
||||
@ -169,12 +181,38 @@ begin
|
||||
end;
|
||||
|
||||
procedure TShowCompilerOptionsDlg.MultilineCheckBoxChange(Sender: TObject);
|
||||
var
|
||||
CheckBox: TCheckBox;
|
||||
Checked: Boolean;
|
||||
i: Integer;
|
||||
Opts: TShowCompToolOpts;
|
||||
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;
|
||||
|
||||
procedure TShowCompilerOptionsDlg.FormCreate(Sender: TObject);
|
||||
begin
|
||||
FToolOptions:=TObjectList.Create(true);
|
||||
|
||||
ImageIndexPackage := IDEImages.LoadImage('item_package');
|
||||
ImageIndexRequired := IDEImages.LoadImage('pkg_required');
|
||||
ImageIndexInherited := IDEImages.LoadImage('pkg_inherited');
|
||||
@ -186,7 +224,7 @@ begin
|
||||
RelativePathsCheckBox.Caption:=lisShowRelativePaths;
|
||||
RelativePathsCheckBox.Checked:=not MiscellaneousOptions.ShowCompOptFullFilenames;
|
||||
MultilineCheckBox.Caption:=lisShowMultipleLines;
|
||||
MultilineCheckBox.Checked:=not MiscellaneousOptions.ShowCompOptMultiLine;
|
||||
MultilineCheckBox.Checked:=MiscellaneousOptions.ShowCompOptMultiLine;
|
||||
|
||||
InheritedParamsTabSheet.Caption:=lisInheritedParameters;
|
||||
InhTreeView.Images := IDEImages.Images_16;
|
||||
@ -201,6 +239,8 @@ begin
|
||||
MiscellaneousOptions.ShowCompOptFullFilenames:=not RelativePathsCheckBox.Checked;
|
||||
MiscellaneousOptions.ShowCompOptMultiLine:=MultilineCheckBox.Checked;
|
||||
MiscellaneousOptions.Save;
|
||||
|
||||
FreeAndNil(FToolOptions);
|
||||
end;
|
||||
|
||||
procedure TShowCompilerOptionsDlg.FormDestroy(Sender: TObject);
|
||||
@ -215,13 +255,33 @@ begin
|
||||
FCompilerOpts:=AValue;
|
||||
UpdateMemo;
|
||||
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;
|
||||
|
||||
procedure TShowCompilerOptionsDlg.UpdateMemo;
|
||||
var
|
||||
Flags: TCompilerCmdLineOptions;
|
||||
CurOptions, CompPath: String;
|
||||
ParamList: TStrings;
|
||||
begin
|
||||
if CompilerOpts=nil then exit;
|
||||
|
||||
@ -230,20 +290,9 @@ begin
|
||||
Include(Flags,ccloAbsolutePaths);
|
||||
CurOptions := CompilerOpts.MakeOptionsString(Flags);
|
||||
CompPath:=CompilerOpts.ParsedOpts.GetParsedValue(pcosCompilerPath);
|
||||
if MultilineCheckBox.Checked then begin
|
||||
ParamList:=TStringList.Create;
|
||||
try
|
||||
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;
|
||||
if Pos(' ',CompPath)>0 then
|
||||
CompPath:=QuotedStr(CompPath);
|
||||
FillMemo(CmdLineMemo,CompPath+' '+CurOptions);
|
||||
end;
|
||||
|
||||
procedure TShowCompilerOptionsDlg.UpdateInheritedTree;
|
||||
@ -430,5 +479,101 @@ begin
|
||||
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.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user