From 951dd0f0c529b98fbeeaf8187d7e345f4ad2f8af Mon Sep 17 00:00:00 2001 From: mattias Date: Tue, 28 Sep 2010 20:56:48 +0000 Subject: [PATCH] IDE: change build macro valeus: invalidate git-svn-id: trunk@27517 - --- ide/compileroptions.pp | 12 +++ ide/frames/buildmodeseditor.lfm | 14 ++-- ide/frames/buildmodeseditor.pas | 91 ++++++++++++++++++----- ide/frames/compiler_inherited_options.pas | 2 +- ide/project.pp | 46 +++++++++++- lcl/interfaces/lcl1.lpk | 4 +- 6 files changed, 140 insertions(+), 29 deletions(-) diff --git a/ide/compileroptions.pp b/ide/compileroptions.pp index 200bf97891..7fcf5b6454 100644 --- a/ide/compileroptions.pp +++ b/ide/compileroptions.pp @@ -80,6 +80,15 @@ - show syntax errors of conditionals - when package is renamed, rename macros too - moved the project target file to compiler options + - code completion + - keywords + - operands + - inherited macros + - project macros + - own macros + - words in conditionals + - result identifiers + - history ToDo: - discuss captions @@ -87,10 +96,13 @@ - make synedit a package - make IDEIntf a package - make LCL a package + - LCLWidgetLinkerAddition - make FCL a package - create package lazbuildsystem - move - code completion + - keypress event + - help for add/delete macro speedbuttons - a project can save the set of build macros and compiler options - add changestamp, assign, equals to compiler options - refactor compiler options (default options, load, save to file) diff --git a/ide/frames/buildmodeseditor.lfm b/ide/frames/buildmodeseditor.lfm index 7f74e6b75a..b8e952c143 100644 --- a/ide/frames/buildmodeseditor.lfm +++ b/ide/frames/buildmodeseditor.lfm @@ -14,14 +14,14 @@ inherited BuildModesEditorFrame: TBuildModesEditorFrame Align = alClient BorderSpacing.Around = 6 Caption = 'BuildMacroValuesGroupBox' - ClientHeight = 215 - ClientWidth = 534 + ClientHeight = 213 + ClientWidth = 530 TabOrder = 0 object BuildMacroValuesStringGrid: TStringGrid Left = 0 - Height = 215 + Height = 213 Top = 0 - Width = 534 + Width = 530 Align = alClient AutoFillColumns = True ColCount = 2 @@ -30,12 +30,12 @@ inherited BuildModesEditorFrame: TBuildModesEditorFrame Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goAlwaysShowEditor, goSmoothScroll] RowCount = 2 TabOrder = 0 + OnEditingDone = BuildMacroValuesStringGridEditingDone OnSelectEditor = BuildMacroValuesStringGridSelectEditor OnSelection = BuildMacroValuesStringGridSelection - OnSelectCell = BuildMacroValuesStringGridSelectCell ColWidths = ( - 266 - 266 + 264 + 264 ) end end diff --git a/ide/frames/buildmodeseditor.pas b/ide/frames/buildmodeseditor.pas index 274a255e92..cbb87493f7 100644 --- a/ide/frames/buildmodeseditor.pas +++ b/ide/frames/buildmodeseditor.pas @@ -34,7 +34,7 @@ uses Grids, Graphics, Menus, ComCtrls, Dialogs, AvgLvlTree, DefineTemplates, StdCtrls, GraphMath, ExtCtrls, Buttons, ProjectIntf, IDEImagesIntf, IDEOptionsIntf, - PackageDefs, + PackageDefs, compiler_inherited_options, TransferMacros, PathEditorDlg, Project, PackageSystem, LazarusIDEStrConsts, CompilerOptions, IDEProcs; @@ -48,8 +48,7 @@ type BuildModesGroupBox: TGroupBox; BuildModesPopupMenu: TPopupMenu; Splitter1: TSplitter; - procedure BuildMacroValuesStringGridSelectCell(Sender: TObject; aCol, - aRow: Integer; var CanSelect: Boolean); + procedure BuildMacroValuesStringGridEditingDone(Sender: TObject); procedure BuildMacroValuesStringGridSelectEditor(Sender: TObject; aCol, aRow: Integer; var Editor: TWinControl); procedure BuildMacroValuesStringGridSelection(Sender: TObject; aCol, @@ -60,7 +59,9 @@ type procedure UpdateMacrosControls; function GetAllBuildMacros: TStrings; procedure CleanMacrosGrid; - procedure Save; + procedure Save(UpdateControls: boolean); + procedure UpdateInheritedOptions; + function FindOptionFrame(AClass: TComponentClass): TComponent; public constructor Create(TheOwner: TComponent); override; destructor Destroy; override; @@ -139,18 +140,19 @@ begin end; end; +procedure TBuildModesEditorFrame.BuildMacroValuesStringGridEditingDone( + Sender: TObject); +begin + //debugln(['TBuildModesEditorFrame.BuildMacroValuesStringGridEditingDone ']); + Save(true); +end; + procedure TBuildModesEditorFrame.BuildMacroValuesStringGridSelection( Sender: TObject; aCol, aRow: Integer); begin CleanMacrosGrid; end; -procedure TBuildModesEditorFrame.BuildMacroValuesStringGridSelectCell( - Sender: TObject; aCol, aRow: Integer; var CanSelect: Boolean); -begin - -end; - procedure TBuildModesEditorFrame.UpdateMacrosControls; var Grid: TStringGrid; @@ -239,21 +241,71 @@ begin end; end; -procedure TBuildModesEditorFrame.Save; +procedure TBuildModesEditorFrame.Save(UpdateControls: boolean); var Grid: TStringGrid; aRow: Integer; MacroName: string; + Values: TStringList; + Value: string; begin Grid:=BuildMacroValuesStringGrid; - MacroValues.Clear; - for aRow:=1 to Grid.RowCount-1 do begin - MacroName:=Grid.Cells[0,aRow]; - if (MacroName='') or (not IsValidIdent(MacroName)) then continue; - MacroValues.Values[MacroName]:=Grid.Cells[1,aRow]; + 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; + //debugln(['TBuildModesEditorFrame.Save ',Values.Text,' changed=',not MacroValues.Equals(Values)]); + if not MacroValues.Equals(Values) then begin + // has changed + MacroValues.Assign(Values); + if UpdateControls then begin + UpdateInheritedOptions; + end; + end; + finally + Values.Free; end; end; +procedure TBuildModesEditorFrame.UpdateInheritedOptions; +var + InhOptionCtrl: TCompilerInheritedOptionsFrame; +begin + InhOptionCtrl:=TCompilerInheritedOptionsFrame( + FindOptionFrame(TCompilerInheritedOptionsFrame)); + //debugln(['TBuildModesEditorFrame.UpdateInheritedOptions ',DbgSName(InhOptionCtrl)]); + if InhOptionCtrl=nil then exit; + InhOptionCtrl.UpdateInheritedTree(AProject.CompilerOptions); +end; + +function TBuildModesEditorFrame.FindOptionFrame(AClass: TComponentClass + ): TComponent; + + function Search(AControl: TControl): TComponent; + var + i: Integer; + AWinControl: TWinControl; + begin + if AControl is AClass then + exit(AControl); + if AControl is TWinControl then begin + AWinControl:=TWinControl(AControl); + for i:=0 to AWinControl.ControlCount-1 do begin + Result:=Search(AWinControl.Controls[i]); + if Result<>nil then exit; + end; + end; + Result:=nil; + end; + +begin + Result:=Search(GetParentForm(Self)); +end; + constructor TBuildModesEditorFrame.Create(TheOwner: TComponent); begin inherited Create(TheOwner); @@ -306,8 +358,11 @@ var begin if AOptions is TProjectCompilerOptions then begin PCOptions:=TProjectCompilerOptions(AOptions); - Save; - PCOptions.Project.MacroValues.Assign(MacroValues); + Save(false); + if not PCOptions.Project.MacroValues.Equals(MacroValues) then begin + PCOptions.Project.MacroValues.Assign(MacroValues); + IncreaseBuildMacroChangeStamp; + end; end; end; diff --git a/ide/frames/compiler_inherited_options.pas b/ide/frames/compiler_inherited_options.pas index 03918a0306..2eb9a1bed9 100644 --- a/ide/frames/compiler_inherited_options.pas +++ b/ide/frames/compiler_inherited_options.pas @@ -57,13 +57,13 @@ type ImageIndexPackage: Integer; InheritedChildDatas: TList; // list of PInheritedNodeData procedure ClearInheritedTree; - procedure UpdateInheritedTree(CompilerOpts: TBaseCompilerOptions); public destructor Destroy; override; function GetTitle: string; override; procedure Setup(ADialog: TAbstractOptionsEditorDialog); override; procedure ReadSettings(AOptions: TAbstractIDEOptions); override; procedure WriteSettings(AOptions: TAbstractIDEOptions); override; + procedure UpdateInheritedTree(CompilerOpts: TBaseCompilerOptions); class function SupportedOptionsClass: TAbstractIDEOptionsClass; override; end; diff --git a/ide/project.pp b/ide/project.pp index f47b77a84d..141d02f946 100644 --- a/ide/project.pp +++ b/ide/project.pp @@ -611,11 +611,14 @@ type destructor Destroy; override; procedure Clear; function Equals(Other: TProjectBuildMacros): boolean; reintroduce; - procedure Assign(Src: TProjectBuildMacros); + function Equals(aValues: TStringList): boolean; reintroduce; + 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; property ChangeStamp: integer read FChangeStamp; procedure IncreaseChangeStamp; procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string); @@ -6261,6 +6264,24 @@ begin Result:=FItems.Equals(Other.FItems); end; +function TProjectBuildMacros.Equals(aValues: TStringList): boolean; +var + i: Integer; + CurName: string; + CurValue: string; +begin + Result:=false; + 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; + //debugln(['TProjectBuildMacros.Equals END ',aValues.Count,' ',Count]); + Result:=aValues.Count=Count; +end; + procedure TProjectBuildMacros.Assign(Src: TProjectBuildMacros); begin if Equals(Src) then exit; @@ -6269,6 +6290,23 @@ begin 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.Assign(aValues); + IncreaseChangeStamp; +end; + function TProjectBuildMacros.Count: integer; begin Result:=FItems.Count; @@ -6279,6 +6317,12 @@ 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.IncreaseChangeStamp; begin if FChangeStamp=High(FChangeStamp) then diff --git a/lcl/interfaces/lcl1.lpk b/lcl/interfaces/lcl1.lpk index 8a781a9541..e8e86e3442 100644 --- a/lcl/interfaces/lcl1.lpk +++ b/lcl/interfaces/lcl1.lpk @@ -12,7 +12,7 @@ -