IDE: update inherited compiler options when frame becomes visible

git-svn-id: trunk@41246 -
This commit is contained in:
mattias 2013-05-17 21:49:44 +00:00
parent b5943c123d
commit 6e218ad039
9 changed files with 312 additions and 63 deletions

View File

@ -47,7 +47,7 @@ uses
EditDefineTree, ProjectResources, MiscOptions, LazConf, EnvironmentOpts, EditDefineTree, ProjectResources, MiscOptions, LazConf, EnvironmentOpts,
TransferMacros, CompilerOptions, OutputFilter, Compiler, FPCSrcScan, TransferMacros, CompilerOptions, OutputFilter, Compiler, FPCSrcScan,
PackageDefs, PackageSystem, Project, ProjectIcon, PackageDefs, PackageSystem, Project, ProjectIcon,
BaseBuildManager, ApplicationBundle; ModeMatrixOpts, BaseBuildManager, ApplicationBundle;
type type
{ TBuildManager } { TBuildManager }
@ -148,6 +148,11 @@ type
override; override;
function OnGetBuildMacroValues(Options: TBaseCompilerOptions; function OnGetBuildMacroValues(Options: TBaseCompilerOptions;
IncludeSelf: boolean): TCTCfgScriptVariables; IncludeSelf: boolean): TCTCfgScriptVariables;
procedure AppendMatrixCustomOption(Sender: TObject;
var Options: string; Types: TBuildMatrixGroupTypes);
procedure GetMatrixOutputDirectoryOverride(Sender: TObject;
var OutDir: string; Types: TBuildMatrixGroupTypes);
function GetModeMatrixTarget(Sender: TObject): string;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
@ -298,14 +303,20 @@ begin
RunCompilerWithOptions:=@OnRunCompilerWithOptions; RunCompilerWithOptions:=@OnRunCompilerWithOptions;
GetBuildMacroValues:=@OnGetBuildMacroValues; GetBuildMacroValues:=@OnGetBuildMacroValues;
OnAppendCustomOption:=@AppendMatrixCustomOption;
OnGetOutputDirectoryOverride:=@GetMatrixOutputDirectoryOverride;
end; end;
destructor TBuildManager.Destroy; destructor TBuildManager.Destroy;
begin begin
GetBuildMacroValues:=nil;
OnAppendCustomOption:=nil;
OnBackupFileInteractive:=nil;
RunCompilerWithOptions:=nil;
FreeAndNil(FFPCSrcScans); FreeAndNil(FFPCSrcScans);
LazConfMacroFunc:=nil; LazConfMacroFunc:=nil;
OnBackupFileInteractive:=nil;
FreeAndNil(InputHistories); FreeAndNil(InputHistories);
FreeAndNil(DefaultCfgVars); FreeAndNil(DefaultCfgVars);
@ -2328,6 +2339,59 @@ begin
end; end;
end; end;
procedure TBuildManager.AppendMatrixCustomOption(Sender: TObject;
var Options: string; Types: TBuildMatrixGroupTypes);
var
Target: String;
ActiveMode: String;
begin
if Project1=nil then exit;
Target:=GetModeMatrixTarget(Sender);
ActiveMode:=Project1.ActiveBuildMode.Identifier;
if bmgtEnvironment in Types then
EnvironmentOptions.BuildMatrixOptions.AppendCustomOptions(Target,ActiveMode,Options);
if bmgtProject in Types then
Project1.BuildModes.SharedMatrixOptions.AppendCustomOptions(Target,ActiveMode,Options);
if bmgtSession in Types then
Project1.BuildModes.SessionMatrixOptions.AppendCustomOptions(Target,ActiveMode,Options);
end;
procedure TBuildManager.GetMatrixOutputDirectoryOverride(Sender: TObject;
var OutDir: string; Types: TBuildMatrixGroupTypes);
var
Target: String;
ActiveMode: String;
begin
if Project1=nil then exit;
Target:=GetModeMatrixTarget(Sender);
ActiveMode:=Project1.ActiveBuildMode.Identifier;
if bmgtEnvironment in Types then
EnvironmentOptions.BuildMatrixOptions.GetOutputDirectory(Target,ActiveMode,OutDir);
if bmgtProject in Types then
Project1.BuildModes.SharedMatrixOptions.GetOutputDirectory(Target,ActiveMode,OutDir);
if bmgtSession in Types then
Project1.BuildModes.SessionMatrixOptions.GetOutputDirectory(Target,ActiveMode,OutDir);
end;
function TBuildManager.GetModeMatrixTarget(Sender: TObject): string;
begin
Result:='';
if Sender is TParsedCompilerOptions then
Sender:=TParsedCompilerOptions(Sender).Owner;
if Sender is TPkgAdditionalCompilerOptions then
exit; // matrix options are added only to normal options
if Sender is TPkgCompilerOptions then
Sender:=TPkgCompilerOptions(Sender).Owner
else if Sender is TProjectCompilerOptions then
Sender:=TProjectCompilerOptions(Sender).Owner;
if Sender is TProject then begin
Result:=BuildMatrixProjectName;
end else if Sender is TLazPackage then begin
Result:=TLazPackage(Sender).Name;
end;
//debugln(['TBuildManager.GetModeMatrixTarget ',DbgSName(Sender),' Target="',Result,'"']);
end;
procedure TBuildManager.SetBuildTarget(const TargetOS, TargetCPU, procedure TBuildManager.SetBuildTarget(const TargetOS, TargetCPU,
LCLWidgetType: string; ScanFPCSrc: TScanModeFPCSources; Quiet: boolean); LCLWidgetType: string; ScanFPCSrc: TScanModeFPCSources; Quiet: boolean);

View File

@ -29,18 +29,6 @@
* * * *
*************************************************************************** ***************************************************************************
ToDo:
- when adding/removing search path: do it for all build modes
- add unit to project
- remove unit from project
- move unit in project
- make lazbuild lcl independent, independent of packages except one
- license gpl2
- create package lazbuildsystem with some units
- move
- i18n for descriptions
- keyword help for a build macro
} }
unit CompilerOptions; unit CompilerOptions;
@ -61,7 +49,8 @@ uses
ProjectIntf, MacroIntf, IDEExternToolIntf, SrcEditorIntf, CompOptsIntf, ProjectIntf, MacroIntf, IDEExternToolIntf, SrcEditorIntf, CompOptsIntf,
IDEOptionsIntf, IDEOptionsIntf,
// IDE // IDE
LazarusIDEStrConsts, IDEProcs, IDEMsgIntf, LazConf, TransferMacros, CompOptsModes; LazarusIDEStrConsts, IDEProcs, IDEMsgIntf, LazConf, TransferMacros,
ModeMatrixOpts, CompOptsModes;
type type
@ -686,8 +675,14 @@ function ConvertOptionsToCmdLine(const Switch, OptionStr: string): string;
type type
TGetBuildMacroValues = function(Options: TBaseCompilerOptions; TGetBuildMacroValues = function(Options: TBaseCompilerOptions;
IncludeSelf: boolean): TCTCfgScriptVariables of object; IncludeSelf: boolean): TCTCfgScriptVariables of object;
TOnAppendCustomOptions = procedure(Sender: TObject;
var CustomOptions: string; Types: TBuildMatrixGroupTypes) of object;
TOnGetOutputDirectoryOverride = procedure(Sender: TObject;
var OutDir: string; Types: TBuildMatrixGroupTypes) of object;
var var
GetBuildMacroValues: TGetBuildMacroValues = nil; // set by TPkgManager, do not change or free the variables GetBuildMacroValues: TGetBuildMacroValues = nil; // set by TPkgManager, do not change or free the variables
OnAppendCustomOption: TOnAppendCustomOptions = nil; // set by MainBuildBoss
OnGetOutputDirectoryOverride: TOnGetOutputDirectoryOverride = nil; // set by MainBuildBoss
function LoadXMLCompileReasons(const AConfig: TXMLConfig; function LoadXMLCompileReasons(const AConfig: TXMLConfig;
const APath: String; const DefaultReasons: TCompileReasons): TCompileReasons; const APath: String; const DefaultReasons: TCompileReasons): TCompileReasons;
@ -3867,6 +3862,15 @@ var
begin begin
s:=OptionText; s:=OptionText;
// apply overrides
if Option=pcosCustomOptions then begin
if Assigned(OnAppendCustomOption) then
OnAppendCustomOption(Self,s,bmgtAll);
end else if Option=pcosOutputDir then begin
if Assigned(OnGetOutputDirectoryOverride) then
OnGetOutputDirectoryOverride(Self,s,bmgtAll);
end;
// parse locally (macros depending on owner, like pkgdir and build macros) // parse locally (macros depending on owner, like pkgdir and build macros)
if Assigned(OnLocalSubstitute) then if Assigned(OnLocalSubstitute) then
begin begin

View File

@ -36,7 +36,7 @@ uses
ProjectIntf, IDEImagesIntf, IDEOptionsIntf, CompOptsIntf, ProjectIntf, IDEImagesIntf, IDEOptionsIntf, CompOptsIntf,
PackageDefs, compiler_inherited_options, TransferMacros, PackageDefs, compiler_inherited_options, TransferMacros,
PathEditorDlg, Project, PackageSystem, LazarusIDEStrConsts, CompilerOptions, PathEditorDlg, Project, PackageSystem, LazarusIDEStrConsts, CompilerOptions,
IDEProcs, BuildModeDiffDlg; IDEProcs, BuildModeDiffDlg, Compiler_ModeMatrix;
type type
@ -78,6 +78,7 @@ type
procedure DoShowSession; procedure DoShowSession;
procedure UpdateDialogCaption; procedure UpdateDialogCaption;
function GetDialogCaption: string; function GetDialogCaption: string;
procedure ModesChanged;
public public
constructor Create(TheOwner: TComponent); override; constructor Create(TheOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
@ -154,6 +155,8 @@ begin
BuildModesStringGrid.Col:=fModeNameCol; BuildModesStringGrid.Col:=fModeNameCol;
BuildModesStringGrid.Row:=BuildModesStringGrid.RowCount-1; BuildModesStringGrid.Row:=BuildModesStringGrid.RowCount-1;
BuildModesStringGrid.EditorMode:=true; BuildModesStringGrid.EditorMode:=true;
ModesChanged;
end; end;
procedure TBuildModesEditorFrame.BuildModeDeleteSpeedButtonClick(Sender: TObject); procedure TBuildModesEditorFrame.BuildModeDeleteSpeedButtonClick(Sender: TObject);
@ -192,6 +195,8 @@ begin
Grid.Row:=Grid.RowCount-1 Grid.Row:=Grid.RowCount-1
else else
Grid.Row:=i; Grid.Row:=i;
ModesChanged;
end; end;
procedure TBuildModesEditorFrame.BuildModeMoveDownSpeedButtonClick(Sender: TObject); procedure TBuildModesEditorFrame.BuildModeMoveDownSpeedButtonClick(Sender: TObject);
@ -205,6 +210,8 @@ begin
inc(i); inc(i);
FillBuildModesGrid; FillBuildModesGrid;
BuildModesStringGrid.Row:=i+1; BuildModesStringGrid.Row:=i+1;
ModesChanged;
end; end;
procedure TBuildModesEditorFrame.BuildModeMoveUpSpeedButtonClick(Sender: TObject); procedure TBuildModesEditorFrame.BuildModeMoveUpSpeedButtonClick(Sender: TObject);
@ -218,6 +225,8 @@ begin
AProject.BuildModes[0].InSession:=false; AProject.BuildModes[0].InSession:=false;
FillBuildModesGrid; FillBuildModesGrid;
BuildModesStringGrid.Row:=i+1; BuildModesStringGrid.Row:=i+1;
ModesChanged;
end; end;
procedure TBuildModesEditorFrame.BuildModesStringGridCheckboxToggled( procedure TBuildModesEditorFrame.BuildModesStringGridCheckboxToggled(
@ -255,6 +264,7 @@ begin
exit; exit;
end; end;
CurMode.InSession:=b; CurMode.InSession:=b;
ModesChanged;
end; end;
end; end;
@ -273,7 +283,7 @@ var
b: Boolean; b: Boolean;
i: Integer; i: Integer;
begin begin
debugln(['TBuildModesForm.BuildModesStringGridValidateEntry Row=',aRow,' Col=',aCol]); //debugln(['TBuildModesForm.BuildModesStringGridValidateEntry Row=',aRow,' Col=',aCol]);
i:=aRow-1; i:=aRow-1;
if (i<0) or (i>=AProject.BuildModes.Count) then exit; if (i<0) or (i>=AProject.BuildModes.Count) then exit;
CurMode:=AProject.BuildModes[i]; CurMode:=AProject.BuildModes[i];
@ -290,6 +300,7 @@ begin
exit; exit;
end; end;
CurMode.InSession:=b; CurMode.InSession:=b;
ModesChanged;
end end
else if aCol=fModeNameCol then else if aCol=fModeNameCol then
begin begin
@ -301,6 +312,7 @@ begin
CurMode.Identifier:=s; CurMode.Identifier:=s;
NewValue:=s; NewValue:=s;
UpdateDialogCaption; UpdateDialogCaption;
ModesChanged;
end; end;
end; end;
@ -367,6 +379,12 @@ begin
Result:='TBuildModesEditorFrame.GetDialogCaption: no project'; Result:='TBuildModesEditorFrame.GetDialogCaption: no project';
end; end;
procedure TBuildModesEditorFrame.ModesChanged;
begin
if ModeMatrixFrame<>nil then
ModeMatrixFrame.UpdateModes;
end;
procedure TBuildModesEditorFrame.UpdateInheritedOptions; procedure TBuildModesEditorFrame.UpdateInheritedOptions;
var var
InhOptionCtrl: TCompilerInheritedOptionsFrame; InhOptionCtrl: TCompilerInheritedOptionsFrame;
@ -450,6 +468,7 @@ begin
finally finally
FSwitchingMode:=false; FSwitchingMode:=false;
end; end;
ModesChanged;
end; end;
procedure TBuildModesEditorFrame.UpdateShowSession; procedure TBuildModesEditorFrame.UpdateShowSession;

View File

@ -1,12 +1,15 @@
inherited CompilerInheritedOptionsFrame: TCompilerInheritedOptionsFrame object CompilerInheritedOptionsFrame: TCompilerInheritedOptionsFrame
Left = 0
Height = 444 Height = 444
Top = 0
Width = 576 Width = 576
ClientHeight = 444 ClientHeight = 444
ClientWidth = 576 ClientWidth = 576
TabOrder = 0 TabOrder = 0
DesignLeft = 957 Visible = False
DesignTop = 308 DesignLeft = 246
object InhNoteLabel: TLabel[0] DesignTop = 162
object InhNoteLabel: TLabel
Left = 0 Left = 0
Height = 16 Height = 16
Top = 0 Top = 0
@ -15,20 +18,20 @@ inherited CompilerInheritedOptionsFrame: TCompilerInheritedOptionsFrame
Caption = 'InhNoteLabel' Caption = 'InhNoteLabel'
ParentColor = False ParentColor = False
end end
object InhTreeView: TTreeView[1] object InhTreeView: TTreeView
Left = 0 Left = 0
Height = 247 Height = 247
Top = 16 Top = 16
Width = 576 Width = 576
Align = alTop Align = alTop
DefaultItemHeight = 17 DefaultItemHeight = 18
ReadOnly = True ReadOnly = True
RightClickSelect = True RightClickSelect = True
TabOrder = 0 TabOrder = 0
OnSelectionChanged = InhTreeViewSelectionChanged OnSelectionChanged = InhTreeViewSelectionChanged
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw] Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
end end
object InhItemMemo: TMemo[2] object InhItemMemo: TMemo
Left = 0 Left = 0
Height = 176 Height = 176
Top = 268 Top = 268
@ -38,7 +41,7 @@ inherited CompilerInheritedOptionsFrame: TCompilerInheritedOptionsFrame
ScrollBars = ssAutoVertical ScrollBars = ssAutoVertical
TabOrder = 1 TabOrder = 1
end end
object InhSplitter: TSplitter[3] object InhSplitter: TSplitter
Cursor = crVSplit Cursor = crVSplit
Left = 0 Left = 0
Height = 5 Height = 5

View File

@ -39,7 +39,8 @@ uses
Classes, SysUtils, LCLProc, FileUtil, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, LCLProc, FileUtil, Forms, Controls, Graphics, Dialogs,
StdCtrls, ComCtrls, ExtCtrls, StdCtrls, ComCtrls, ExtCtrls,
CodeToolsCfgScript, IDEOptionsIntf, IDEImagesIntf, ProjectIntf, CompOptsIntf, CodeToolsCfgScript, IDEOptionsIntf, IDEImagesIntf, ProjectIntf, CompOptsIntf,
Project, PackageDefs, CompilerOptions, LazarusIDEStrConsts, IDEProcs; Project, PackageDefs, ModeMatrixOpts, CompilerOptions,
LazarusIDEStrConsts, IDEProcs;
type type
@ -52,11 +53,14 @@ type
InhTreeView: TTreeView; InhTreeView: TTreeView;
procedure InhTreeViewSelectionChanged(Sender: TObject); procedure InhTreeViewSelectionChanged(Sender: TObject);
private private
FLastOptions: TBaseCompilerOptions;
ImageIndexInherited: Integer; ImageIndexInherited: Integer;
ImageIndexRequired: Integer; ImageIndexRequired: Integer;
ImageIndexPackage: Integer; ImageIndexPackage: Integer;
InheritedChildDatas: TList; // list of PInheritedNodeData InheritedChildDatas: TList; // list of PInheritedNodeData
procedure ClearInheritedTree; procedure ClearInheritedTree;
protected
procedure VisibleChanged; override;
public public
destructor Destroy; override; destructor Destroy; override;
function GetTitle: string; override; function GetTitle: string; override;
@ -65,6 +69,7 @@ type
procedure WriteSettings(AOptions: TAbstractIDEOptions); override; procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure UpdateInheritedTree(CompilerOpts: TBaseCompilerOptions); procedure UpdateInheritedTree(CompilerOpts: TBaseCompilerOptions);
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override; class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
property LastOptions: TBaseCompilerOptions read FLastOptions;
end; end;
implementation implementation
@ -154,7 +159,46 @@ var
SkippedPkgList: TFPList; SkippedPkgList: TFPList;
AProject: TProject; AProject: TProject;
Pkg: TLazPackage; Pkg: TLazPackage;
t: TBuildMatrixGroupType;
procedure AddMatrixGroupNode(Grp: TBuildMatrixGroupType);
begin
AncestorNode := InhTreeView.Items.Add(nil, '');
case Grp of
bmgtEnvironment: AncestorNode.Text:='Environment';
bmgtProject: AncestorNode.Text:='Project';
bmgtSession: AncestorNode.Text:='Project Session';
end;
AncestorNode.ImageIndex := ImageIndexPackage;
AncestorNode.SelectedIndex := AncestorNode.ImageIndex;
end;
procedure AddMatrixGroup(Grp: TBuildMatrixGroupType);
var
CustomOptions: String;
OutDir: String;
begin
AncestorNode := nil;
CustomOptions:='';
OnAppendCustomOption(CompilerOpts,CustomOptions,[Grp]);
if CustomOptions<>'' then begin
AddMatrixGroupNode(Grp);
AddChildNode(liscustomOptions, CustomOptions, icoCustomOptions);
end;
OutDir:='.*';
OnGetOutputDirectoryOverride(CompilerOpts,OutDir,[Grp]);
if OutDir<>'.*' then begin
AddMatrixGroupNode(Grp);
AddChildNode('Output directory', OutDir, icoNone);
end;
if AncestorNode<>nil then
AncestorNode.Expand(true);
end;
begin begin
FLastOptions:=CompilerOpts;
if not Visible then exit;
OptionsList := nil; OptionsList := nil;
//debugln(['TCompilerInheritedOptionsFrame.UpdateInheritedTree START CompilerOpts=',DbgSName(CompilerOpts)]); //debugln(['TCompilerInheritedOptionsFrame.UpdateInheritedTree START CompilerOpts=',DbgSName(CompilerOpts)]);
CompilerOpts.GetInheritedCompilerOptions(OptionsList); CompilerOpts.GetInheritedCompilerOptions(OptionsList);
@ -235,8 +279,7 @@ begin
AncestorNode.Expanded := True; AncestorNode.Expanded := True;
end; end;
OptionsList.Free; OptionsList.Free;
end end else
else
begin begin
InhTreeView.Items.Add(nil, lisNoCompilerOptionsInherited); InhTreeView.Items.Add(nil, lisNoCompilerOptionsInherited);
end; end;
@ -249,6 +292,11 @@ begin
AncestorNode.SelectedIndex := AncestorNode.ImageIndex; AncestorNode.SelectedIndex := AncestorNode.ImageIndex;
end; end;
end; end;
// add matrix options
for t:=low(TBuildMatrixGroupType) to high(TBuildMatrixGroupType) do
AddMatrixGroup(t);
InhTreeView.EndUpdate; InhTreeView.EndUpdate;
finally finally
SkippedPkgList.Free; SkippedPkgList.Free;
@ -284,6 +332,12 @@ begin
InhTreeView.EndUpdate; InhTreeView.EndUpdate;
end; end;
procedure TCompilerInheritedOptionsFrame.VisibleChanged;
begin
inherited VisibleChanged;
if IsVisible and (LastOptions<>nil) then
UpdateInheritedTree(LastOptions);
end;
procedure TCompilerInheritedOptionsFrame.InhTreeViewSelectionChanged(Sender: TObject); procedure TCompilerInheritedOptionsFrame.InhTreeViewSelectionChanged(Sender: TObject);
var var

View File

@ -19,26 +19,14 @@
*************************************************************************** ***************************************************************************
ToDo: ToDo:
- follow active mode
- write options: global, save envopt.xml
- restore options: global, save xml
- rename build mode => update matrix modes and title
- delete build mode => delete column
- add build mode => add column
- project custom options
- show added custom options in project inherited tree
- pkg custom options
- show added custom options in package inherited tree
- pkg out dir
- show OutDir in package inherited tree
- project outdir
- show OutDir in project inherited tree
- ide macro
- warn for syntax errors in ide macro - warn for syntax errors in ide macro
- wiki - ide macro
- load old build macro values into matrix - load old build macro values into matrix
- save matrix options for old build macro values - save matrix options for old build macro values
- easy way to change LCLWidgetType
- wiki
- remove old frame - remove old frame
- remove old macro value classes
} }
unit Compiler_ModeMatrix; unit Compiler_ModeMatrix;
@ -49,7 +37,8 @@ interface
uses uses
Classes, SysUtils, LazFileUtils, LazLogger, KeywordFuncLists, IDEOptionsIntf, Classes, SysUtils, LazFileUtils, LazLogger, KeywordFuncLists, IDEOptionsIntf,
IDEImagesIntf, LResources, Forms, Controls, Graphics, ComCtrls, IDEImagesIntf, LResources, Forms, Controls, Graphics, ComCtrls,
ModeMatrixCtrl, EnvironmentOpts, ModeMatrixOpts, Project, LazarusIDEStrConsts; ModeMatrixCtrl, EnvironmentOpts, ModeMatrixOpts, Project, LazarusIDEStrConsts,
TransferMacros;
type type
@ -89,11 +78,12 @@ type
fOldIDEOptions: TBuildMatrixOptions; fOldIDEOptions: TBuildMatrixOptions;
fOldSharedOptions: TBuildMatrixOptions; fOldSharedOptions: TBuildMatrixOptions;
fOldSessionOptions: TBuildMatrixOptions; fOldSessionOptions: TBuildMatrixOptions;
procedure DoWriteSettings;
procedure MoveRow(Direction: integer); procedure MoveRow(Direction: integer);
procedure UpdateButtons; procedure UpdateButtons;
function AddTarget(StorageGroup: TGroupedMatrixGroup): TGroupedMatrixGroup; function AddTarget(StorageGroup: TGroupedMatrixGroup): TGroupedMatrixGroup;
procedure UpdateModes(UpdateGrid: boolean); protected
procedure UpdateActiveMode; procedure VisibleChanged; override;
public public
constructor Create(TheOwner: TComponent); override; constructor Create(TheOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
@ -103,6 +93,8 @@ type
procedure ReadSettings(AOptions: TAbstractIDEOptions); override; procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override; procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure RestoreSettings(AOptions: TAbstractIDEOptions); override; procedure RestoreSettings(AOptions: TAbstractIDEOptions); override;
procedure UpdateModes(UpdateGrid: boolean = true);
procedure UpdateActiveMode;
public public
property Grid: TGroupedMatrixControl read FGrid; property Grid: TGroupedMatrixControl read FGrid;
property GroupIDE: TGroupedMatrixGroup read FGroupIDE; property GroupIDE: TGroupedMatrixGroup read FGroupIDE;
@ -121,12 +113,15 @@ function IsEqual(Options: TBuildMatrixOptions; StorageGroup: TGroupedMatrixGroup
procedure AssignBuildMatrixOptionsToGroup(Options: TBuildMatrixOptions; procedure AssignBuildMatrixOptionsToGroup(Options: TBuildMatrixOptions;
Matrix: TGroupedMatrix; StorageGroup: TGroupedMatrixGroup); Matrix: TGroupedMatrix; StorageGroup: TGroupedMatrixGroup);
procedure AssignBuildMatrixGroupToOptions(StorageGroup: TGroupedMatrixGroup; procedure AssignBuildMatrixGroupToOptions(StorageGroup: TGroupedMatrixGroup;
Options: TBuildMatrixOptions); Options: TBuildMatrixOptions; InvalidateCompOpts: boolean);
function TargetsPrefix: string; function TargetsPrefix: string;
function AddMatrixTarget(Matrix: TGroupedMatrix; StorageGroup: TGroupedMatrixGroup): TGroupedMatrixGroup; function AddMatrixTarget(Matrix: TGroupedMatrix; StorageGroup: TGroupedMatrixGroup): TGroupedMatrixGroup;
function SplitMatrixMacro(MacroAssignment: string; function SplitMatrixMacro(MacroAssignment: string;
out MacroName, MacroValue: string; ExceptionOnError: boolean): boolean; out MacroName, MacroValue: string; ExceptionOnError: boolean): boolean;
var
ModeMatrixFrame: TCompOptModeMatrix = nil;
implementation implementation
function BuildMatrixOptionTypeCaption(Typ: TBuildMatrixOptionType): string; function BuildMatrixOptionTypeCaption(Typ: TBuildMatrixOptionType): string;
@ -226,7 +221,7 @@ begin
end; end;
procedure AssignBuildMatrixGroupToOptions(StorageGroup: TGroupedMatrixGroup; procedure AssignBuildMatrixGroupToOptions(StorageGroup: TGroupedMatrixGroup;
Options: TBuildMatrixOptions); Options: TBuildMatrixOptions; InvalidateCompOpts: boolean);
var var
GrpIndex: Integer; GrpIndex: Integer;
Target: TGroupedMatrixGroup; Target: TGroupedMatrixGroup;
@ -262,6 +257,8 @@ begin
end; end;
end; end;
end; end;
if InvalidateCompOpts then
IncreaseCompilerParseStamp;
end; end;
function TargetsPrefix: string; function TargetsPrefix: string;
@ -579,6 +576,13 @@ begin
Result:=AddMatrixTarget(Grid.Matrix,StorageGroup); Result:=AddMatrixTarget(Grid.Matrix,StorageGroup);
end; end;
procedure TCompOptModeMatrix.VisibleChanged;
begin
inherited VisibleChanged;
if (not Visible) and (LazProject<>nil) then
DoWriteSettings;
end;
procedure TCompOptModeMatrix.UpdateModes(UpdateGrid: boolean); procedure TCompOptModeMatrix.UpdateModes(UpdateGrid: boolean);
var var
i: Integer; i: Integer;
@ -723,11 +727,25 @@ begin
UpdateButtons; UpdateButtons;
end; end;
procedure TCompOptModeMatrix.DoWriteSettings;
begin
// write IDE options
AssignBuildMatrixGroupToOptions(GroupIDE,
EnvironmentOptions.BuildMatrixOptions, true);
// write Project options
AssignBuildMatrixGroupToOptions(GroupProject,
LazProject.BuildModes.SharedMatrixOptions, true);
// write Session options
AssignBuildMatrixGroupToOptions(GroupSession,
LazProject.BuildModes.SessionMatrixOptions, true);
end;
constructor TCompOptModeMatrix.Create(TheOwner: TComponent); constructor TCompOptModeMatrix.Create(TheOwner: TComponent);
var var
t: TBuildMatrixOptionType; t: TBuildMatrixOptionType;
begin begin
inherited Create(TheOwner); inherited Create(TheOwner);
ModeMatrixFrame:=Self;
fOldIDEOptions:=TBuildMatrixOptions.Create; fOldIDEOptions:=TBuildMatrixOptions.Create;
fOldSharedOptions:=TBuildMatrixOptions.Create; fOldSharedOptions:=TBuildMatrixOptions.Create;
@ -789,6 +807,7 @@ end;
destructor TCompOptModeMatrix.Destroy; destructor TCompOptModeMatrix.Destroy;
begin begin
ModeMatrixFrame:=nil;
FreeAndNil(fOldIDEOptions); FreeAndNil(fOldIDEOptions);
FreeAndNil(fOldSharedOptions); FreeAndNil(fOldSharedOptions);
FreeAndNil(fOldSessionOptions); FreeAndNil(fOldSessionOptions);
@ -857,12 +876,7 @@ begin
CompOptions:=TProjectCompilerOptions(AOptions); CompOptions:=TProjectCompilerOptions(AOptions);
fProject:=CompOptions.LazProject; fProject:=CompOptions.LazProject;
// write IDE options DoWriteSettings;
AssignBuildMatrixGroupToOptions(GroupIDE,EnvironmentOptions.BuildMatrixOptions);
// write Project options
AssignBuildMatrixGroupToOptions(GroupProject,LazProject.BuildModes.SharedMatrixOptions);
// write Session options
AssignBuildMatrixGroupToOptions(GroupSession,LazProject.BuildModes.SessionMatrixOptions);
end; end;
procedure TCompOptModeMatrix.RestoreSettings(AOptions: TAbstractIDEOptions); procedure TCompOptModeMatrix.RestoreSettings(AOptions: TAbstractIDEOptions);
@ -879,6 +893,8 @@ begin
LazProject.BuildModes.SharedMatrixOptions.Assign(fOldSharedOptions); LazProject.BuildModes.SharedMatrixOptions.Assign(fOldSharedOptions);
// write Session options // write Session options
LazProject.BuildModes.SessionMatrixOptions.Assign(fOldSessionOptions); LazProject.BuildModes.SessionMatrixOptions.Assign(fOldSessionOptions);
IncreaseCompilerParseStamp;
end; end;
initialization initialization

View File

@ -28,7 +28,8 @@ interface
uses uses
Classes, SysUtils, math, types, contnrs, Controls, LCLType, LCLIntf, Grids, Classes, SysUtils, math, types, contnrs, Controls, LCLType, LCLIntf, Grids,
Graphics, StdCtrls, Menus, LazLogger, LazConfigStorage, Laz2_XMLCfg, Graphics, StdCtrls, Menus, LazLogger, LazConfigStorage, Laz2_XMLCfg,
FileProcs, KeywordFuncLists, ModeMatrixOpts; FileProcs, KeywordFuncLists,
IDEProcs, ModeMatrixOpts;
const const
DefaultModeMatrixMaxUndo = 100; DefaultModeMatrixMaxUndo = 100;
@ -1178,7 +1179,7 @@ begin
MatRow:=Matrix.Rows[aRow-1]; MatRow:=Matrix.Rows[aRow-1];
if MatRow is TGroupedMatrixValue then begin if MatRow is TGroupedMatrixValue then begin
//debugln(['TGroupedMatrixControl.GetCheckBoxState ',aCol,' ',aRow,' "',Modes[aCol-1],'" ',TGroupedMatrixValue(MatRow).Modes.Text]); //debugln(['TGroupedMatrixControl.GetCheckBoxState ',aCol,' ',aRow,' "',Modes[aCol-1],'" ',TGroupedMatrixValue(MatRow).Modes.Text]);
if TGroupedMatrixValue(MatRow).Modes.IndexOf(Modes[aCol-1].Caption)>=0 if IndexInStringList(TGroupedMatrixValue(MatRow).Modes,cstCaseInsensitive,Modes[aCol-1].Caption)>=0
then begin then begin
aState:=cbChecked; aState:=cbChecked;
//debugln(['TGroupedMatrixControl.GetCheckBoxState ',aCol,' ',aRow,' "',Modes[aCol-1],'" ',TGroupedMatrixValue(MatRow).Modes.Text]); //debugln(['TGroupedMatrixControl.GetCheckBoxState ',aCol,' ',aRow,' "',Modes[aCol-1],'" ',TGroupedMatrixValue(MatRow).Modes.Text]);
@ -1205,7 +1206,7 @@ begin
if assigned(OnSetCheckboxState) then if assigned(OnSetCheckboxState) then
OnSetCheckboxState(Self, aCol, aRow, aState); OnSetCheckboxState(Self, aCol, aRow, aState);
ModeName:=Modes[aCol-1].Caption; ModeName:=Modes[aCol-1].Caption;
i:=ValueRow.Modes.IndexOf(ModeName); i:=IndexInStringList(ValueRow.Modes,cstCaseInsensitive,ModeName);
if (i<0) = (aState=cbUnchecked) then exit; if (i<0) = (aState=cbUnchecked) then exit;
StoreUndo; StoreUndo;
if i>=0 then begin if i>=0 then begin
@ -1443,7 +1444,7 @@ procedure TGroupedMatrixControl.DefaultDrawCell(aCol, aRow: Integer; var aRect:
procedure DrawActiveModeRow(ValueRow: TGroupedMatrixValue); procedure DrawActiveModeRow(ValueRow: TGroupedMatrixValue);
begin begin
if ActiveMode<0 then exit; if ActiveMode<0 then exit;
if ValueRow.Modes.IndexOf(Modes[ActiveMode].Caption)<0 then exit; if IndexInStringList(ValueRow.Modes,cstCaseInsensitive,Modes[ActiveMode].Caption)<0 then exit;
Canvas.GradientFill(Rect(aRect.Left,(aRect.Top+aRect.Bottom) div 2,aRect.Right,aRect.Bottom), Canvas.GradientFill(Rect(aRect.Left,(aRect.Top+aRect.Bottom) div 2,aRect.Right,aRect.Bottom),
Color,ActiveModeColor,gdVertical); Color,ActiveModeColor,gdVertical);
end; end;

View File

@ -4676,7 +4676,8 @@ begin
else else
Application.TaskBarBehavior := tbDefault; Application.TaskBarBehavior := tbDefault;
end else begin end else begin
IDEOptionsDialog.WriteAll(true); // restore // restore
IDEOptionsDialog.WriteAll(true);
end; end;
finally finally
IDEOptionsDialog.Free; IDEOptionsDialog.Free;

View File

@ -46,6 +46,16 @@ const
'IDEMacro' 'IDEMacro'
); );
type
TBuildMatrixGroupType = (
bmgtEnvironment,
bmgtProject,
bmgtSession
);
TBuildMatrixGroupTypes = set of TBuildMatrixGroupType;
const
bmgtAll = [low(TBuildMatrixGroupType)..high(TBuildMatrixGroupType)];
type type
TBuildMatrixOptions = class; TBuildMatrixOptions = class;
@ -68,9 +78,11 @@ type
procedure Assign(Source: TPersistent); override; procedure Assign(Source: TPersistent); override;
constructor Create(aList: TBuildMatrixOptions); constructor Create(aList: TBuildMatrixOptions);
destructor Destroy; override; destructor Destroy; override;
function FitsTarget(const Target: string): boolean;
function FitsMode(const Mode: string): boolean;
property List: TBuildMatrixOptions read FList; property List: TBuildMatrixOptions read FList;
property Targets: string read FTargets write SetTargets; property Targets: string read FTargets write SetTargets;
property Modes: string read FModes write SetModes; // modes separated by line breaks property Modes: string read FModes write SetModes; // modes separated by line breaks, case insensitive
property Typ: TBuildMatrixOptionType read FTyp write SetTyp; property Typ: TBuildMatrixOptionType read FTyp write SetTyp;
property MacroName: string read FMacroName write SetMacroName; property MacroName: string read FMacroName write SetMacroName;
property Value: string read FValue write SetValue; property Value: string read FValue write SetValue;
@ -106,19 +118,28 @@ type
function IndexOf(Option: TBuildMatrixOption): integer; function IndexOf(Option: TBuildMatrixOption): integer;
function Add(Typ: TBuildMatrixOptionType = bmotCustom; Targets: string = '*'): TBuildMatrixOption; function Add(Typ: TBuildMatrixOptionType = bmotCustom; Targets: string = '*'): TBuildMatrixOption;
procedure Delete(Index: integer); procedure Delete(Index: integer);
// equals, modified
property ChangeStep: int64 read FChangeStep; property ChangeStep: int64 read FChangeStep;
procedure IncreaseChangeStep; procedure IncreaseChangeStep;
function Equals(Obj: TObject): boolean; override; function Equals(Obj: TObject): boolean; override;
property OnChanged: TNotifyEvent read FOnChanged write FOnChangesd;
property Modified: boolean read GetModified write SetModified;
// load, save
procedure LoadFromConfig(Cfg: TConfigStorage); procedure LoadFromConfig(Cfg: TConfigStorage);
procedure SaveToConfig(Cfg: TConfigStorage); procedure SaveToConfig(Cfg: TConfigStorage);
procedure LoadFromXMLConfig(Cfg: TXMLConfig; const aPath: string); procedure LoadFromXMLConfig(Cfg: TXMLConfig; const aPath: string);
procedure SaveToXMLConfig(Cfg: TXMLConfig; const aPath: string); procedure SaveToXMLConfig(Cfg: TXMLConfig; const aPath: string);
property OnChanged: TNotifyEvent read FOnChanged write FOnChangesd;
property Modified: boolean read GetModified write SetModified; // queries
procedure AppendCustomOptions(Target, ActiveMode: string; var Options: string);
procedure GetOutputDirectory(Target, ActiveMode: string; var OutDir: string);
end; end;
function BuildMatrixTargetFits(Target, Targets: string): boolean; function BuildMatrixTargetFits(Target, Targets: string): boolean;
function BuildMatrixTargetFitsPattern(Target, Pattern: PChar): boolean; function BuildMatrixTargetFitsPattern(Target, Pattern: PChar): boolean;
function BuildMatrixModeFits(Mode, ModesSeparatedByLineBreaks: string): boolean;
function Str2BuildMatrixOptionType(const s: string): TBuildMatrixOptionType; function Str2BuildMatrixOptionType(const s: string): TBuildMatrixOptionType;
implementation implementation
@ -219,6 +240,28 @@ begin
until false; until false;
end; end;
function BuildMatrixModeFits(Mode, ModesSeparatedByLineBreaks: string): boolean;
var
p: PChar;
m: PChar;
begin
Result:=false;
if Mode='' then exit;
if ModesSeparatedByLineBreaks='' then exit;
p:=PChar(ModesSeparatedByLineBreaks);
while p^<>#0 do begin
while p^ in [#1..#31] do inc(p);
m:=PChar(Mode);
while (UpChars[p^]=UpChars[m^]) and (p^>=' ') do begin
inc(p);
inc(m);
end;
if (m^=#0) and (p^ in [#10,#13,#0]) then
exit(true);
while p^>=' ' do inc(p);
end;
end;
function Str2BuildMatrixOptionType(const s: string): TBuildMatrixOptionType; function Str2BuildMatrixOptionType(const s: string): TBuildMatrixOptionType;
begin begin
for Result:=low(TBuildMatrixOptionType) to high(TBuildMatrixOptionType) do for Result:=low(TBuildMatrixOptionType) to high(TBuildMatrixOptionType) do
@ -384,6 +427,40 @@ begin
Items[i].SaveToXMLConfig(Cfg,aPath+'item'+IntToStr(i+1)+'/'); Items[i].SaveToXMLConfig(Cfg,aPath+'item'+IntToStr(i+1)+'/');
end; end;
procedure TBuildMatrixOptions.AppendCustomOptions(Target, ActiveMode: string;
var Options: string);
var
i: Integer;
Option: TBuildMatrixOption;
Value: String;
begin
for i:=0 to Count-1 do begin
Option:=Items[i];
if Option.Typ<>bmotCustom then continue;
Value:=Trim(Option.Value);
if Value='' then continue;
if not Option.FitsTarget(Target) then continue;
if not Option.FitsMode(ActiveMode) then continue;
if Options<>'' then Options+=' ';
Options+=Value;
end;
end;
procedure TBuildMatrixOptions.GetOutputDirectory(Target, ActiveMode: string;
var OutDir: string);
var
i: Integer;
Option: TBuildMatrixOption;
begin
for i:=0 to Count-1 do begin
Option:=Items[i];
if Option.Typ<>bmotOutDir then continue;
if not Option.FitsTarget(Target) then continue;
if not Option.FitsMode(ActiveMode) then continue;
OutDir:=Option.Value;
end;
end;
{ TBuildMatrixOption } { TBuildMatrixOption }
procedure TBuildMatrixOption.SetMacroName(AValue: string); procedure TBuildMatrixOption.SetMacroName(AValue: string);
@ -451,6 +528,16 @@ begin
inherited Destroy; inherited Destroy;
end; end;
function TBuildMatrixOption.FitsTarget(const Target: string): boolean;
begin
Result:=BuildMatrixTargetFits(Target,Targets);
end;
function TBuildMatrixOption.FitsMode(const Mode: string): boolean;
begin
Result:=BuildMatrixModeFits(Mode,Modes);
end;
function TBuildMatrixOption.Equals(Obj: TObject): boolean; function TBuildMatrixOption.Equals(Obj: TObject): boolean;
var var
Src: TBuildMatrixOption; Src: TBuildMatrixOption;