IDE: change build macro valeus: invalidate

git-svn-id: trunk@27517 -
This commit is contained in:
mattias 2010-09-28 20:56:48 +00:00
parent 9e9d2feeec
commit 951dd0f0c5
6 changed files with 140 additions and 29 deletions

View File

@ -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)

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -12,7 +12,7 @@
<UnitOutputDirectory Value="../units/$(TargetCPU)-$(TargetOS)/$(LCLWidgetType1)"/>
</SearchPaths>
<Conditionals Value="// LCLWidgetType1
if undefined(LCLWidgetType) then begin
if undefined(LCLWidgetType1) then begin
if (TargetOS='win32') or (TargetOS='win64') then
LCLWidgetType1 := 'win32'
else if TargetOS='wince' then
@ -100,7 +100,7 @@ end;"/>
</Item2>
</RequiredPkgs>
<UsageOptions>
<CustomOptions Value="-dLCL -d$(LCLWidgetType1)
<CustomOptions Value="-dLCL -dLCL$(LCLWidgetType1)
"/>
<UnitPath Value="$(PkgOutDir)"/>
</UsageOptions>