diff --git a/ide/buildmanager.pas b/ide/buildmanager.pas index c0f12167c6..32353676ba 100644 --- a/ide/buildmanager.pas +++ b/ide/buildmanager.pas @@ -47,7 +47,7 @@ uses EditDefineTree, ProjectResources, MiscOptions, LazConf, EnvironmentOpts, TransferMacros, CompilerOptions, OutputFilter, Compiler, FPCSrcScan, PackageDefs, PackageSystem, Project, ProjectIcon, - BaseBuildManager, ApplicationBundle; + ModeMatrixOpts, BaseBuildManager, ApplicationBundle; type { TBuildManager } @@ -148,6 +148,11 @@ type override; function OnGetBuildMacroValues(Options: TBaseCompilerOptions; 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 constructor Create(AOwner: TComponent); override; destructor Destroy; override; @@ -298,14 +303,20 @@ begin RunCompilerWithOptions:=@OnRunCompilerWithOptions; GetBuildMacroValues:=@OnGetBuildMacroValues; + OnAppendCustomOption:=@AppendMatrixCustomOption; + OnGetOutputDirectoryOverride:=@GetMatrixOutputDirectoryOverride; end; destructor TBuildManager.Destroy; begin + GetBuildMacroValues:=nil; + OnAppendCustomOption:=nil; + OnBackupFileInteractive:=nil; + RunCompilerWithOptions:=nil; + FreeAndNil(FFPCSrcScans); LazConfMacroFunc:=nil; - OnBackupFileInteractive:=nil; FreeAndNil(InputHistories); FreeAndNil(DefaultCfgVars); @@ -2328,6 +2339,59 @@ begin 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, LCLWidgetType: string; ScanFPCSrc: TScanModeFPCSources; Quiet: boolean); diff --git a/ide/compileroptions.pp b/ide/compileroptions.pp index eac0cf2b45..ca417f02f8 100644 --- a/ide/compileroptions.pp +++ b/ide/compileroptions.pp @@ -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; @@ -61,7 +49,8 @@ uses ProjectIntf, MacroIntf, IDEExternToolIntf, SrcEditorIntf, CompOptsIntf, IDEOptionsIntf, // IDE - LazarusIDEStrConsts, IDEProcs, IDEMsgIntf, LazConf, TransferMacros, CompOptsModes; + LazarusIDEStrConsts, IDEProcs, IDEMsgIntf, LazConf, TransferMacros, + ModeMatrixOpts, CompOptsModes; type @@ -686,8 +675,14 @@ function ConvertOptionsToCmdLine(const Switch, OptionStr: string): string; type TGetBuildMacroValues = function(Options: TBaseCompilerOptions; 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 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; const APath: String; const DefaultReasons: TCompileReasons): TCompileReasons; @@ -3867,6 +3862,15 @@ var begin 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) if Assigned(OnLocalSubstitute) then begin diff --git a/ide/frames/buildmodeseditor.pas b/ide/frames/buildmodeseditor.pas index 505afbe790..843e89a02e 100644 --- a/ide/frames/buildmodeseditor.pas +++ b/ide/frames/buildmodeseditor.pas @@ -36,7 +36,7 @@ uses ProjectIntf, IDEImagesIntf, IDEOptionsIntf, CompOptsIntf, PackageDefs, compiler_inherited_options, TransferMacros, PathEditorDlg, Project, PackageSystem, LazarusIDEStrConsts, CompilerOptions, - IDEProcs, BuildModeDiffDlg; + IDEProcs, BuildModeDiffDlg, Compiler_ModeMatrix; type @@ -78,6 +78,7 @@ type procedure DoShowSession; procedure UpdateDialogCaption; function GetDialogCaption: string; + procedure ModesChanged; public constructor Create(TheOwner: TComponent); override; destructor Destroy; override; @@ -154,6 +155,8 @@ begin BuildModesStringGrid.Col:=fModeNameCol; BuildModesStringGrid.Row:=BuildModesStringGrid.RowCount-1; BuildModesStringGrid.EditorMode:=true; + + ModesChanged; end; procedure TBuildModesEditorFrame.BuildModeDeleteSpeedButtonClick(Sender: TObject); @@ -192,6 +195,8 @@ begin Grid.Row:=Grid.RowCount-1 else Grid.Row:=i; + + ModesChanged; end; procedure TBuildModesEditorFrame.BuildModeMoveDownSpeedButtonClick(Sender: TObject); @@ -205,6 +210,8 @@ begin inc(i); FillBuildModesGrid; BuildModesStringGrid.Row:=i+1; + + ModesChanged; end; procedure TBuildModesEditorFrame.BuildModeMoveUpSpeedButtonClick(Sender: TObject); @@ -218,6 +225,8 @@ begin AProject.BuildModes[0].InSession:=false; FillBuildModesGrid; BuildModesStringGrid.Row:=i+1; + + ModesChanged; end; procedure TBuildModesEditorFrame.BuildModesStringGridCheckboxToggled( @@ -255,6 +264,7 @@ begin exit; end; CurMode.InSession:=b; + ModesChanged; end; end; @@ -273,7 +283,7 @@ var b: Boolean; i: Integer; begin - debugln(['TBuildModesForm.BuildModesStringGridValidateEntry Row=',aRow,' Col=',aCol]); + //debugln(['TBuildModesForm.BuildModesStringGridValidateEntry Row=',aRow,' Col=',aCol]); i:=aRow-1; if (i<0) or (i>=AProject.BuildModes.Count) then exit; CurMode:=AProject.BuildModes[i]; @@ -290,6 +300,7 @@ begin exit; end; CurMode.InSession:=b; + ModesChanged; end else if aCol=fModeNameCol then begin @@ -301,6 +312,7 @@ begin CurMode.Identifier:=s; NewValue:=s; UpdateDialogCaption; + ModesChanged; end; end; @@ -367,6 +379,12 @@ begin Result:='TBuildModesEditorFrame.GetDialogCaption: no project'; end; +procedure TBuildModesEditorFrame.ModesChanged; +begin + if ModeMatrixFrame<>nil then + ModeMatrixFrame.UpdateModes; +end; + procedure TBuildModesEditorFrame.UpdateInheritedOptions; var InhOptionCtrl: TCompilerInheritedOptionsFrame; @@ -450,6 +468,7 @@ begin finally FSwitchingMode:=false; end; + ModesChanged; end; procedure TBuildModesEditorFrame.UpdateShowSession; diff --git a/ide/frames/compiler_inherited_options.lfm b/ide/frames/compiler_inherited_options.lfm index 345934c109..e69cfce933 100644 --- a/ide/frames/compiler_inherited_options.lfm +++ b/ide/frames/compiler_inherited_options.lfm @@ -1,12 +1,15 @@ -inherited CompilerInheritedOptionsFrame: TCompilerInheritedOptionsFrame +object CompilerInheritedOptionsFrame: TCompilerInheritedOptionsFrame + Left = 0 Height = 444 + Top = 0 Width = 576 ClientHeight = 444 ClientWidth = 576 TabOrder = 0 - DesignLeft = 957 - DesignTop = 308 - object InhNoteLabel: TLabel[0] + Visible = False + DesignLeft = 246 + DesignTop = 162 + object InhNoteLabel: TLabel Left = 0 Height = 16 Top = 0 @@ -15,20 +18,20 @@ inherited CompilerInheritedOptionsFrame: TCompilerInheritedOptionsFrame Caption = 'InhNoteLabel' ParentColor = False end - object InhTreeView: TTreeView[1] + object InhTreeView: TTreeView Left = 0 Height = 247 Top = 16 Width = 576 Align = alTop - DefaultItemHeight = 17 + DefaultItemHeight = 18 ReadOnly = True RightClickSelect = True TabOrder = 0 OnSelectionChanged = InhTreeViewSelectionChanged Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw] end - object InhItemMemo: TMemo[2] + object InhItemMemo: TMemo Left = 0 Height = 176 Top = 268 @@ -38,7 +41,7 @@ inherited CompilerInheritedOptionsFrame: TCompilerInheritedOptionsFrame ScrollBars = ssAutoVertical TabOrder = 1 end - object InhSplitter: TSplitter[3] + object InhSplitter: TSplitter Cursor = crVSplit Left = 0 Height = 5 diff --git a/ide/frames/compiler_inherited_options.pas b/ide/frames/compiler_inherited_options.pas index c95c6eba28..acac6e660e 100644 --- a/ide/frames/compiler_inherited_options.pas +++ b/ide/frames/compiler_inherited_options.pas @@ -39,7 +39,8 @@ uses Classes, SysUtils, LCLProc, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls, ExtCtrls, CodeToolsCfgScript, IDEOptionsIntf, IDEImagesIntf, ProjectIntf, CompOptsIntf, - Project, PackageDefs, CompilerOptions, LazarusIDEStrConsts, IDEProcs; + Project, PackageDefs, ModeMatrixOpts, CompilerOptions, + LazarusIDEStrConsts, IDEProcs; type @@ -52,11 +53,14 @@ type InhTreeView: TTreeView; procedure InhTreeViewSelectionChanged(Sender: TObject); private + FLastOptions: TBaseCompilerOptions; ImageIndexInherited: Integer; ImageIndexRequired: Integer; ImageIndexPackage: Integer; InheritedChildDatas: TList; // list of PInheritedNodeData procedure ClearInheritedTree; + protected + procedure VisibleChanged; override; public destructor Destroy; override; function GetTitle: string; override; @@ -65,6 +69,7 @@ type procedure WriteSettings(AOptions: TAbstractIDEOptions); override; procedure UpdateInheritedTree(CompilerOpts: TBaseCompilerOptions); class function SupportedOptionsClass: TAbstractIDEOptionsClass; override; + property LastOptions: TBaseCompilerOptions read FLastOptions; end; implementation @@ -154,7 +159,46 @@ var SkippedPkgList: TFPList; AProject: TProject; 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 + FLastOptions:=CompilerOpts; + if not Visible then exit; + OptionsList := nil; //debugln(['TCompilerInheritedOptionsFrame.UpdateInheritedTree START CompilerOpts=',DbgSName(CompilerOpts)]); CompilerOpts.GetInheritedCompilerOptions(OptionsList); @@ -235,8 +279,7 @@ begin AncestorNode.Expanded := True; end; OptionsList.Free; - end - else + end else begin InhTreeView.Items.Add(nil, lisNoCompilerOptionsInherited); end; @@ -249,6 +292,11 @@ begin AncestorNode.SelectedIndex := AncestorNode.ImageIndex; end; end; + + // add matrix options + for t:=low(TBuildMatrixGroupType) to high(TBuildMatrixGroupType) do + AddMatrixGroup(t); + InhTreeView.EndUpdate; finally SkippedPkgList.Free; @@ -284,6 +332,12 @@ begin InhTreeView.EndUpdate; end; +procedure TCompilerInheritedOptionsFrame.VisibleChanged; +begin + inherited VisibleChanged; + if IsVisible and (LastOptions<>nil) then + UpdateInheritedTree(LastOptions); +end; procedure TCompilerInheritedOptionsFrame.InhTreeViewSelectionChanged(Sender: TObject); var diff --git a/ide/frames/compiler_modematrix.pas b/ide/frames/compiler_modematrix.pas index 860fdc26f4..f53c2a21e4 100644 --- a/ide/frames/compiler_modematrix.pas +++ b/ide/frames/compiler_modematrix.pas @@ -19,26 +19,14 @@ *************************************************************************** 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 - - wiki + - ide macro - load old build macro values into matrix - save matrix options for old build macro values + - easy way to change LCLWidgetType + - wiki - remove old frame + - remove old macro value classes } unit Compiler_ModeMatrix; @@ -49,7 +37,8 @@ interface uses Classes, SysUtils, LazFileUtils, LazLogger, KeywordFuncLists, IDEOptionsIntf, IDEImagesIntf, LResources, Forms, Controls, Graphics, ComCtrls, - ModeMatrixCtrl, EnvironmentOpts, ModeMatrixOpts, Project, LazarusIDEStrConsts; + ModeMatrixCtrl, EnvironmentOpts, ModeMatrixOpts, Project, LazarusIDEStrConsts, + TransferMacros; type @@ -89,11 +78,12 @@ type fOldIDEOptions: TBuildMatrixOptions; fOldSharedOptions: TBuildMatrixOptions; fOldSessionOptions: TBuildMatrixOptions; + procedure DoWriteSettings; procedure MoveRow(Direction: integer); procedure UpdateButtons; function AddTarget(StorageGroup: TGroupedMatrixGroup): TGroupedMatrixGroup; - procedure UpdateModes(UpdateGrid: boolean); - procedure UpdateActiveMode; + protected + procedure VisibleChanged; override; public constructor Create(TheOwner: TComponent); override; destructor Destroy; override; @@ -103,6 +93,8 @@ type procedure ReadSettings(AOptions: TAbstractIDEOptions); override; procedure WriteSettings(AOptions: TAbstractIDEOptions); override; procedure RestoreSettings(AOptions: TAbstractIDEOptions); override; + procedure UpdateModes(UpdateGrid: boolean = true); + procedure UpdateActiveMode; public property Grid: TGroupedMatrixControl read FGrid; property GroupIDE: TGroupedMatrixGroup read FGroupIDE; @@ -121,12 +113,15 @@ function IsEqual(Options: TBuildMatrixOptions; StorageGroup: TGroupedMatrixGroup procedure AssignBuildMatrixOptionsToGroup(Options: TBuildMatrixOptions; Matrix: TGroupedMatrix; StorageGroup: TGroupedMatrixGroup); procedure AssignBuildMatrixGroupToOptions(StorageGroup: TGroupedMatrixGroup; - Options: TBuildMatrixOptions); + Options: TBuildMatrixOptions; InvalidateCompOpts: boolean); function TargetsPrefix: string; function AddMatrixTarget(Matrix: TGroupedMatrix; StorageGroup: TGroupedMatrixGroup): TGroupedMatrixGroup; function SplitMatrixMacro(MacroAssignment: string; out MacroName, MacroValue: string; ExceptionOnError: boolean): boolean; +var + ModeMatrixFrame: TCompOptModeMatrix = nil; + implementation function BuildMatrixOptionTypeCaption(Typ: TBuildMatrixOptionType): string; @@ -226,7 +221,7 @@ begin end; procedure AssignBuildMatrixGroupToOptions(StorageGroup: TGroupedMatrixGroup; - Options: TBuildMatrixOptions); + Options: TBuildMatrixOptions; InvalidateCompOpts: boolean); var GrpIndex: Integer; Target: TGroupedMatrixGroup; @@ -262,6 +257,8 @@ begin end; end; end; + if InvalidateCompOpts then + IncreaseCompilerParseStamp; end; function TargetsPrefix: string; @@ -579,6 +576,13 @@ begin Result:=AddMatrixTarget(Grid.Matrix,StorageGroup); end; +procedure TCompOptModeMatrix.VisibleChanged; +begin + inherited VisibleChanged; + if (not Visible) and (LazProject<>nil) then + DoWriteSettings; +end; + procedure TCompOptModeMatrix.UpdateModes(UpdateGrid: boolean); var i: Integer; @@ -723,11 +727,25 @@ begin UpdateButtons; 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); var t: TBuildMatrixOptionType; begin inherited Create(TheOwner); + ModeMatrixFrame:=Self; fOldIDEOptions:=TBuildMatrixOptions.Create; fOldSharedOptions:=TBuildMatrixOptions.Create; @@ -789,6 +807,7 @@ end; destructor TCompOptModeMatrix.Destroy; begin + ModeMatrixFrame:=nil; FreeAndNil(fOldIDEOptions); FreeAndNil(fOldSharedOptions); FreeAndNil(fOldSessionOptions); @@ -857,12 +876,7 @@ begin CompOptions:=TProjectCompilerOptions(AOptions); fProject:=CompOptions.LazProject; - // write IDE options - AssignBuildMatrixGroupToOptions(GroupIDE,EnvironmentOptions.BuildMatrixOptions); - // write Project options - AssignBuildMatrixGroupToOptions(GroupProject,LazProject.BuildModes.SharedMatrixOptions); - // write Session options - AssignBuildMatrixGroupToOptions(GroupSession,LazProject.BuildModes.SessionMatrixOptions); + DoWriteSettings; end; procedure TCompOptModeMatrix.RestoreSettings(AOptions: TAbstractIDEOptions); @@ -879,6 +893,8 @@ begin LazProject.BuildModes.SharedMatrixOptions.Assign(fOldSharedOptions); // write Session options LazProject.BuildModes.SessionMatrixOptions.Assign(fOldSessionOptions); + + IncreaseCompilerParseStamp; end; initialization diff --git a/ide/frames/modematrixctrl.pas b/ide/frames/modematrixctrl.pas index a02c078435..40cf76f277 100644 --- a/ide/frames/modematrixctrl.pas +++ b/ide/frames/modematrixctrl.pas @@ -28,7 +28,8 @@ interface uses Classes, SysUtils, math, types, contnrs, Controls, LCLType, LCLIntf, Grids, Graphics, StdCtrls, Menus, LazLogger, LazConfigStorage, Laz2_XMLCfg, - FileProcs, KeywordFuncLists, ModeMatrixOpts; + FileProcs, KeywordFuncLists, + IDEProcs, ModeMatrixOpts; const DefaultModeMatrixMaxUndo = 100; @@ -1178,7 +1179,7 @@ begin MatRow:=Matrix.Rows[aRow-1]; if MatRow is TGroupedMatrixValue then begin //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 aState:=cbChecked; //debugln(['TGroupedMatrixControl.GetCheckBoxState ',aCol,' ',aRow,' "',Modes[aCol-1],'" ',TGroupedMatrixValue(MatRow).Modes.Text]); @@ -1205,7 +1206,7 @@ begin if assigned(OnSetCheckboxState) then OnSetCheckboxState(Self, aCol, aRow, aState); ModeName:=Modes[aCol-1].Caption; - i:=ValueRow.Modes.IndexOf(ModeName); + i:=IndexInStringList(ValueRow.Modes,cstCaseInsensitive,ModeName); if (i<0) = (aState=cbUnchecked) then exit; StoreUndo; if i>=0 then begin @@ -1443,7 +1444,7 @@ procedure TGroupedMatrixControl.DefaultDrawCell(aCol, aRow: Integer; var aRect: procedure DrawActiveModeRow(ValueRow: TGroupedMatrixValue); begin 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), Color,ActiveModeColor,gdVertical); end; diff --git a/ide/main.pp b/ide/main.pp index b6fb4d18da..0df47a2480 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -4676,7 +4676,8 @@ begin else Application.TaskBarBehavior := tbDefault; end else begin - IDEOptionsDialog.WriteAll(true); // restore + // restore + IDEOptionsDialog.WriteAll(true); end; finally IDEOptionsDialog.Free; diff --git a/ide/modematrixopts.pas b/ide/modematrixopts.pas index 2c01fb82ec..313d2d0e0c 100644 --- a/ide/modematrixopts.pas +++ b/ide/modematrixopts.pas @@ -46,6 +46,16 @@ const 'IDEMacro' ); +type + TBuildMatrixGroupType = ( + bmgtEnvironment, + bmgtProject, + bmgtSession + ); + TBuildMatrixGroupTypes = set of TBuildMatrixGroupType; +const + bmgtAll = [low(TBuildMatrixGroupType)..high(TBuildMatrixGroupType)]; + type TBuildMatrixOptions = class; @@ -68,9 +78,11 @@ type procedure Assign(Source: TPersistent); override; constructor Create(aList: TBuildMatrixOptions); destructor Destroy; override; + function FitsTarget(const Target: string): boolean; + function FitsMode(const Mode: string): boolean; property List: TBuildMatrixOptions read FList; 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 MacroName: string read FMacroName write SetMacroName; property Value: string read FValue write SetValue; @@ -106,19 +118,28 @@ type function IndexOf(Option: TBuildMatrixOption): integer; function Add(Typ: TBuildMatrixOptionType = bmotCustom; Targets: string = '*'): TBuildMatrixOption; procedure Delete(Index: integer); + + // equals, modified property ChangeStep: int64 read FChangeStep; procedure IncreaseChangeStep; 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 SaveToConfig(Cfg: TConfigStorage); procedure LoadFromXMLConfig(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; function BuildMatrixTargetFits(Target, Targets: string): boolean; function BuildMatrixTargetFitsPattern(Target, Pattern: PChar): boolean; +function BuildMatrixModeFits(Mode, ModesSeparatedByLineBreaks: string): boolean; function Str2BuildMatrixOptionType(const s: string): TBuildMatrixOptionType; implementation @@ -219,6 +240,28 @@ begin until false; 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; begin for Result:=low(TBuildMatrixOptionType) to high(TBuildMatrixOptionType) do @@ -384,6 +427,40 @@ begin Items[i].SaveToXMLConfig(Cfg,aPath+'item'+IntToStr(i+1)+'/'); 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 } procedure TBuildMatrixOption.SetMacroName(AValue: string); @@ -451,6 +528,16 @@ begin inherited Destroy; 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; var Src: TBuildMatrixOption;