IDE: replaced compiler options Macro values with Additions and Overrides

git-svn-id: trunk@41570 -
This commit is contained in:
mattias 2013-06-06 21:34:39 +00:00
parent 5c8c3c59df
commit e9931a214f
11 changed files with 65 additions and 921 deletions

2
.gitattributes vendored
View File

@ -5089,8 +5089,6 @@ ide/ideinfodlg.lfm svneol=native#text/plain
ide/ideinfodlg.pas svneol=native#text/plain
ide/ideinfoneedbuild.lfm svneol=native#text/plain
ide/ideinfoneedbuild.pas svneol=native#text/plain
ide/idemacrovalues.lfm svneol=native#text/plain
ide/idemacrovalues.pas svneol=native#text/plain
ide/ideminilibc.pas svneol=native#text/plain
ide/ideoptiondefs.pas svneol=native#text/pascal
ide/ideoptionsdlg.lfm svneol=native#text/plain

View File

@ -300,9 +300,6 @@ const
CompilerOptionsOther = 0800;
CompilerOptionsConditional = 0900; // IDE Macros
CompilerOptionsAdditionsAndOverrides = 1000;
{$IFNDEF EnableModeMatrix}
CompilerOptionsMacroValues = 1001;
{$ENDIF}
CompilerOptionsInherited = 1100;
CompilerOptionsCompilation = 1200;

View File

@ -2209,74 +2209,21 @@ function TBuildManager.OnGetBuildMacroValues(Options: TBaseCompilerOptions;
end;
end;
{$IFNDEF EnableModeMatrix}
function GetProjectMacroValues: TCTCfgScriptVariables;
var
MainMacroValues: TProjectBuildMacros;
i: Integer;
aName: String;
aValue: String;
begin
// return the values of the active project
if (Project1<>nil) and (Project1.MacroValues<>nil) then begin
MainMacroValues:=Project1.MacroValues;
Result:=MainMacroValues.CfgVars;
if MainMacroValues.CfgVarsBuildMacroStamp=BuildMacroChangeStamp then
exit;
// rebuild main macros
Result.Clear;
for i:=0 to MainMacroValues.Count-1 do begin
aName:=MainMacroValues.Names[i];
aValue:=MainMacroValues.ValueFromIndex(i);
//debugln(['TBuildManager.OnGetBuildMacroValues project override: ',aName,'="',aValue,'"']);
Result.Define(PChar(aName),aValue);
end;
{$IFDEF VerboseBuildMacros}
Values.WriteDebugReport('OnGetBuildMacroValues project overrides');
{$ENDIF}
MainMacroValues.CfgVarsBuildMacroStamp:=BuildMacroChangeStamp;
end else if DefaultCfgVars<>nil then begin
// there is no project => use defaults
Result:=DefaultCfgVars;
if DefaultCfgVarsBuildMacroStamp=BuildMacroChangeStamp then
exit;
// rebuild main macros
Result.Clear;
DefaultCfgVarsBuildMacroStamp:=BuildMacroChangeStamp;
end else
exit(nil);
SetCmdLineOverrides(Result);
end;
{$ENDIF}
procedure SetProjectMacroValues(Vars: TCTCfgScriptVariables);
var
{$IFDEF EnableModeMatrix}
Target: String;
{$ELSE}
Values: TCTCfgScriptVariables;
{$ENDIF}
begin
{$IFDEF EnableModeMatrix}
Target:=GetModeMatrixTarget(Options);
if EnvironmentOptions<>nil then
ApplyBuildMatrixMacros(EnvironmentOptions.BuildMatrixOptions,Target,Vars);
if (Project1<>nil) and (Project1.BuildModes<>nil) then
begin
ApplyBuildMatrixMacros(Project1.BuildModes.SharedMatrixOptions,Target,Vars);
ApplyBuildMatrixMacros(Project1.BuildModes.SessionMatrixOptions,Target,Vars);
end;
SetCmdLineOverrides(Vars);
{$IFDEF VerboseBuildMacros}
Vars.WriteDebugReport('OnGetBuildMacroValues after applying project values');
{$ENDIF}
{$ELSE}
Values:=GetProjectMacroValues;
if Values=nil then exit;
{$IFDEF VerboseBuildMacros}
Values.WriteDebugReport('OnGetBuildMacroValues project values');
{$ENDIF}
Vars.AddOverrides(Values);
Target:=GetModeMatrixTarget(Options);
if EnvironmentOptions<>nil then
ApplyBuildMatrixMacros(EnvironmentOptions.BuildMatrixOptions,Target,Vars);
if (Project1<>nil) and (Project1.BuildModes<>nil) then
begin
ApplyBuildMatrixMacros(Project1.BuildModes.SharedMatrixOptions,Target,Vars);
ApplyBuildMatrixMacros(Project1.BuildModes.SessionMatrixOptions,Target,Vars);
end;
SetCmdLineOverrides(Vars);
{$IFDEF VerboseBuildMacros}
Vars.WriteDebugReport('OnGetBuildMacroValues after applying project values');
{$ENDIF}
SetDefaults(Vars);
end;

View File

@ -1,4 +1,4 @@
object CompOptModeMatrix: TCompOptModeMatrix
object CompOptModeMatrixFrame: TCompOptModeMatrixFrame
Left = 0
Height = 429
Top = 0
@ -26,7 +26,7 @@ object CompOptModeMatrix: TCompOptModeMatrix
ShowHint = True
end
object BMMMoveDownToolButton: TToolButton
Left = 26
Left = 24
Top = 2
Caption = 'Down'
OnClick = BMMMoveDownToolButtonClick
@ -34,7 +34,7 @@ object CompOptModeMatrix: TCompOptModeMatrix
ShowHint = True
end
object BMMUndoToolButton: TToolButton
Left = 80
Left = 74
Top = 2
Caption = 'Undo'
OnClick = BMMUndoToolButtonClick
@ -42,7 +42,7 @@ object CompOptModeMatrix: TCompOptModeMatrix
ShowHint = True
end
object BMMRedoToolButton: TToolButton
Left = 121
Left = 111
Top = 2
Caption = 'Redo'
OnClick = BMMRedoToolButtonClick
@ -50,7 +50,7 @@ object CompOptModeMatrix: TCompOptModeMatrix
ShowHint = True
end
object BMMDeleteToolButton: TToolButton
Left = 226
Left = 210
Top = 2
Caption = 'Delete'
OnClick = BMMDeleteToolButtonClick
@ -58,28 +58,28 @@ object CompOptModeMatrix: TCompOptModeMatrix
ShowHint = True
end
object ToolButton1: TToolButton
Left = 70
Left = 64
Top = 2
Width = 10
Caption = 'ToolButton1'
Style = tbsSeparator
end
object ToolButton2: TToolButton
Left = 161
Left = 148
Top = 2
Width = 10
Caption = 'ToolButton2'
Style = tbsSeparator
end
object ToolButton3: TToolButton
Left = 216
Left = 200
Top = 2
Width = 10
Caption = 'ToolButton3'
Style = tbsSeparator
end
object BMMAddToolButton: TToolButton
Left = 171
Left = 158
Top = 2
Caption = 'Add'
DropdownMenu = BMMAddPopupMenu

View File

@ -24,10 +24,7 @@
Options frame for build mode matrix options.
ToDo:
- wiki
- undo: combine changes while editing a cell
- remove old frame (idemacrovalues.pas,lfm)
- remove ifdefs
}
unit Compiler_ModeMatrix;
@ -43,9 +40,9 @@ uses
type
{ TCompOptModeMatrix }
{ TCompOptModeMatrixFrame }
TCompOptModeMatrix = class(TAbstractIDEOptionsEditor)
TCompOptModeMatrixFrame = class(TAbstractIDEOptionsEditor)
BMMatrixToolBar: TToolBar;
BMMDeleteToolButton: TToolButton;
BMMMoveDownToolButton: TToolButton;
@ -149,7 +146,7 @@ function BuildMatrixOptionTypeHint(Typ: TBuildMatrixOptionType): string;
function BuildMatrixDefaultValue(Typ: TBuildMatrixOptionType): string;
var
ModeMatrixFrame: TCompOptModeMatrix = nil;
ModeMatrixFrame: TCompOptModeMatrixFrame = nil;
implementation
@ -382,14 +379,14 @@ end;
{$R *.lfm}
{ TCompOptModeMatrix }
{ TCompOptModeMatrixFrame }
procedure TCompOptModeMatrix.GridSelection(Sender: TObject; aCol, aRow: Integer);
procedure TCompOptModeMatrixFrame.GridSelection(Sender: TObject; aCol, aRow: Integer);
begin
UpdateButtons;
end;
procedure TCompOptModeMatrix.GridSetEditText(Sender: TObject; ACol,
procedure TCompOptModeMatrixFrame.GridSetEditText(Sender: TObject; ACol,
ARow: Integer; const Value: string);
var
MatRow: TGroupedMatrixRow;
@ -415,7 +412,7 @@ begin
end;
end;
procedure TCompOptModeMatrix.GridShowHint(Sender: TObject; HintInfo: PHintInfo);
procedure TCompOptModeMatrixFrame.GridShowHint(Sender: TObject; HintInfo: PHintInfo);
var
aCol: Longint;
aRow: Longint;
@ -456,7 +453,7 @@ begin
HintInfo^.HintStr:=h;
end;
procedure TCompOptModeMatrix.OnAddMacroMenuItemClick(Sender: TObject);
procedure TCompOptModeMatrixFrame.OnAddMacroMenuItemClick(Sender: TObject);
var
ValueMenuItem: TMenuItem;
MacroMenuItem: TMenuItem;
@ -470,24 +467,24 @@ begin
CreateNewOption(BuildMatrixOptionTypeCaption(bmotIDEMacro),MacroName+':='+Value);
end;
procedure TCompOptModeMatrix.BMMNewCustomOptionMenuItemClick(Sender: TObject);
procedure TCompOptModeMatrixFrame.BMMNewCustomOptionMenuItemClick(Sender: TObject);
begin
CreateNewOption(BuildMatrixOptionTypeCaption(bmotCustom),BuildMatrixDefaultValue(bmotCustom));
end;
procedure TCompOptModeMatrix.BMMUndoToolButtonClick(Sender: TObject);
procedure TCompOptModeMatrixFrame.BMMUndoToolButtonClick(Sender: TObject);
begin
Grid.Undo;
UpdateGridStorageGroups;
UpdateButtons;
end;
procedure TCompOptModeMatrix.BMMNewTargetMenuItemClick(Sender: TObject);
procedure TCompOptModeMatrixFrame.BMMNewTargetMenuItemClick(Sender: TObject);
begin
CreateNewTarget;
end;
procedure TCompOptModeMatrix.BMMAddToolButtonClick(Sender: TObject);
procedure TCompOptModeMatrixFrame.BMMAddToolButtonClick(Sender: TObject);
var
p: TPoint;
begin
@ -495,13 +492,13 @@ begin
BMMAddPopupMenu.PopUp(p.x,p.y);
end;
procedure TCompOptModeMatrix.GridEditingDone(Sender: TObject);
procedure TCompOptModeMatrixFrame.GridEditingDone(Sender: TObject);
begin
//DebugLn(['TFrame1.GridEditingDone ']);
UpdateButtons;
end;
procedure TCompOptModeMatrix.GridGetCellHightlightColor(Sender: TObject; aCol,
procedure TCompOptModeMatrixFrame.GridGetCellHightlightColor(Sender: TObject; aCol,
aRow: integer; var aColor: TColor);
var
MatRow: TGroupedMatrixRow;
@ -532,19 +529,19 @@ begin
end;
end;
procedure TCompOptModeMatrix.BMMRedoToolButtonClick(Sender: TObject);
procedure TCompOptModeMatrixFrame.BMMRedoToolButtonClick(Sender: TObject);
begin
Grid.Redo;
UpdateGridStorageGroups;
UpdateButtons;
end;
procedure TCompOptModeMatrix.BMMMoveUpToolButtonClick(Sender: TObject);
procedure TCompOptModeMatrixFrame.BMMMoveUpToolButtonClick(Sender: TObject);
begin
MoveRow(-1);
end;
procedure TCompOptModeMatrix.BMMAddPopupMenuPopup(Sender: TObject);
procedure TCompOptModeMatrixFrame.BMMAddPopupMenuPopup(Sender: TObject);
var
i: Integer;
Pkg: TLazPackage;
@ -591,22 +588,22 @@ begin
end;
end;
procedure TCompOptModeMatrix.BMMNewIDEMacroMenuItemClick(Sender: TObject);
procedure TCompOptModeMatrixFrame.BMMNewIDEMacroMenuItemClick(Sender: TObject);
begin
CreateNewOption(BuildMatrixOptionTypeCaption(bmotIDEMacro),BuildMatrixDefaultValue(bmotIDEMacro));
end;
procedure TCompOptModeMatrix.BMMNewOutDirMenuItemClick(Sender: TObject);
procedure TCompOptModeMatrixFrame.BMMNewOutDirMenuItemClick(Sender: TObject);
begin
CreateNewOption(BuildMatrixOptionTypeCaption(bmotOutDir),BuildMatrixDefaultValue(bmotOutDir));
end;
procedure TCompOptModeMatrix.BMMMoveDownToolButtonClick(Sender: TObject);
procedure TCompOptModeMatrixFrame.BMMMoveDownToolButtonClick(Sender: TObject);
begin
MoveRow(1);
end;
procedure TCompOptModeMatrix.BMMDeleteToolButtonClick(Sender: TObject);
procedure TCompOptModeMatrixFrame.BMMDeleteToolButtonClick(Sender: TObject);
var
aRow: Integer;
MatRow: TGroupedMatrixRow;
@ -622,7 +619,7 @@ begin
UpdateButtons;
end;
procedure TCompOptModeMatrix.UpdateButtons;
procedure TCompOptModeMatrixFrame.UpdateButtons;
var
aRow: Integer;
MatRow: TGroupedMatrixRow;
@ -646,13 +643,13 @@ begin
and (MatRow.GetNextSkipChildren<>nil);
end;
function TCompOptModeMatrix.AddTarget(StorageGroup: TGroupedMatrixGroup
function TCompOptModeMatrixFrame.AddTarget(StorageGroup: TGroupedMatrixGroup
): TGroupedMatrixGroup;
begin
Result:=AddMatrixTarget(Grid.Matrix,StorageGroup);
end;
procedure TCompOptModeMatrix.CreateNewOption(aTyp, aValue: string);
procedure TCompOptModeMatrixFrame.CreateNewOption(aTyp, aValue: string);
var
aRow: Integer;
MatRow: TGroupedMatrixRow;
@ -705,7 +702,7 @@ begin
UpdateButtons;
end;
procedure TCompOptModeMatrix.CreateNewTarget;
procedure TCompOptModeMatrixFrame.CreateNewTarget;
var
aRow: Integer;
MatRow: TGroupedMatrixRow;
@ -743,7 +740,7 @@ begin
UpdateButtons;
end;
function TCompOptModeMatrix.GetCaptionValue(aCaption, aPattern: string): string;
function TCompOptModeMatrixFrame.GetCaptionValue(aCaption, aPattern: string): string;
var
p: SizeInt;
begin
@ -753,7 +750,7 @@ begin
Result:=copy(aCaption,p,length(aCaption)-length(aPattern)+2);
end;
procedure TCompOptModeMatrix.UpdateEnabledModesInGrid(
procedure TCompOptModeMatrixFrame.UpdateEnabledModesInGrid(
Options: TBuildMatrixOptions; StorageGroup: TGroupedMatrixGroup;
var HasChanged: boolean);
// update enabled modes in grid
@ -788,7 +785,7 @@ begin
end;
end;
procedure TCompOptModeMatrix.UpdateGridStorageGroups;
procedure TCompOptModeMatrixFrame.UpdateGridStorageGroups;
var
i: Integer;
MatRow: TGroupedMatrixRow;
@ -815,14 +812,14 @@ begin
raise Exception.Create('grid lost the session storage group');
end;
procedure TCompOptModeMatrix.VisibleChanged;
procedure TCompOptModeMatrixFrame.VisibleChanged;
begin
inherited VisibleChanged;
if (not Visible) and (LazProject<>nil) then
DoWriteSettings;
end;
procedure TCompOptModeMatrix.UpdateModes(UpdateGrid: boolean);
procedure TCompOptModeMatrixFrame.UpdateModes(UpdateGrid: boolean);
var
i: Integer;
BuildMode: TProjectBuildMode;
@ -872,7 +869,7 @@ begin
Grid.Invalidate;
end;
procedure TCompOptModeMatrix.UpdateActiveMode;
procedure TCompOptModeMatrixFrame.UpdateActiveMode;
var
i: Integer;
begin
@ -882,7 +879,7 @@ begin
Grid.ActiveMode:=i;
end;
procedure TCompOptModeMatrix.MoveRow(Direction: integer);
procedure TCompOptModeMatrixFrame.MoveRow(Direction: integer);
var
MatRow: TGroupedMatrixRow;
aRow: Integer;
@ -980,7 +977,7 @@ begin
UpdateButtons;
end;
procedure TCompOptModeMatrix.DoWriteSettings;
procedure TCompOptModeMatrixFrame.DoWriteSettings;
begin
// write IDE options
AssignBuildMatrixGroupToOptions(GroupIDE,
@ -993,7 +990,7 @@ begin
LazProject.BuildModes.SessionMatrixOptions,true);
end;
constructor TCompOptModeMatrix.Create(TheOwner: TComponent);
constructor TCompOptModeMatrixFrame.Create(TheOwner: TComponent);
var
t: TBuildMatrixOptionType;
begin
@ -1067,7 +1064,7 @@ begin
UpdateButtons;
end;
destructor TCompOptModeMatrix.Destroy;
destructor TCompOptModeMatrixFrame.Destroy;
begin
ModeMatrixFrame:=nil;
FreeAndNil(fOldIDEOptions);
@ -1076,22 +1073,22 @@ begin
inherited Destroy;
end;
function TCompOptModeMatrix.GetTitle: String;
function TCompOptModeMatrixFrame.GetTitle: String;
begin
Result:=lisMMAdditionsAndOverrides;
end;
procedure TCompOptModeMatrix.Setup(ADialog: TAbstractOptionsEditorDialog);
procedure TCompOptModeMatrixFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
begin
//debugln(['TCompOptModeMatrix.Setup ',DbgSName(ADialog)]);
end;
class function TCompOptModeMatrix.SupportedOptionsClass: TAbstractIDEOptionsClass;
class function TCompOptModeMatrixFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
begin
Result := TProjectCompilerOptions;
end;
procedure TCompOptModeMatrix.ReadSettings(AOptions: TAbstractIDEOptions);
procedure TCompOptModeMatrixFrame.ReadSettings(AOptions: TAbstractIDEOptions);
var
CompOptions: TProjectCompilerOptions;
begin
@ -1129,7 +1126,7 @@ begin
Grid.Col:=Grid.FixedCols;
end;
procedure TCompOptModeMatrix.WriteSettings(AOptions: TAbstractIDEOptions);
procedure TCompOptModeMatrixFrame.WriteSettings(AOptions: TAbstractIDEOptions);
var
CompOptions: TProjectCompilerOptions;
begin
@ -1140,7 +1137,7 @@ begin
DoWriteSettings;
end;
procedure TCompOptModeMatrix.RestoreSettings(AOptions: TAbstractIDEOptions);
procedure TCompOptModeMatrixFrame.RestoreSettings(AOptions: TAbstractIDEOptions);
var
CompOptions: TProjectCompilerOptions;
begin
@ -1159,10 +1156,8 @@ begin
end;
initialization
{$IFDEF EnableModeMatrix}
RegisterIDEOptionsEditor(GroupCompiler, TCompOptModeMatrix,
RegisterIDEOptionsEditor(GroupCompiler, TCompOptModeMatrixFrame,
CompilerOptionsAdditionsAndOverrides);
{$ENDIF}
end.

View File

@ -287,7 +287,7 @@ end;
procedure TCompilerPathOptionsFrame.LCLWidgetTypeLabelClick(Sender: TObject);
begin
FDialog.OpenEditor(GroupCompiler,{$IFDEF EnableModeMatrix}CompilerOptionsAdditionsAndOverrides{$ELSE}CompilerOptionsMacroValues{$ENDIF});
FDialog.OpenEditor(GroupCompiler,CompilerOptionsAdditionsAndOverrides);
end;
procedure TCompilerPathOptionsFrame.LCLWidgetTypeLabelMouseEnter(Sender: TObject);

View File

@ -1,44 +0,0 @@
object IdeMacroValuesFrame: TIdeMacroValuesFrame
Left = 0
Height = 421
Top = 0
Width = 550
ClientHeight = 421
ClientWidth = 550
TabOrder = 0
DesignLeft = 460
DesignTop = 117
object IdeMacroValuesGroupBox: TGroupBox
Left = 6
Height = 409
Top = 6
Width = 538
Align = alClient
BorderSpacing.Around = 6
Caption = 'IdeMacroValuesGroupBox'
ClientHeight = 389
ClientWidth = 532
TabOrder = 0
object IdeMacroValuesStringGrid: TStringGrid
Left = 0
Height = 389
Top = 0
Width = 532
Align = alClient
AutoFillColumns = True
ColCount = 2
DefaultColWidth = 120
FixedCols = 0
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goAlwaysShowEditor, goSmoothScroll]
RowCount = 2
TabOrder = 0
OnEditingDone = IdeMacroValuesStringGridEditingDone
OnSelectEditor = IdeMacroValuesStringGridSelectEditor
OnSelection = IdeMacroValuesStringGridSelection
ColWidths = (
263
263
)
end
end
end

View File

@ -1,361 +0,0 @@
{
***************************************************************************
* *
* This source is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This code is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details. *
* *
* A copy of the GNU General Public License is available on the World *
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
* obtain it by writing to the Free Software Foundation, *
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
***************************************************************************
Abstract:
The frame for 'IDE macro values' on the compiler options.
Allows to add/delete/edit values for existing macros.
It does not allow to define new IDE macros, only values.
}
unit IdeMacroValues;
{$mode objfpc}{$H+}
interface
uses
Math, Classes, SysUtils, LCLProc, Controls, FileUtil, Forms,
Grids, Graphics, Menus, ComCtrls, Dialogs, AvgLvlTree, DefineTemplates,
StdCtrls, GraphMath, ExtCtrls, Buttons,
ProjectIntf, IDEImagesIntf, IDEOptionsIntf, CompOptsIntf,
PackageDefs, compiler_inherited_options, TransferMacros,
PathEditorDlg, Project, PackageSystem, LazarusIDEStrConsts, CompilerOptions,
IDEProcs;
type
{ TIdeMacroValuesFrame }
TIdeMacroValuesFrame = class(TAbstractIDEOptionsEditor)
IdeMacroValuesGroupBox: TGroupBox;
IdeMacroValuesStringGrid: TStringGrid;
MenuItem1: TMenuItem;
procedure IdeMacroValuesStringGridEditingDone(Sender: TObject);
procedure IdeMacroValuesStringGridSelectEditor(Sender: TObject; aCol,
aRow: Integer; var Editor: TWinControl);
procedure IdeMacroValuesStringGridSelection(Sender: TObject; aCol,
aRow: Integer);
private
FLoadShowSessionFromProject: boolean;
FProject: TProject;
FSwitchingMode: boolean;
procedure UpdateMacrosControls;
function GetAllIdeMacros: TStrings;
procedure CleanMacrosGrid;
procedure SaveMacros(UpdateControls: boolean);
procedure UpdateInheritedOptions;
procedure UpdateDialogCaption;
function GetDialogCaption: string;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
property AProject: TProject read FProject;
property SwitchingMode: boolean read FSwitchingMode; // the active mode is currently switched
end;
implementation
{$R *.lfm}
{ TIdeMacroValuesFrame }
procedure TIdeMacroValuesFrame.IdeMacroValuesStringGridSelectEditor(
Sender: TObject; aCol, aRow: Integer; var Editor: TWinControl);
var
PickList: TPickListCellEditor;
sl: TStringList;
Macros: TStrings;
Grid: TStringGrid;
MacroName: string;
i: LongInt;
Macro: TLazBuildMacro;
begin
Grid:=IdeMacroValuesStringGrid;
if aCol=0 then begin
// list all build MacroValues
if not (Editor is TPickListCellEditor) then exit;
PickList:=TPickListCellEditor(Editor);
sl:=TStringList.Create;
Macros:=nil;
try
if aRow=Grid.RowCount-1 then
sl.Add('(none)')
else
sl.Add('(delete)');
Macros:=GetAllIdeMacros;
sl.AddStrings(Macros);
PickList.Items.Assign(sl);
finally
Macros.Free;
sl.Free;
end;
end else if aCol=1 then begin
// list all possible values of current macro
if not (Editor is TPickListCellEditor) then exit;
PickList:=TPickListCellEditor(Editor);
MacroName:=Grid.Cells[0,aRow];
sl:=TStringList.Create;
try
Macros:=GetAllIdeMacros;
i:=Macros.IndexOf(MacroName);
if i>=0 then begin
Macro:=TLazBuildMacro(Macros.Objects[i]);
sl.AddStrings(Macro.Values);
end else begin
sl.Add('');
end;
PickList.Items.Assign(sl);
finally
Macros.Free;
sl.Free;
end;
end;
end;
procedure TIdeMacroValuesFrame.IdeMacroValuesStringGridEditingDone(Sender: TObject);
begin
SaveMacros(true);
end;
procedure TIdeMacroValuesFrame.IdeMacroValuesStringGridSelection(
Sender: TObject; aCol, aRow: Integer);
begin
CleanMacrosGrid;
end;
procedure TIdeMacroValuesFrame.UpdateMacrosControls;
var
Grid: TStringGrid;
i: Integer;
begin
Grid:=IdeMacroValuesStringGrid;
Grid.RowCount:=Project1.MacroValues.Count+2; // + titles + add button
for i:=0 to Project1.MacroValues.Count-1 do begin
Grid.Cells[0,i+1]:=Project1.MacroValues.Names[i];
Grid.Cells[1,i+1]:=Project1.MacroValues.ValueFromIndex(i);
end;
i:=Project1.MacroValues.Count+1;
Grid.Cells[0,i]:='(none)';
Grid.Cells[1,i]:='';
end;
procedure TIdeMacroValuesFrame.UpdateDialogCaption;
var
Form: TCustomForm;
begin
Form:=GetParentForm(Self);
if Form<>nil then
Form.Caption:=GetDialogCaption;
end;
function TIdeMacroValuesFrame.GetDialogCaption: string;
begin
if AProject<>nil then
begin
Result := aProject.GetTitleOrName;
Result:=Format(dlgProjectOptionsFor, [Result]);
if AProject.BuildModes.Count>1 then
Result:=Result+', '+copy(AProject.ActiveBuildMode.GetCaption,1,12);
end else
Result:='TIdeMacroValuesFrame.GetDialogCaption: no project';
end;
function TIdeMacroValuesFrame.GetAllIdeMacros: TStrings;
procedure Add(aBuildMacro: TLazBuildMacro);
begin
if GetAllIdeMacros.IndexOf(aBuildMacro.Identifier)>=0 then exit;
GetAllIdeMacros.AddObject(aBuildMacro.Identifier,aBuildMacro);
end;
procedure Add(CompOpts: TLazCompilerOptions);
var
i: Integer;
begin
for i:=0 to CompOpts.BuildMacros.Count-1 do
Add(CompOpts.BuildMacros[i]);
end;
var
PkgList: TFPList;
APackage: TLazPackage;
i: Integer;
begin
Result:=TStringList.Create;
if AProject=nil then exit;
Add(AProject.CompilerOptions);
PkgList:=nil;
try
PackageGraph.GetAllRequiredPackages(nil,AProject.FirstRequiredDependency,PkgList);
if PkgList<>nil then begin
for i:=0 to PkgList.Count-1 do begin
if TObject(PkgList[i]) is TLazPackage then begin
APackage:=TLazPackage(PkgList[i]);
Add(APackage.CompilerOptions);
end;
end;
end;
finally
PkgList.Free;
end;
TStringList(Result).Sort;
end;
procedure TIdeMacroValuesFrame.CleanMacrosGrid;
var
Grid: TStringGrid;
aRow: Integer;
MacroName: string;
NeedNewRow: Boolean;
begin
Grid:=IdeMacroValuesStringGrid;
// delete rows
for aRow:=Grid.RowCount-2 downto 1 do begin
if aRow=Grid.Row then continue; // row is selected
MacroName:=Grid.Cells[0,aRow];
if (MacroName<>'') and IsValidIdent(MacroName) then continue; // valid macro name
// delete row
Grid.DeleteColRow(false,aRow);
end;
NeedNewRow:=Grid.RowCount<2;
if (not NeedNewRow) then begin
MacroName:=Grid.Cells[0,Grid.RowCount-1];
if (MacroName<>'') and IsValidIdent(MacroName) then
NeedNewRow:=true;
end;
if NeedNewRow then begin
Grid.RowCount:=Grid.RowCount+1;
Grid.Cells[0,Grid.RowCount-1]:='(new)';
Grid.Cells[1,Grid.RowCount-1]:='';
end;
end;
procedure TIdeMacroValuesFrame.SaveMacros(UpdateControls: boolean);
var
Grid: TStringGrid;
aRow: Integer;
MacroName: string;
Values: TStringList;
Value: string;
begin
Grid:=IdeMacroValuesStringGrid;
Values:=TStringList.Create;
try
for aRow:=1 to Grid.RowCount-1 do begin
MacroName:=Grid.Cells[0,aRow];
if (MacroName='') or (not IsValidIdent(MacroName)) then continue;
Value:=Grid.Cells[1,aRow];
Values.Values[MacroName]:=Value;
end;
if not Project1.MacroValues.Equals(Values) then begin
// has changed
Project1.MacroValues.Assign(Values);
IncreaseBuildMacroChangeStamp;
if UpdateControls then begin
UpdateInheritedOptions;
end;
end;
finally
Values.Free;
end;
end;
procedure TIdeMacroValuesFrame.UpdateInheritedOptions;
var
InhOptionCtrl: TCompilerInheritedOptionsFrame;
begin
InhOptionCtrl:=TCompilerInheritedOptionsFrame(
FindOptionControl(TCompilerInheritedOptionsFrame));
if InhOptionCtrl=nil then exit;
InhOptionCtrl.UpdateInheritedTree(AProject.CompilerOptions);
end;
constructor TIdeMacroValuesFrame.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
FLoadShowSessionFromProject:=true;
end;
destructor TIdeMacroValuesFrame.Destroy;
begin
inherited Destroy;
end;
function TIdeMacroValuesFrame.GetTitle: String;
begin
Result := dlgIdeMacroValues;
end;
procedure TIdeMacroValuesFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
var
Grid: TStringGrid;
begin
IdeMacroValuesGroupBox.Caption:=lisIDEMacroValuesForFPCMacrosUseCustomOptions;
Grid:=IdeMacroValuesStringGrid;
Grid.Columns.Add;
Grid.Columns[0].Title.Caption:=lisMacroName;
Grid.Columns[0].ButtonStyle:=cbsPickList;
Grid.Columns.Add;
Grid.Columns[1].Title.Caption:=lisMacroValue;
Grid.Columns[1].ButtonStyle:=cbsPickList;
end;
procedure TIdeMacroValuesFrame.ReadSettings(AOptions: TAbstractIDEOptions);
var
PCOptions: TProjectCompilerOptions;
begin
if AOptions is TProjectCompilerOptions then begin
PCOptions:=TProjectCompilerOptions(AOptions);
FProject:=PCOptions.LazProject;
Assert(FProject=Project1, 'TIdeMacroValuesFrame.ReadSettings: FProject<>Project1');
// macros
UpdateMacrosControls;
// options dialog
UpdateDialogCaption;
end;
end;
procedure TIdeMacroValuesFrame.WriteSettings(AOptions: TAbstractIDEOptions);
begin
if AOptions is TProjectCompilerOptions then
SaveMacros(false);
end;
class function TIdeMacroValuesFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
begin
Result := TProjectCompilerOptions;
end;
initialization
RegisterIDEOptionsEditor(GroupCompiler, TIdeMacroValuesFrame, CompilerOptionsMacroValues);
end.

View File

@ -716,9 +716,7 @@ var
Note: String;
NeedBuildAllFlag: Boolean;
SubResult: TModalResult;
{$IFDEF EnableModeMatrix}
MatrixOption: TBuildMatrixOption;
{$ENDIF}
begin
Result:=false;
CloseProject(Project1);
@ -764,14 +762,10 @@ begin
if (CPUOverride<>'') then
Project1.CompilerOptions.TargetCPU:=CPUOverride;
if (WidgetSetOverride<>'') then begin
{$IFDEF EnableModeMatrix}
MatrixOption:=Project1.BuildModes.SessionMatrixOptions.Add(bmotIDEMacro);
MatrixOption.Modes:=Project1.ActiveBuildMode.Identifier;
MatrixOption.MacroName:='LCLWidgetType';
MatrixOption.Value:=WidgetSetOverride;
{$ELSE}
Project1.ActiveBuildMode.MacroValues.Values['LCLWidgetType']:=WidgetSetOverride;
{$ENDIF}
end;
// apply options
MainBuildBoss.SetBuildTargetProject1(true,smsfsSkip);

View File

@ -133,11 +133,7 @@ uses
compiler_linking_options, compiler_verbosity_options, compiler_messages_options,
compiler_other_options, compiler_inherited_options, compiler_compilation_options,
compiler_buildmacro_options,
{$IFDEF EnableModeMatrix}
Compiler_ModeMatrix,
{$ELSE}
IdeMacroValues,
{$ENDIF}
// package option frames
package_usage_options, package_description_options, package_integration_options,
package_provides_options, package_i18n_options,

View File

@ -611,54 +611,6 @@ type
property Active: boolean read FActive write SetActive;
end;
{$IFNDEF EnableModeMatrix}
{ TProjectBuildMacros }
TProjectBuildMacros = class
private
FCfgVars: TCTCfgScriptVariables;
FCfgVarsBuildMacroStamp: integer;
FChangeStamp: integer;
fLastSavedChangeStamp: integer;
FItems: TStrings;
fOnChanged: TMethodList;
function GetMacros(const Name: string): string;
function GetModified: boolean;
function GetNames(Index: integer): string;
function GetValues(const Name: string): string;
procedure SetModified(const AValue: boolean);
procedure SetValues(const Name: string; const AValue: string);
public
constructor Create;
destructor Destroy; override;
procedure Clear;
function Equals(Other: TProjectBuildMacros): boolean; reintroduce;
function Equals(aValues: TStringList): boolean; reintroduce;
function CreateDiff(Other: TProjectBuildMacros;
Tool: TCompilerDiffTool = nil): boolean;
procedure Assign(Src: TProjectBuildMacros); overload;
procedure Assign(aValues: TStringList); overload;
function Count: integer;
property Names[Index: integer]: string read GetNames;
function ValueFromIndex(Index: integer): string;
property Values[const Name: string]: string read GetValues write SetValues;
function IsDefined(const Name: string): boolean;
procedure Undefine(const Name: string);
property ChangeStamp: integer read FChangeStamp;
procedure IncreaseChangeStamp;
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string; ClearModified: boolean = true);
procedure AddOnChangedHandler(const Handler: TNotifyEvent);
procedure RemoveOnChangedHandler(const Handler: TNotifyEvent);
public
property Modified: boolean read GetModified write SetModified;
// CfgVars are updated by TBuildManager.OnGetBuildMacroValues
property CfgVars: TCTCfgScriptVariables read FCfgVars;
property CfgVarsBuildMacroStamp: integer read FCfgVarsBuildMacroStamp
write FCfgVarsBuildMacroStamp;
end;
{$ENDIF}
{ TProjectBuildMode }
TProjectBuildMode = class(TComponent)
@ -666,9 +618,6 @@ type
FChangeStamp: int64;
fSavedChangeStamp: int64;
FCompilerOptions: TProjectCompilerOptions;
{$IFNDEF EnableModeMatrix}
FMacroValues: TProjectBuildMacros;
{$ENDIF}
FIdentifier: string;
FInSession: boolean;
fOnChanged: TMethodList;
@ -703,9 +652,6 @@ type
// copied by Assign, compared by Equals, cleared by Clear
property CompilerOptions: TProjectCompilerOptions read FCompilerOptions;
{$IFNDEF EnableModeMatrix}
property MacroValues: TProjectBuildMacros read FMacroValues;
{$ENDIF}
end;
{ TProjectBuildModes }
@ -780,9 +726,6 @@ type
FEnableI18NForLFM: boolean;
FLastCompileComplete: boolean;
FMacroEngine: TTransferMacroList;
{$IFNDEF EnableModeMatrix}
FMacroValues: TProjectBuildMacros;
{$ENDIF}
FTmpAutoCreatedForms: TStrings; // temporary, used to apply auto create forms changes
FAutoOpenDesignerFormsDisabled: boolean;
FBookmarks: TProjectBookmarkList;
@ -1108,9 +1051,6 @@ type
write FLastCompilerParams;
property LastCompileComplete: boolean read FLastCompileComplete write FLastCompileComplete;
property MacroEngine: TTransferMacroList read FMacroEngine;
{$IFNDEF EnableModeMatrix}
property MacroValues: TProjectBuildMacros read FMacroValues;
{$ENDIF}
property MainFilename: String read GetMainFilename;
property MainProject: boolean read FMainProject write SetMainProject;
property MainUnitID: Integer read FMainUnitID write SetMainUnitID;
@ -2747,7 +2687,6 @@ function TProject.WriteProject(ProjectWriteFlags: TProjectWriteFlags;
procedure SaveMacroValuesAtOldPlace(XMLConfig: TXMLConfig; const Path: string;
aMode: TProjectBuildMode);
{$IFDEF EnableModeMatrix}
var
Cnt: Integer;
@ -2772,17 +2711,12 @@ function TProject.WriteProject(ProjectWriteFlags: TProjectWriteFlags;
end;
end;
{$ENDIF}
begin
{$IFDEF EnableModeMatrix}
// for older IDE (<1.1) SaveAtOldPlace the macros at the old place
Cnt:=0;
SaveAtOldPlace(BuildModes.SessionMatrixOptions);
SaveAtOldPlace(BuildModes.SharedMatrixOptions);
XMLConfig.SetDeleteValue(Path+'Count',Cnt,0);
{$ELSE}
aMode.MacroValues.SaveToXMLConfig(XMLConfig,Path);
{$ENDIF}
end;
procedure SaveBuildModes(XMLConfig: TXMLConfig; const Path: string;
@ -3302,7 +3236,6 @@ var
end;
end;
{$IFDEF EnableModeMatrix}
procedure AddMatrixMacro(const MacroName, MacroValue, ModeIdentifier: string;
InSession: boolean);
@ -3348,20 +3281,16 @@ var
MatrixOption.Modes:=ModeIdentifier;
end;
end;
{$ENDIF}
procedure LoadOldMacroValues(XMLConfig: TXMLConfig; const Path: string;
CurMode: TProjectBuildMode);
{$IFDEF EnableModeMatrix}
var
Cnt: Integer;
i: Integer;
SubPath: String;
MacroName: String;
MacroValue: String;
{$ENDIF}
begin
{$IFDEF EnableModeMatrix}
// load macro values of old IDE (<1.1)
Cnt:=XMLConfig.GetValue(Path+'Count',0);
//debugln(['LoadOldMacroValues Cnt=',Cnt]);
@ -3373,9 +3302,6 @@ var
//debugln(['LoadOldMacroValues Mode="',CurMode.Identifier,'" ',MacroName,'="',MacroValue,'" session=',CurMode.InSession]);
AddMatrixMacro(MacroName,MacroValue,CurMode.Identifier,CurMode.InSession);
end;
{$ELSE}
CurMode.MacroValues.LoadFromXMLConfig(XMLConfig,Path);
{$ENDIF}
end;
procedure LoadBuildModes(XMLConfig: TXMLConfig; const Path: string;
@ -3389,9 +3315,7 @@ var
CurMode: TProjectBuildMode;
MacroValsPath: String;
ActiveIdentifier: String;
{$IFDEF EnableModeMatrix}
s: String;
{$ENDIF}
begin
//debugln(['LoadBuildModes LoadData=',LoadData,' LoadParts=',LoadParts,' prfLoadPartBuildModes=',prfLoadPartBuildModes in ReadFlags]);
if LoadParts then begin
@ -3459,14 +3383,12 @@ var
MacroValsPath:=Path+'MacroValues/';
CurMode:=BuildModes[0];
LoadOldMacroValues(XMLConfig,MacroValsPath,CurMode);
{$IFDEF EnableModeMatrix}
if XMLConfig.GetValue(CompOptsPath+'Version/Value', 0)<10 then begin
// LCLWidgetType was not a macro but a property of its own
s := XMLConfig.GetValue(CompOptsPath+'LCLWidgetType/Value', '');
if (s<>'') and (SysUtils.CompareText(s,'default')<>0) then
AddMatrixMacro('LCLWidgetType',s,'default',false);
end;
{$ENDIF}
CurMode.CompilerOptions.LoadFromXMLConfig(XMLConfig,CompOptsPath);
end;
@ -5448,15 +5370,9 @@ begin
FActiveBuildMode:=AValue;
if FActiveBuildMode<>nil then
begin
{$IFNDEF EnableModeMatrix}
FMacroValues:=FActiveBuildMode.MacroValues;
{$ENDIF}
FCompilerOptions:=FActiveBuildMode.CompilerOptions;
FLazCompilerOptions:=FCompilerOptions;
end else begin
{$IFNDEF EnableModeMatrix}
FMacroValues:=nil;
{$ENDIF}
FCompilerOptions:=nil;
FLazCompilerOptions:=nil;
end;
@ -6146,27 +6062,10 @@ end;
procedure TProjectCompilerOptions.LoadFromXMLConfig(AXMLConfig: TXMLConfig;
const Path: string);
var
FileVersion: Integer;
{$IFNDEF EnableModeMatrix}
s: String;
{$ENDIF}
begin
inherited LoadFromXMLConfig(AXMLConfig,Path);
FileVersion:=aXMLConfig.GetValue(Path+'Version/Value', 0);
if FileVersion<10 then
begin
if BuildMode<>nil then begin
{$IFNDEF EnableModeMatrix}
// LCLWidgetType was not a macro but a property of its own
s := aXMLConfig.GetValue(Path+'LCLWidgetType/Value', '');
if (s<>'') and (SysUtils.CompareText(s,'default')<>0) then
BuildMode.MacroValues.Values['LCLWidgetType']:=s;
{$ENDIF}
end;
end;
//FileVersion:=aXMLConfig.GetValue(Path+'Version/Value', 0);
// old compatibility
if AXMLConfig.GetValue(Path+'SkipCompiler/Value',false) then
@ -6183,13 +6082,6 @@ begin
SaveXMLCompileReasons(AXMLConfig, Path+'CompileReasons/', FCompileReasons,
crAll);
{$IFNDEF EnableModeMatrix}
// write the LCLWidgetType value to let older IDEs read the value
if BuildMode<>nil then
aXMLConfig.SetDeleteValue(Path+'LCLWidgetType/Value',
BuildMode.MacroValues.Values['LCLWidgetType'],'');
{$ENDIF}
//debugln(['TProjectCompilerOptions.SaveToXMLConfig ',Path+'CompileReasons/ ',crCompile in FCompileReasons]);
end;
@ -6945,250 +6837,6 @@ begin
RequiresPropPath:=DestPath;
end;
{$IFNDEF EnableModeMatrix}
{ TProjectBuildMacros }
function TProjectBuildMacros.GetMacros(const Name: string): string;
begin
if (Name='') or not IsValidIdent(Name) then exit('');
Result:=FItems.Values[Name];
end;
function TProjectBuildMacros.GetModified: boolean;
begin
Result:=ChangeStamp<>fLastSavedChangeStamp;
end;
function TProjectBuildMacros.GetNames(Index: integer): string;
begin
Result:=FItems.Names[Index];
end;
function TProjectBuildMacros.GetValues(const Name: string): string;
begin
if (Name='') or not IsValidIdent(Name) then exit('');
Result:=FItems.Values[Name];
end;
procedure TProjectBuildMacros.SetModified(const AValue: boolean);
begin
if not AValue then
fLastSavedChangeStamp:=ChangeStamp;
end;
procedure TProjectBuildMacros.SetValues(const Name: string; const AValue: string);
begin
if (Name='') or not IsValidIdent(Name) then exit;
if Values[Name]=AValue then exit;
FItems.Values[Name]:=AValue;
IncreaseChangeStamp;
end;
constructor TProjectBuildMacros.Create;
begin
FItems:=TStringList.Create;
FCfgVars:=TCTCfgScriptVariables.Create;
FCfgVarsBuildMacroStamp:=CTInvalidChangeStamp;
FChangeStamp:=CTInvalidChangeStamp;
fOnChanged:=TMethodList.Create;
end;
destructor TProjectBuildMacros.Destroy;
begin
FreeAndNil(FItems);
FreeAndNil(FCfgVars);
FreeAndNil(fOnChanged);
inherited Destroy;
end;
procedure TProjectBuildMacros.Clear;
begin
if FItems.Count=0 then exit;
IncreaseChangeStamp;
FItems.Clear;
FCfgVars.Clear;
FCfgVarsBuildMacroStamp:=CTInvalidChangeStamp;
end;
function TProjectBuildMacros.Equals(Other: TProjectBuildMacros): boolean;
begin
Result:=not CreateDiff(Other);
end;
function TProjectBuildMacros.Equals(aValues: TStringList): boolean;
var
i: Integer;
CurName: string;
CurValue: string;
begin
Result:=false;
if aValues.Count<>Count then exit;
for i:=0 to aValues.Count-1 do begin
CurName:=aValues.Names[i];
CurValue:=aValues.ValueFromIndex[i];
//debugln(['TProjectBuildMacros.Equals ',CurName,' NewValue=',CurValue,' IsDefined=',IsDefined(CurName),' OldValue=',Values[CurName]]);
if not IsDefined(CurName) then exit;
if Values[CurName]<>CurValue then exit;
end;
Result:=true;
//debugln(['TProjectBuildMacros.Equals END ',aValues.Count,' ',Count]);
end;
function TProjectBuildMacros.CreateDiff(Other: TProjectBuildMacros;
Tool: TCompilerDiffTool): boolean;
{ add anything new or different in Other and if something is not in Other
add an undefined line
}
var
i: Integer;
CurName: string;
CurValue: string;
begin
Result:=false;
for i:=0 to Other.Count-1 do begin
CurName:=Other.Names[i];
CurValue:=Other.ValueFromIndex(i);
//debugln(['TProjectBuildMacros.Equals ',CurName,' NewValue=',CurValue,' IsDefined=',IsDefined(CurName),' OldValue=',Values[CurName]]);
if Tool=nil then
begin
if Values[CurName]<>CurValue then exit(true);
end else
Result:=Result or Tool.AddDiff('BuildMacros/'+CurName,Values[CurName],CurValue);
end;
if Tool<>nil then
begin
for i:=0 to Count-1 do
begin
CurName:=ValueFromIndex(i);
if not Other.IsDefined(CurName) then
begin
Result:=true;
Tool.AddDiffItemUndefined('BuildMacros/'+CurName);
end;
end;
end;
//debugln(['TProjectBuildMacros.Equals END ',aValues.Count,' ',Count]);
end;
procedure TProjectBuildMacros.Assign(Src: TProjectBuildMacros);
begin
if Equals(Src) then exit;
FItems.Assign(Src.FItems);
CfgVars.Clear;
FCfgVarsBuildMacroStamp:=CTInvalidChangeStamp;
IncreaseChangeStamp;
end;
procedure TProjectBuildMacros.Assign(aValues: TStringList);
var
i: Integer;
CurName: string;
CurValue: string;
begin
if Equals(aValues) then exit;
FItems.Clear;
for i:=0 to aValues.Count-1 do begin
CurName:=aValues.Names[i];
CurValue:=aValues.ValueFromIndex[i];
FItems.Values[CurName]:=CurValue;
end;
CfgVars.Clear;
FCfgVarsBuildMacroStamp:=CTInvalidChangeStamp;
IncreaseChangeStamp;
end;
function TProjectBuildMacros.Count: integer;
begin
Result:=FItems.Count;
end;
function TProjectBuildMacros.ValueFromIndex(Index: integer): string;
begin
Result:=FItems.ValueFromIndex[Index];
end;
function TProjectBuildMacros.IsDefined(const Name: string): boolean;
begin
if (Name='') or not IsValidIdent(Name) then exit(false);
Result:=FItems.IndexOfName(Name)>=0;
end;
procedure TProjectBuildMacros.Undefine(const Name: string);
var
i: LongInt;
begin
if (Name='') or not IsValidIdent(Name) then exit;
i:=FItems.IndexOfName(Name);
if i<0 then exit;
FItems.Delete(i);
IncreaseChangeStamp;
end;
procedure TProjectBuildMacros.IncreaseChangeStamp;
begin
CTIncreaseChangeStamp(FChangeStamp);
if fOnChanged<>nil then fOnChanged.CallNotifyEvents(Self);
end;
procedure TProjectBuildMacros.LoadFromXMLConfig(XMLConfig: TXMLConfig;
const Path: string);
var
NewItems: TStringList;
Cnt: LongInt;
i: Integer;
SubPath: String;
NewName: String;
NewValue: String;
begin
NewItems:=TStringList.Create;
try
Cnt:=XMLConfig.GetValue(Path+'Count',0);
for i:=1 to Cnt do begin
SubPath:=Path+'Macro'+IntToStr(i)+'/';
NewName:=XMLConfig.GetValue(SubPath+'Name','');
if (NewName='') or not IsValidIdent(NewName) then continue;
NewValue:=XMLConfig.GetValue(SubPath+'Value','');
NewItems.Values[NewName]:=NewValue;
end;
if not FItems.Equals(NewItems) then begin
IncreaseChangeStamp;
FItems.Assign(NewItems);
FCfgVars.Clear;
FCfgVarsBuildMacroStamp:=CTInvalidChangeStamp;
end;
fLastSavedChangeStamp:=ChangeStamp;
finally
NewItems.Free;
end;
end;
procedure TProjectBuildMacros.SaveToXMLConfig(XMLConfig: TXMLConfig;
const Path: string; ClearModified: boolean);
var
i: Integer;
SubPath: String;
begin
XMLConfig.SetDeleteValue(Path+'Count',Count,0);
for i:=0 to Count-1 do begin
SubPath:=Path+'Macro'+IntToStr(i+1)+'/';
XMLConfig.SetDeleteValue(SubPath+'Name',Names[i],'');
XMLConfig.SetDeleteValue(SubPath+'Value',ValueFromIndex(i),'');
end;
if ClearModified then
Modified:=false;
end;
procedure TProjectBuildMacros.AddOnChangedHandler(const Handler: TNotifyEvent);
begin
fOnChanged.Add(TMethod(Handler));
end;
procedure TProjectBuildMacros.RemoveOnChangedHandler(const Handler: TNotifyEvent);
begin
fOnChanged.Remove(TMethod(Handler));
end;
{$ENDIF}
{ TProjectBuildMode }
procedure TProjectBuildMode.SetInSession(const AValue: boolean);
@ -7229,10 +6877,6 @@ begin
fOnChanged:=TMethodList.Create;
FChangeStamp:=CTInvalidChangeStamp64;
fSavedChangeStamp:=FChangeStamp;
{$IFNDEF EnableModeMatrix}
FMacroValues:=TProjectBuildMacros.Create;
FMacroValues.AddOnChangedHandler(@OnItemChanged);
{$ENDIF}
FCompilerOptions:=TProjectCompilerOptions.Create(LazProject);
FCompilerOptions.AddOnChangedHandler(@OnItemChanged);
FCompilerOptions.FBuildMode:=Self;
@ -7242,9 +6886,6 @@ destructor TProjectBuildMode.Destroy;
begin
FreeAndNil(fOnChanged);
FreeAndNil(FCompilerOptions);
{$IFNDEF EnableModeMatrix}
FreeAndNil(FMacroValues);
{$ENDIF}
inherited Destroy;
end;
@ -7259,18 +6900,11 @@ end;
procedure TProjectBuildMode.Clear;
begin
CompilerOptions.Clear;
{$IFNDEF EnableModeMatrix}
MacroValues.Clear;
{$ENDIF}
end;
function TProjectBuildMode.Equals(Src: TProjectBuildMode): boolean;
begin
Result:=CompilerOptions.IsEqual(Src.CompilerOptions)
{$IFNDEF EnableModeMatrix}
and MacroValues.Equals(Src.MacroValues)
{$ENDIF}
;
Result:=CompilerOptions.IsEqual(Src.CompilerOptions);
end;
function TProjectBuildMode.CreateDiff(Other: TProjectBuildMode;
@ -7280,9 +6914,6 @@ begin
//if Tool<>nil then debugln(['TProjectBuildMode.CreateDiff ']);
Result:=CompilerOptions.CreateDiff(Other.CompilerOptions,Tool);
if (Tool=nil) and Result then exit;
{$IFNDEF EnableModeMatrix}
if MacroValues.CreateDiff(Other.MacroValues,Tool) then Result:=true;
{$ENDIF}
end;
procedure TProjectBuildMode.Assign(Src: TProjectBuildMode);
@ -7290,18 +6921,12 @@ begin
if Equals(Src) then exit;
InSession:=Src.InSession;
CompilerOptions.Assign(Src.CompilerOptions);
{$IFNDEF EnableModeMatrix}
MacroValues.Assign(Src.MacroValues);
{$ENDIF}
end;
procedure TProjectBuildMode.LoadFromXMLConfig(XMLConfig: TXMLConfig;
const Path: string);
begin
FIdentifier:=XMLConfig.GetValue('Identifier','');
{$IFNDEF EnableModeMatrix}
FMacroValues.LoadFromXMLConfig(XMLConfig,Path+'BuildMacros/');
{$ENDIF}
FCompilerOptions.LoadFromXMLConfig(XMLConfig,Path+'CompilerOptions/');
end;
@ -7309,9 +6934,6 @@ procedure TProjectBuildMode.SaveToXMLConfig(XMLConfig: TXMLConfig;
const Path: string; ClearModified: boolean);
begin
XMLConfig.SetDeleteValue('Identifier',Identifier,'');
{$IFNDEF EnableModeMatrix}
FMacroValues.SaveToXMLConfig(XMLConfig,Path+'BuildMacros/',ClearModified);
{$ENDIF}
FCompilerOptions.SaveToXMLConfig(XMLConfig,Path+'CompilerOptions/');
end;