IDE: removed conditionals via nodes

git-svn-id: trunk@27107 -
This commit is contained in:
mattias 2010-08-16 11:08:18 +00:00
parent 4eb55fc1fb
commit 12f0bd4993
16 changed files with 930 additions and 1935 deletions

6
.gitattributes vendored
View File

@ -3534,10 +3534,6 @@ ide/frames/compiler_codegen_options.lfm svneol=native#text/plain
ide/frames/compiler_codegen_options.pas svneol=native#text/pascal
ide/frames/compiler_compilation_options.lfm svneol=native#text/plain
ide/frames/compiler_compilation_options.pas svneol=native#text/pascal
ide/frames/compiler_conditionals_options.lfm svneol=native#text/plain
ide/frames/compiler_conditionals_options.pas svneol=native#text/plain
ide/frames/compiler_condtree.lfm svneol=native#text/plain
ide/frames/compiler_condtree.pas svneol=native#text/plain
ide/frames/compiler_inherited_options.lfm svneol=native#text/plain
ide/frames/compiler_inherited_options.pas svneol=native#text/pascal
ide/frames/compiler_linking_options.lfm svneol=native#text/plain
@ -3552,8 +3548,6 @@ ide/frames/compiler_path_options.lfm svneol=native#text/plain
ide/frames/compiler_path_options.pas svneol=native#text/plain
ide/frames/compiler_verbosity_options.lfm svneol=native#text/plain
ide/frames/compiler_verbosity_options.pas svneol=native#text/pascal
ide/frames/compoptcondpropsdlg.lfm svneol=native#text/plain
ide/frames/compoptcondpropsdlg.pas svneol=native#text/plain
ide/frames/desktop_options.lfm svneol=native#text/plain
ide/frames/desktop_options.pas svneol=native#text/pascal
ide/frames/editor_codefolding_options.lfm svneol=native#text/plain

View File

@ -61,6 +61,7 @@
- edit default value
ToDo:
- warn for macro name conflicts
- every package/project needs a function to compute all values of its build macros
- build macros depend on used packages and project build macro values
- add a changestamp for this
@ -69,11 +70,11 @@
- default value of a build macro requires values of project and
default macro values of required packages
- every package/project needs a function to substitute macros
- check local macros (pkgdir, pkgoutdir)
- check active project values
- check default values of build macros of used packages
- check default values of build macros of self
- check conditionals
- check local macros (pkgdir, pkgoutdir)
- use default global macros
- every package/project needs conditionals
- using config script
@ -88,6 +89,7 @@
- refactor compiler options (default options, load, save to file)
- store sets in lpi
- store sets in lps
- when package is renamed, rename macros too
- i18n for descriptions
- keyword help for a build macro
@ -300,7 +302,6 @@ type
TParsedCompilerOptions = class
private
FConditionals: TCompOptConditionals;
FInvalidateParseOnChange: boolean;
FOnLocalSubstitute: TLocalSubstitutionEvent;
FOutputDirectoryOverride: string;
@ -315,7 +316,7 @@ type
ParsedPIValues: array[TParsedCompilerOptString] of string;
ParsedPIStamp: array[TParsedCompilerOptString] of integer;
ParsingPI: array[TParsedCompilerOptString] of boolean;
constructor Create(TheConditionals: TCompOptConditionals);
constructor Create;
function GetParsedValue(Option: TParsedCompilerOptString;
WithOverrides: boolean = true): string;
function GetParsedPIValue(Option: TParsedCompilerOptString): string;// platform independent
@ -334,7 +335,6 @@ type
write FInvalidateParseOnChange;
property OutputDirectoryOverride: string read FOutputDirectoryOverride
write SetOutputDirectoryOverride;
property Conditionals: TCompOptConditionals read FConditionals;
end;
TParseStringEvent =
@ -475,6 +475,7 @@ type
protected
procedure SetBaseDirectory(const AValue: string); override;
procedure SetCompilerPath(const AValue: String); override;
procedure SetConditionals(const AValue: string); override;
procedure SetCustomOptions(const AValue: string); override;
procedure SetIncludePaths(const AValue: String); override;
procedure SetLibraryPaths(const AValue: String); override;
@ -613,7 +614,6 @@ type
TAdditionalCompilerOptions = class
private
FBaseDirectory: string;
FConditionals: TCompOptConditionals;
FCustomOptions: string;
FIncludePath: string;
FLibraryPath: string;
@ -653,7 +653,6 @@ type
property CustomOptions: string read FCustomOptions write SetCustomOptions;
property BaseDirectory: string read FBaseDirectory write SetBaseDirectory;
property ParsedOpts: TParsedCompilerOptions read FParsedOpts;
property Conditionals: TCompOptConditionals read FConditionals;
end;
@ -1010,8 +1009,7 @@ constructor TBaseCompilerOptions.Create(const AOwner: TObject;
const AToolClass: TCompilationToolClass);
begin
inherited Create(AOwner);
FConditionals := TCompOptConditionals.Create;
FParsedOpts := TParsedCompilerOptions.Create(TCompOptConditionals(FConditionals));
FParsedOpts := TParsedCompilerOptions.Create;
FExecuteBefore := AToolClass.Create;
FExecuteAfter := AToolClass.Create;
fBuildMacros := TIDEBuildMacros.Create(Self);
@ -1112,6 +1110,13 @@ begin
ParsedOpts.SetUnparsedValue(pcosCompilerPath,fCompilerPath);
end;
procedure TBaseCompilerOptions.SetConditionals(const AValue: string);
begin
if FConditionals=AValue then exit;
FConditionals:=AValue;
IncreaseBuildMacroChangeStamp;
end;
procedure TBaseCompilerOptions.SetDefaultMakeOptionsFlags(
const AValue: TCompilerCmdLineOptions);
begin
@ -1295,8 +1300,7 @@ begin
SrcPath := sp(XMLConfigFile.GetValue(p+'SrcPath/Value', ''));
{ Conditionals }
TCompOptConditionals(FConditionals).LoadFromXMLConfig(XMLConfigFile,
Path+'Conditionals/',PathDelimChange);
FConditionals:=XMLConfigFile.GetValue(Path+'Conditionals/Value','');
TIDEBuildMacros(fBuildMacros).LoadFromXMLConfig(XMLConfigFile,
Path+'BuildMacros/',PathDelimChange);
// ToDo: replace this with conditional compiler options
@ -1509,10 +1513,9 @@ begin
XMLConfigFile.SetDeleteValue(p+'SrcPath/Value', f(SrcPath),'');
{ Conditionals }
TCompOptConditionals(FConditionals).SaveToXMLConfig(XMLConfigFile,
Path+'Conditionals/',UsePathDelim);
XMLConfigFile.SetDeleteValue(Path+'Conditionals/Value',Conditionals,'');
TIDEBuildMacros(fBuildMacros).SaveToXMLConfig(XMLConfigFile,
Path+'BuildMacros/',UsePathDelim);
Path+'BuildMacros/',UsePathDelim);
// ToDo: remove
XMLConfigFile.SetDeleteValue(p+'LCLWidgetType/Value', LCLWidgetType,'');
@ -2931,7 +2934,7 @@ begin
DebugPath := CompOpts.DebugPath;
// conditionals
Conditionals.Assign(CompOpts.Conditionals);
Conditionals:=CompOpts.Conditionals;
TIDEBuildMacros(BuildMacros).Assign(CompOpts.BuildMacros);
fLCLWidgetType := CompOpts.fLCLWidgetType;
@ -3063,8 +3066,8 @@ begin
Tool.AddPathsDiff('DebugPath',fDebugPath,CompOpts.fDebugPath);
// conditionals
Tool.Path:='Conditionals';
TCompOptConditionals(Conditionals).CreateDiff(CompOpts.Conditionals,Tool);
Tool.AddPathsDiff('Conditionals',FConditionals,CompOpts.FConditionals);
Tool.Path:='BuildModes';
TIDEBuildMacros(fBuildMacros).CreateDiff(CompOpts.BuildMacros,Tool);
Tool.AddDiff('LCLWidgetType',fLCLWidgetType,CompOpts.fLCLWidgetType);
@ -3224,15 +3227,13 @@ end;
constructor TAdditionalCompilerOptions.Create(TheOwner: TObject);
begin
fOwner:=TheOwner;
FConditionals:=TCompOptConditionals.Create;
FParsedOpts:=TParsedCompilerOptions.Create(FConditionals);
FParsedOpts:=TParsedCompilerOptions.Create;
Clear;
end;
destructor TAdditionalCompilerOptions.Destroy;
begin
FreeThenNil(FParsedOpts);
FreeThenNil(FConditionals);// free conditionals before FParsedOpts
inherited Destroy;
end;
@ -3262,7 +3263,6 @@ begin
LinkerOptions:=f(XMLConfig.GetValue(Path+'LinkerOptions/Value',''));
ObjectPath:=f(XMLConfig.GetValue(Path+'ObjectPath/Value',''));
UnitPath:=f(XMLConfig.GetValue(Path+'UnitPath/Value',''));
FConditionals.LoadFromXMLConfig(XMLConfig,Path+'Conditionals/',AdjustPathDelims);
end;
procedure TAdditionalCompilerOptions.SaveToXMLConfig(XMLConfig: TXMLConfig;
@ -3280,7 +3280,6 @@ begin
XMLConfig.SetDeleteValue(Path+'LinkerOptions/Value',f(fLinkerOptions),'');
XMLConfig.SetDeleteValue(Path+'ObjectPath/Value',f(FObjectPath),'');
XMLConfig.SetDeleteValue(Path+'UnitPath/Value',f(FUnitPath),'');
FConditionals.SaveToXMLConfig(XMLConfig,Path+'Conditionals/',UsePathDelim);
end;
function TAdditionalCompilerOptions.GetOwnerName: string;
@ -3323,9 +3322,8 @@ begin
DebugLn(['TParsedCompilerOptions.SetOutputDirectoryOverride using default']);
end;
constructor TParsedCompilerOptions.Create(TheConditionals: TCompOptConditionals);
constructor TParsedCompilerOptions.Create;
begin
FConditionals:=TheConditionals;
Clear;
end;
@ -3405,29 +3403,8 @@ function TParsedCompilerOptions.DoParseOption(const OptionText: string;
var
s: String;
BaseDirectory: String;
cocOption: TCOCValueType;
h: string;
begin
s:=OptionText;
// add conditional additions
if Conditionals<>nil then begin
cocOption:=ParsedCompOptToConditional[Option];
case Option of
pcosUnitPath,pcosSrcPath,pcosIncludePath,pcosObjectPath,pcosLibraryPath,
pcosDebugPath:
// add search path
s:=MergeSearchPaths(s,FConditionals.Values[cocOption]);
pcosLinkerOptions,pcosCustomOptions:
begin
// add command line option
h:=FConditionals.Values[cocOption];
if (h<>'') then begin
if s<>'' then s:=s+' ';
s:=s+h;
end;
end;
end;
end;
// parse locally
//DebugLn(['TParsedCompilerOptions.DoParseOption local "',s,'" ...']);
if Assigned(OnLocalSubstitute) then

View File

@ -1,7 +1,7 @@
object frmCompilerOptions: TfrmCompilerOptions
Left = 318
Left = 305
Height = 528
Top = 150
Top = 157
Width = 659
ActiveControl = CategoryTreeView
Align = alClient
@ -1051,63 +1051,22 @@ object frmCompilerOptions: TfrmCompilerOptions
end
end
end
object ConditionalPage: TPage
Caption = 'ConditionalPage'
object MacrosPage: TPage
Caption = 'MacrosPage'
ClientWidth = 531
ClientHeight = 435
object ConditionalsGroupBox: TGroupBox
Left = 0
Height = 214
Top = 0
Width = 531
Align = alTop
Caption = 'ConditionalsGroupBox'
ClientHeight = 195
ClientWidth = 527
TabOrder = 1
inline ConditionalOptionsFrame: TCompOptsCondTreeFrame
Height = 195
Width = 527
Align = alClient
ClientHeight = 195
ClientWidth = 527
Visible = True
inherited COCTreeView: TTreeView
Height = 195
Width = 527
end
end
end
object ConditionalSplitter: TSplitter
Cursor = crVSplit
Left = 0
Height = 5
Top = 214
Width = 531
Align = alTop
ResizeAnchor = akTop
end
object BuildMacrosGroupBox: TGroupBox
Left = 0
Height = 216
Top = 219
inline BuildMacrosFrame: TCompOptBuildMacrosFrame
Height = 435
Width = 531
Align = alClient
Caption = 'BuildMacrosGroupBox'
ClientHeight = 197
ClientWidth = 527
TabOrder = 0
inline BuildMacrosFrame: TCompOptBuildMacrosFrame
Height = 197
Width = 527
Align = alClient
ClientHeight = 197
ClientHeight = 435
ClientWidth = 531
Visible = True
inherited MacrosGroupBox: TGroupBox
Width = 531
ClientWidth = 527
Visible = True
inherited BuildMacroSelectedGroupBox: TGroupBox
Height = 197
Width = 283
ClientHeight = 178
ClientWidth = 279
inherited BuildMacroDefaultLabel: TLabel
Width = 267
@ -1119,11 +1078,18 @@ object frmCompilerOptions: TfrmCompilerOptions
Width = 267
end
end
inherited Splitter1: TSplitter
Height = 197
end
inherited BuildMacrosTreeView: TTreeView
Height = 197
end
inherited MacrosSplitter: TSplitter
Width = 531
end
inherited ConditionalsGroupBox: TGroupBox
Height = 187
Width = 531
ClientHeight = 168
ClientWidth = 527
inherited CondSynEdit: TSynEdit
Height = 168
Width = 527
end
end
end

View File

@ -47,7 +47,7 @@ uses
TransferMacros, PathEditorDlg, LazarusIDEStrConsts, IDEOptionDefs, LazConf,
IDEProcs, IDEImagesIntf, ShowCompilerOpts, Project, PackageDefs, IDEMsgIntf,
CompilerOptions, CheckCompilerOpts, CompOptsModes, BuildModesEditor,
Compiler_CondTree, Compiler_BuildMacro_Options, CheckLst;
Compiler_BuildMacro_Options, CheckLst;
type
{ TfrmCompilerOptions }
@ -115,7 +115,6 @@ type
grpTargetPlatform: TGroupBox;
lblTargetOS : TLabel;
ConditionalSplitter: TSplitter;
CategorySplitter: TSplitter;
TargetOSComboBox: TComboBox;
lblTargetCPU : TLabel;
@ -179,11 +178,8 @@ type
grpCustomOptions: TGroupBox;
memCustomOptions: TMemo;
{ Conditionals }
ConditionalPage: TPage;
ConditionalOptionsFrame: TCompOptsCondTreeFrame;
ConditionalsGroupBox: TGroupBox;
BuildMacrosGroupBox: TGroupBox;
{ Build Macros and Conditionals }
MacrosPage: TPage;
BuildMacrosFrame: TCompOptBuildMacrosFrame;
{ Inherited Options }
@ -264,7 +260,7 @@ type
procedure SetupVerbosityTab(Page: integer);
procedure SetupConfigMsgTab(Page: integer);
procedure SetupOtherTab(Page: integer);
procedure SetupConditionalsTab(Page: integer);
procedure SetupMacrosTab(Page: integer);
procedure SetupInheritedTab(Page: integer);
procedure SetupCompilationTab(Page: integer);
procedure SetupButtonBar;
@ -451,7 +447,7 @@ begin
inc(Page);
SetupOtherTab(Page);
inc(Page);
SetupConditionalsTab(Page);
SetupMacrosTab(Page);
inc(Page);
SetupInheritedTab(Page);
inc(Page);
@ -785,10 +781,9 @@ begin
edtErrorCnt.Text := IntToStr(Options.StopAfterErrCount);
// conditional + build macros
// conditionals + build macros
{$IFDEF EnableBuildModes}
ConditionalOptionsFrame.Conditionals:=Options.Conditionals as TCompOptConditionals;
BuildMacrosFrame.BuildMacros:=Options.BuildMacros as TIDEBuildMacros;
BuildMacrosFrame.Options:=Options;
{$ENDIF}
// inherited tab
@ -1520,15 +1515,13 @@ begin
grpCustomOptions.Caption:=lisCustomOptions2;
end;
procedure TfrmCompilerOptions.SetupConditionalsTab(Page: integer);
procedure TfrmCompilerOptions.SetupMacrosTab(Page: integer);
begin
ConditionalPage:=MainNoteBook.Page[Page];
ConditionalPage.Caption:=dlgCOConditionals;
MacrosPage:=MainNoteBook.Page[Page];
MacrosPage.Caption:='Build macros';
{$IFDEF EnableBuildModes}
CategoryTreeView.Items.AddObject(nil,ConditionalPage.Caption,ConditionalPage);
CategoryTreeView.Items.AddObject(nil,MacrosPage.Caption,MacrosPage);
{$ENDIF}
ConditionalsGroupBox.Caption:=dlgOIOptions;
BuildMacrosGroupBox.Caption:=lisCustomBuildMacros;
end;
{------------------------------------------------------------------------------

View File

@ -70,338 +70,8 @@ type
property Differ: boolean read FDiffer write SetDiffer;
end;
{ TCompOptConditionals }
TCompOptConditionals = class(TLazCompOptConditionals)
private
FChangeStamp: integer;
FErrorMsg: string;
FErrorNode: TCompOptCondNode;
FEvaluator: TExpressionEvaluator;
FEvaluatorStamp: integer;
FValuesValid: boolean;
FValues: array[TCOCValueType] of string;
function GetValues(const ValueType: TCOCValueType): string;
procedure SetEvaluator(const AValue: TExpressionEvaluator);
procedure AddValue(const ValueType: TCOCValueType; Value: string);
procedure SetValue(const ValueType: TCOCValueType; Value: string);
public
constructor Create;
destructor Destroy; override;
procedure Clear;
procedure ClearNodes;
procedure InvalidateValues; override;
procedure Assign(Source: TLazCompOptConditionals); override;
procedure CreateDiff(CompOpts: TLazCompOptConditionals;
Tool: TCompilerDiffTool); virtual;
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string;
DoSwitchPathDelims: boolean); virtual;
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string;
UsePathDelim: TPathDelimSwitch); virtual;
property Values[ValueType: TCOCValueType]: string read GetValues;
property Evaluator: TExpressionEvaluator read FEvaluator write SetEvaluator;
property ChangeStamp: integer read FChangeStamp;
procedure IncreaseChangeStamp; inline;
procedure WriteDebugReport;
property ErrorNode: TCompOptCondNode read FErrorNode write FErrorNode;
property ErrorMsg: string read FErrorMsg write FErrorMsg;
end;
implementation
{ TCompOptConditionals }
function TCompOptConditionals.GetValues(const ValueType: TCOCValueType): string;
function ComputeIfNode(Node: TCompOptCondNode;
out ExprResult: boolean): boolean;
var
ResultStr: String;
begin
case Node.NodeType of
cocntIf,cocntElseIf:
begin
ResultStr:=FEvaluator.Eval(Node.Value);
if FEvaluator.ErrorPosition>=0 then begin
FErrorNode:=Node;
FErrorMsg:='error in expression at column '+IntToStr(FEvaluator.ErrorPosition);
exit(false);
end;
ExprResult:=ResultStr<>'0';
end;
cocntIfdef:
ExprResult:=FEvaluator.IsDefined(Node.Value);
cocntIfNdef:
ExprResult:=not FEvaluator.IsDefined(Node.Value);
else
FErrorNode:=Node;
FErrorMsg:='unexpected node of type '+COCNodeTypeNames[Node.NodeType];
exit(false);
end;
Result:=true;
end;
function ComputeNode(ParentNode: TCompOptCondNode; Index: integer): boolean;
var
ExprResult: boolean;
Node: TCompOptCondNode;
begin
Result:=false;
while Index<ParentNode.Count do begin
Node:=ParentNode.Childs[Index];
case Node.NodeType of
cocntIf,cocntIfdef,cocntIfNdef:
while true do begin
if (Node.NodeType=cocntElse) then
ExprResult:=true
else if (not ComputeIfNode(Node,ExprResult)) then
exit;
if ExprResult then begin
// execute childs
if Node.Count>0 then
if not ComputeNode(Node,0) then exit;
// skip all else
inc(Index);
while (Index<ParentNode.Count) do begin
Node:=ParentNode.Childs[Index];
if not (Node.NodeType in [cocntElseIf,cocntElse]) then break;
if ParentNode.Childs[Index-1].NodeType=cocntElse then begin
FErrorNode:=Node;
FErrorMsg:='ElseIf not allowed after Else';
exit(false);
end;
inc(Index);
end;
break;
end else begin
// skip childs
inc(Index);
end;
if Index>=ParentNode.Count then break;
Node:=ParentNode.Childs[Index];
end;
cocntAddValue:
begin
AddValue(Node.ValueType,Node.Value);
inc(Index);
end;
cocntSetValue:
begin
SetValue(Node.ValueType,Node.Value);
inc(Index);
end;
else
fErrorNode:=Node;
FErrorMsg:='unexpected node of type '+COCNodeTypeNames[Node.NodeType];
exit(false);
end;
end;
Result:=true;
end;
var
v: TCOCValueType;
begin
if FEvaluator=nil then begin
Result:='';
exit;
end;
if (not FValuesValid)
or (FEvaluator.ChangeStamp<>FEvaluatorStamp) then begin
for v:=Low(FValues) to High(FValues) do
FValues[v]:='';
ComputeNode(Root,0);
FValuesValid:=true;
FEvaluatorStamp:=FEvaluator.ChangeStamp;
end;
Result:=FValues[ValueType];
end;
procedure TCompOptConditionals.SetEvaluator(const AValue: TExpressionEvaluator
);
begin
if FEvaluator=AValue then exit;
FEvaluator:=AValue;
InvalidateValues;
end;
procedure TCompOptConditionals.AddValue(const ValueType: TCOCValueType;
Value: string);
begin
Value:=Trim(Value);
if Value='' then exit;
case ValueType of
cocvtUnitPath,cocvtSrcPath,cocvtIncludePath,cocvtObjectPath,cocvtLibraryPath,
cocvtDebugPath:
begin
FValues[ValueType]:=MergeSearchPaths(FValues[ValueType],Value);
end;
cocvtLinkerOptions,cocvtCustomOptions:
begin
if FValues[ValueType]<>'' then
FValues[ValueType]:=FValues[ValueType]+' ';
FValues[ValueType]:=FValues[ValueType]+Value;
end;
else
FValues[ValueType]:=FValues[ValueType]+Value;
end;
end;
procedure TCompOptConditionals.SetValue(const ValueType: TCOCValueType;
Value: string);
begin
FValues[ValueType]:=Trim(Value);
end;
constructor TCompOptConditionals.Create;
begin
FEvaluator:=TExpressionEvaluator.Create;
inherited Create;
end;
destructor TCompOptConditionals.Destroy;
begin
Clear;
FreeAndNil(FEvaluator);
inherited Destroy;
end;
procedure TCompOptConditionals.Clear;
begin
ClearNodes;
end;
procedure TCompOptConditionals.ClearNodes;
begin
FValuesValid:=false;
FErrorNode:=nil;
FErrorMsg:='';
Root.ClearNodes;
end;
procedure TCompOptConditionals.InvalidateValues;
begin
FValuesValid:=false;
FErrorNode:=nil;
FErrorMsg:='';
end;
procedure TCompOptConditionals.Assign(Source: TLazCompOptConditionals);
begin
ClearNodes;
Root.Assign(Source.Root);
end;
procedure TCompOptConditionals.CreateDiff(CompOpts: TLazCompOptConditionals;
Tool: TCompilerDiffTool);
procedure Diff(CurNode, OtherNode: TCompOptCondNode);
var
i: Integer;
OldPath: String;
begin
Tool.AddDiff('NodeType',COCNodeTypeNames[CurNode.NodeType],COCNodeTypeNames[OtherNode.NodeType]);
Tool.AddDiff('ValueType',COCValueTypeNames[CurNode.ValueType],COCValueTypeNames[OtherNode.ValueType]);
Tool.AddDiff('Value',CurNode.Value,OtherNode.Value);
if CurNode.Count<>OtherNode.Count then begin
Tool.AddDiff('Count',IntToStr(CurNode.Count),IntToStr(OtherNode.Count));
exit;
end;
for i:=0 to CurNode.Count-1 do begin
OldPath:=Tool.Path;
Tool.Path:=Tool.Path+'Item'+IntToStr(i+1)+'/';
Diff(CurNode.Childs[i],OtherNode.Childs[i]);
Tool.Path:=OldPath;
end;
end;
begin
Diff(Root,CompOpts.Root);
end;
procedure TCompOptConditionals.LoadFromXMLConfig(XMLConfig: TXMLConfig;
const Path: string; DoSwitchPathDelims: boolean);
procedure LoadNode(Node: TCompOptCondNode; const SubPath: string);
var
NewCount: LongInt;
i: Integer;
NewChild: TCompOptCondNode;
s: String;
begin
Node.ClearNodes;
Node.NodeType:=COCNodeTypeNameToType(XMLConfig.GetValue(SubPath+'NodeType',''));
Node.ValueType:=COCValueTypeNameToType(XMLConfig.GetValue(SubPath+'ValueType',''));
s:=XMLConfig.GetValue(SubPath+'Value','');
Node.Value:=SwitchPathDelims(s,DoSwitchPathDelims);
// load childs
NewCount:=XMLConfig.GetValue(SubPath+'ChildCount',0);
for i:=1 to NewCount do begin
NewChild:=TCompOptCondNode.Create(Node.Owner);
Node.AddLast(NewChild);
LoadNode(NewChild,SubPath+'Item'+IntToStr(i)+'/');
end;
end;
begin
LoadNode(Root,Path);
Root.NodeType:=cocntNone;
Root.ValueType:=cocvtNone;
Root.Value:='';
end;
procedure TCompOptConditionals.SaveToXMLConfig(XMLConfig: TXMLConfig;
const Path: string; UsePathDelim: TPathDelimSwitch);
procedure SaveNode(Node: TCompOptCondNode; const SubPath: string);
var
i: Integer;
s: String;
begin
XMLConfig.SetDeleteValue(SubPath+'NodeType',COCNodeTypeNames[Node.NodeType],
COCNodeTypeNames[cocntNone]);
XMLConfig.SetDeleteValue(SubPath+'ValueType',COCValueTypeNames[Node.ValueType],
COCValueTypeNames[cocvtNone]);
s:=SwitchPathDelims(Node.Value,UsePathDelim);
XMLConfig.SetDeleteValue(SubPath+'Value',s,'');
// save childs
XMLConfig.SetDeleteValue(SubPath+'ChildCount',Node.Count,0);
for i:=0 to Node.Count-1 do
SaveNode(Node.Childs[i],SubPath+'Item'+IntToStr(i+1)+'/');
end;
begin
SaveNode(Root,Path);
end;
procedure TCompOptConditionals.IncreaseChangeStamp; inline;
begin
if FChangeStamp<High(Integer) then
inc(FChangeStamp)
else
FChangeStamp:=Low(Integer);
end;
procedure TCompOptConditionals.WriteDebugReport;
procedure WriteNode(Prefix: string; Node: TCompOptCondNode);
var
i: Integer;
begin
DebugLn([Prefix,'Type=',COCNodeTypeNames[Node.NodeType],' Value=',Node.Value]);
for i:=0 to Node.Count-1 do
WriteNode(Prefix+' ',Node.Childs[i]);
end;
begin
DebugLn(['TCompOptConditionals.WriteDebugReport ']);
WriteNode(' ',Root);
end;
{ TCompilerDiffTool }
procedure TCompilerDiffTool.SetDiff(const AValue: TStrings);

View File

@ -1,85 +1,843 @@
object CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame
Left = 0
Height = 233
Height = 430
Top = 0
Width = 578
ClientHeight = 233
ClientWidth = 578
Width = 496
ClientHeight = 430
ClientWidth = 496
TabOrder = 0
Visible = False
DesignLeft = 349
DesignTop = 520
object BuildMacroSelectedGroupBox: TGroupBox
Left = 244
Height = 233
Top = 0
Width = 334
Align = alClient
BorderSpacing.Left = 6
Caption = 'BuildMacroSelectedGroupBox'
ClientHeight = 214
ClientWidth = 330
TabOrder = 0
object BuildMacroDefaultLabel: TLabel
Left = 6
Height = 18
Top = 72
Width = 318
Align = alTop
BorderSpacing.Top = 15
BorderSpacing.Around = 6
Caption = 'BuildMacroDefaultLabel'
ParentColor = False
end
object BuildMacroDescriptionLabel: TLabel
Left = 6
Height = 18
Top = 6
Width = 318
Align = alTop
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'BuildMacroDescriptionLabel'
ParentColor = False
end
object BuildMacroDescriptionEdit: TEdit
Left = 6
Height = 27
Top = 24
Width = 318
Align = alTop
BorderSpacing.Left = 6
BorderSpacing.Right = 6
TabOrder = 0
Text = 'BuildMacroDescriptionEdit'
end
end
object Splitter1: TSplitter
Left = 233
Height = 233
Top = 0
Width = 5
end
object BuildMacrosTreeView: TTreeView
DesignLeft = 308
DesignTop = 268
object MacrosGroupBox: TGroupBox
Left = 0
Height = 233
Height = 243
Top = 0
Width = 227
Align = alLeft
BorderSpacing.Right = 6
DefaultItemHeight = 19
PopupMenu = BuildMacrosTVPopupMenu
RightClickSelect = True
Width = 496
Align = alTop
Caption = 'MacrosGroupBox'
ClientHeight = 224
ClientWidth = 492
TabOrder = 0
object BuildMacrosTreeView: TTreeView
Left = 0
Height = 224
Top = 0
Width = 227
Align = alLeft
BorderSpacing.Right = 6
DefaultItemHeight = 19
PopupMenu = BuildMacrosTVPopupMenu
RightClickSelect = True
TabOrder = 0
OnEdited = BuildMacrosTreeViewEdited
OnEditing = BuildMacrosTreeViewEditing
OnSelectionChanged = BuildMacrosTreeViewSelectionChanged
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoRightClickSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips]
end
object Splitter1: TSplitter
Left = 233
Height = 224
Top = 0
Width = 5
end
object BuildMacroSelectedGroupBox: TGroupBox
Left = 244
Height = 224
Top = 0
Width = 248
Align = alClient
BorderSpacing.Left = 6
Caption = 'BuildMacroSelectedGroupBox'
ClientHeight = 205
ClientWidth = 244
TabOrder = 2
object BuildMacroDefaultLabel: TLabel
Left = 6
Height = 18
Top = 72
Width = 232
Align = alTop
BorderSpacing.Top = 15
BorderSpacing.Around = 6
Caption = 'BuildMacroDefaultLabel'
ParentColor = False
end
object BuildMacroDescriptionLabel: TLabel
Left = 6
Height = 18
Top = 6
Width = 232
Align = alTop
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'BuildMacroDescriptionLabel'
ParentColor = False
end
object BuildMacroDescriptionEdit: TEdit
Left = 6
Height = 27
Top = 24
Width = 232
Align = alTop
BorderSpacing.Left = 6
BorderSpacing.Right = 6
TabOrder = 0
Text = 'BuildMacroDescriptionEdit'
end
end
end
object MacrosSplitter: TSplitter
Cursor = crVSplit
Left = 0
Height = 5
Top = 243
Width = 496
Align = alTop
ResizeAnchor = akTop
end
object ConditionalsGroupBox: TGroupBox
Left = 0
Height = 182
Top = 248
Width = 496
Align = alClient
Caption = 'ConditionalsGroupBox'
ClientHeight = 163
ClientWidth = 492
TabOrder = 2
OnEdited = BuildMacrosTreeViewEdited
OnEditing = BuildMacrosTreeViewEditing
OnSelectionChanged = BuildMacrosTreeViewSelectionChanged
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoRightClickSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips]
inline CondSynEdit: TSynEdit
Left = 0
Height = 163
Top = 0
Width = 492
Align = alClient
Font.Height = 9
Font.Name = '-misc-dejavu sans mono-*-*-*-*-*-*-*-*-*-*-iso10646-1'
Font.Pitch = fpFixed
Font.Quality = fqNonAntialiased
ParentColor = False
ParentFont = False
TabOrder = 0
Gutter.Width = 55
Gutter.MouseActions = <
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 13
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbRight
ClickCount = ccSingle
ClickDir = cdUp
Command = 12
MoveCaret = False
Option = 0
Priority = 0
end>
RightGutter.Width = 0
RightGutter.MouseActions = <
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 13
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbRight
ClickCount = ccSingle
ClickDir = cdUp
Command = 12
MoveCaret = False
Option = 0
Priority = 0
end>
Highlighter = ConditionalsSynPasSyn
Keystrokes = <
item
Command = ecUp
ShortCut = 38
end
item
Command = ecSelUp
ShortCut = 8230
end
item
Command = ecScrollUp
ShortCut = 16422
end
item
Command = ecDown
ShortCut = 40
end
item
Command = ecSelDown
ShortCut = 8232
end
item
Command = ecScrollDown
ShortCut = 16424
end
item
Command = ecLeft
ShortCut = 37
end
item
Command = ecSelLeft
ShortCut = 8229
end
item
Command = ecWordLeft
ShortCut = 16421
end
item
Command = ecSelWordLeft
ShortCut = 24613
end
item
Command = ecRight
ShortCut = 39
end
item
Command = ecSelRight
ShortCut = 8231
end
item
Command = ecWordRight
ShortCut = 16423
end
item
Command = ecSelWordRight
ShortCut = 24615
end
item
Command = ecPageDown
ShortCut = 34
end
item
Command = ecSelPageDown
ShortCut = 8226
end
item
Command = ecPageBottom
ShortCut = 16418
end
item
Command = ecSelPageBottom
ShortCut = 24610
end
item
Command = ecPageUp
ShortCut = 33
end
item
Command = ecSelPageUp
ShortCut = 8225
end
item
Command = ecPageTop
ShortCut = 16417
end
item
Command = ecSelPageTop
ShortCut = 24609
end
item
Command = ecLineStart
ShortCut = 36
end
item
Command = ecSelLineStart
ShortCut = 8228
end
item
Command = ecEditorTop
ShortCut = 16420
end
item
Command = ecSelEditorTop
ShortCut = 24612
end
item
Command = ecLineEnd
ShortCut = 35
end
item
Command = ecSelLineEnd
ShortCut = 8227
end
item
Command = ecEditorBottom
ShortCut = 16419
end
item
Command = ecSelEditorBottom
ShortCut = 24611
end
item
Command = ecToggleMode
ShortCut = 45
end
item
Command = ecCopy
ShortCut = 16429
end
item
Command = ecPaste
ShortCut = 8237
end
item
Command = ecDeleteChar
ShortCut = 46
end
item
Command = ecCut
ShortCut = 8238
end
item
Command = ecDeleteLastChar
ShortCut = 8
end
item
Command = ecDeleteLastChar
ShortCut = 8200
end
item
Command = ecDeleteLastWord
ShortCut = 16392
end
item
Command = ecUndo
ShortCut = 32776
end
item
Command = ecRedo
ShortCut = 40968
end
item
Command = ecLineBreak
ShortCut = 13
end
item
Command = ecSelectAll
ShortCut = 16449
end
item
Command = ecCopy
ShortCut = 16451
end
item
Command = ecBlockIndent
ShortCut = 24649
end
item
Command = ecLineBreak
ShortCut = 16461
end
item
Command = ecInsertLine
ShortCut = 16462
end
item
Command = ecDeleteWord
ShortCut = 16468
end
item
Command = ecBlockUnindent
ShortCut = 24661
end
item
Command = ecPaste
ShortCut = 16470
end
item
Command = ecCut
ShortCut = 16472
end
item
Command = ecDeleteLine
ShortCut = 16473
end
item
Command = ecDeleteEOL
ShortCut = 24665
end
item
Command = ecUndo
ShortCut = 16474
end
item
Command = ecRedo
ShortCut = 24666
end
item
Command = ecGotoMarker0
ShortCut = 16432
end
item
Command = ecGotoMarker1
ShortCut = 16433
end
item
Command = ecGotoMarker2
ShortCut = 16434
end
item
Command = ecGotoMarker3
ShortCut = 16435
end
item
Command = ecGotoMarker4
ShortCut = 16436
end
item
Command = ecGotoMarker5
ShortCut = 16437
end
item
Command = ecGotoMarker6
ShortCut = 16438
end
item
Command = ecGotoMarker7
ShortCut = 16439
end
item
Command = ecGotoMarker8
ShortCut = 16440
end
item
Command = ecGotoMarker9
ShortCut = 16441
end
item
Command = ecSetMarker0
ShortCut = 24624
end
item
Command = ecSetMarker1
ShortCut = 24625
end
item
Command = ecSetMarker2
ShortCut = 24626
end
item
Command = ecSetMarker3
ShortCut = 24627
end
item
Command = ecSetMarker4
ShortCut = 24628
end
item
Command = ecSetMarker5
ShortCut = 24629
end
item
Command = ecSetMarker6
ShortCut = 24630
end
item
Command = ecSetMarker7
ShortCut = 24631
end
item
Command = ecSetMarker8
ShortCut = 24632
end
item
Command = ecSetMarker9
ShortCut = 24633
end
item
Command = EcFoldLevel1
ShortCut = 41009
end
item
Command = EcFoldLevel2
ShortCut = 41010
end
item
Command = EcFoldLevel1
ShortCut = 41011
end
item
Command = EcFoldLevel1
ShortCut = 41012
end
item
Command = EcFoldLevel1
ShortCut = 41013
end
item
Command = EcFoldLevel6
ShortCut = 41014
end
item
Command = EcFoldLevel7
ShortCut = 41015
end
item
Command = EcFoldLevel8
ShortCut = 41016
end
item
Command = EcFoldLevel9
ShortCut = 41017
end
item
Command = EcFoldLevel0
ShortCut = 41008
end
item
Command = EcFoldCurrent
ShortCut = 41005
end
item
Command = EcUnFoldCurrent
ShortCut = 41003
end
item
Command = EcToggleMarkupWord
ShortCut = 32845
end
item
Command = ecNormalSelect
ShortCut = 24654
end
item
Command = ecColumnSelect
ShortCut = 24643
end
item
Command = ecLineSelect
ShortCut = 24652
end
item
Command = ecTab
ShortCut = 9
end
item
Command = ecShiftTab
ShortCut = 8201
end
item
Command = ecMatchBracket
ShortCut = 24642
end
item
Command = ecColSelUp
ShortCut = 40998
end
item
Command = ecColSelDown
ShortCut = 41000
end
item
Command = ecColSelLeft
ShortCut = 40997
end
item
Command = ecColSelRight
ShortCut = 40999
end
item
Command = ecColSelPageDown
ShortCut = 40994
end
item
Command = ecColSelPageBottom
ShortCut = 57378
end
item
Command = ecColSelPageUp
ShortCut = 40993
end
item
Command = ecColSelPageTop
ShortCut = 57377
end
item
Command = ecColSelLineStart
ShortCut = 40996
end
item
Command = ecColSelLineEnd
ShortCut = 40995
end
item
Command = ecColSelEditorTop
ShortCut = 57380
end
item
Command = ecColSelEditorBottom
ShortCut = 57379
end>
MouseActions = <
item
Shift = []
ShiftMask = [ssShift, ssAlt]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown
Command = 1
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = [ssShift]
ShiftMask = [ssShift, ssAlt]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown
Command = 1
MoveCaret = True
Option = 1
Priority = 0
end
item
Shift = [ssAlt]
ShiftMask = [ssShift, ssAlt]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown
Command = 3
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = [ssShift, ssAlt]
ShiftMask = [ssShift, ssAlt]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown
Command = 3
MoveCaret = True
Option = 1
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbRight
ClickCount = ccSingle
ClickDir = cdUp
Command = 12
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccDouble
ClickDir = cdDown
Command = 6
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccTriple
ClickDir = cdDown
Command = 7
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccQuad
ClickDir = cdDown
Command = 8
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbMiddle
ClickCount = ccSingle
ClickDir = cdDown
Command = 10
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = [ssCtrl]
ShiftMask = [ssShift, ssAlt, ssCtrl]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdUp
Command = 11
MoveCaret = False
Option = 0
Priority = 0
end>
MouseSelActions = <
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown
Command = 9
MoveCaret = False
Option = 0
Priority = 0
end>
Lines.Strings = (
'CondSynEdit'
)
BracketHighlightStyle = sbhsBoth
inline SynLeftGutterPartList1: TSynGutterPartList
object SynGutterMarks1: TSynGutterMarks
Width = 24
end
object SynGutterLineNumber1: TSynGutterLineNumber
Width = 15
MouseActions = <>
MarkupInfo.Background = clBtnFace
MarkupInfo.Foreground = clNone
DigitCount = 2
ShowOnlyLineNumbersMultiplesOf = 1
ZeroStart = False
LeadingZeros = False
end
object SynGutterChanges1: TSynGutterChanges
Width = 4
ModifiedColor = 59900
SavedColor = clGreen
end
object SynGutterSeparator1: TSynGutterSeparator
Width = 2
end
object SynGutterCodeFolding1: TSynGutterCodeFolding
MouseActions = <
item
Shift = []
ShiftMask = []
Button = mbRight
ClickCount = ccSingle
ClickDir = cdUp
Command = 16
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = [ssShift]
Button = mbMiddle
ClickCount = ccAny
ClickDir = cdDown
Command = 14
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = [ssShift]
ShiftMask = [ssShift]
Button = mbMiddle
ClickCount = ccAny
ClickDir = cdDown
Command = 14
MoveCaret = False
Option = 1
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 0
MoveCaret = False
Option = 0
Priority = 0
end>
MarkupInfo.Background = clNone
MarkupInfo.Foreground = clGray
MouseActionsExpanded = <
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 14
MoveCaret = False
Option = 0
Priority = 0
end>
MouseActionsCollapsed = <
item
Shift = [ssCtrl]
ShiftMask = [ssCtrl]
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 15
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = [ssCtrl]
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 15
MoveCaret = False
Option = 1
Priority = 0
end>
end
end
inline SynRightGutterPartList1: TSynRightGutterPartList
end
end
end
object BuildMacrosTVPopupMenu: TPopupMenu
OnPopup = BuildMacrosTVPopupMenuPopup
left = 99
top = 77
end
object ConditionalsSynPasSyn: TSynPasSyn
Enabled = False
CompilerMode = pcmDelphi
NestedComments = False
left = 182
top = 313
end
end

View File

@ -30,7 +30,7 @@ interface
uses
Classes, SysUtils, LCLProc, FileUtil, Controls, Forms, StdCtrls, Grids,
Buttons, ExtCtrls, Dialogs, ComCtrls, Menus, AvgLvlTree, IDEImagesIntf,
ProjectIntf, PackageIntf, CompilerOptions, Compiler_CondTree,
ProjectIntf, PackageIntf, CompilerOptions,
LazarusIDEStrConsts, CompOptsModes, PackageDefs, SynEdit, SynHighlighterPas;
type
@ -49,6 +49,11 @@ type
BuildMacrosTVPopupMenu: TPopupMenu;
BuildMacroDefaultLabel: TLabel;
BuildMacroDescriptionLabel: TLabel;
ConditionalsGroupBox: TGroupBox;
ConditionalsSynPasSyn: TSynPasSyn;
CondSynEdit: TSynEdit;
MacrosGroupBox: TGroupBox;
MacrosSplitter: TSplitter;
Splitter1: TSplitter;
procedure BuildMacrosTreeViewEdited(Sender: TObject; Node: TTreeNode;
var S: string);
@ -62,12 +67,14 @@ type
procedure DeleteValueClick(Sender: TObject);
private
FBuildMacros: TIDEBuildMacros;
FOptions: TBaseCompilerOptions;
fVarImgID: LongInt;
fValueImgID: LongInt;
fDefValueImgID: LongInt;
procedure SaveItemProperties;
procedure SetBuildMacros(const AValue: TIDEBuildMacros);
procedure RebuildTreeView;
procedure SetOptions(const AValue: TBaseCompilerOptions);
function TreeViewAddBuildMacro(aBuildMacro: TLazBuildMacro): TTreeNode;
procedure TreeViewAddValue(ValuesTVNode: TTreeNode; aValue: string);
function GetNodeInfo(Node: TTreeNode; out BuildMacro: TLazBuildMacro): TCBMNodeType;
@ -80,6 +87,7 @@ type
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
property BuildMacros: TIDEBuildMacros read FBuildMacros write SetBuildMacros;
property Options: TBaseCompilerOptions read FOptions write SetOptions;
end;
implementation
@ -302,6 +310,15 @@ begin
BuildMacrosTreeView.EndUpdate;
end;
procedure TCompOptBuildMacrosFrame.SetOptions(const AValue: TBaseCompilerOptions
);
begin
if FOptions=AValue then exit;
FOptions:=AValue;
BuildMacros:=Options.BuildMacros as TIDEBuildMacros;
CondSynEdit.Lines.Text:=Options.Conditionals;
end;
function TCompOptBuildMacrosFrame.TreeViewAddBuildMacro(
aBuildMacro: TLazBuildMacro): TTreeNode;
var
@ -409,12 +426,14 @@ begin
GetSelectedNode(BuildMacro,NodeType);
if BuildMacro=nil then exit;
BuildMacro.Description:=BuildMacroDescriptionEdit.Text;
Options.Conditionals:=CondSynEdit.Lines.Text;
end;
constructor TCompOptBuildMacrosFrame.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
MacrosGroupBox.Caption:='Build macros:';
BuildMacrosTreeView.Images := IDEImages.Images_24;
fVarImgID:=IDEImages.LoadImage(24,'da_define');
fValueImgID:=IDEImages.LoadImage(24,'da_define');
@ -422,6 +441,8 @@ begin
BuildMacroDefaultLabel.Caption:='Hint: A default value can be defined in the conditionals.';
BuildMacroDescriptionLabel.Caption:='Description:';
ConditionalsGroupBox.Caption:='Conditionals:';
end;
destructor TCompOptBuildMacrosFrame.Destroy;

View File

@ -1,49 +0,0 @@
object CompOptsConditionalsFrame: TCompOptsConditionalsFrame
Left = 0
Height = 411
Top = 0
Width = 499
ClientHeight = 411
ClientWidth = 499
TabOrder = 0
DesignLeft = 426
DesignTop = 475
object ConditionalsGroupBox: TGroupBox
Left = 0
Height = 200
Top = 0
Width = 499
Align = alTop
Caption = 'ConditionalsGroupBox'
ClientHeight = 181
ClientWidth = 495
TabOrder = 1
inline ConditionalsTreeFrame: TCompOptsCondTreeFrame
Height = 181
Width = 495
Align = alClient
ClientHeight = 181
ClientWidth = 495
Visible = True
inherited COCTreeView: TTreeView
Height = 181
Width = 495
end
end
end
object ConditionalsSplitter: TSplitter
Cursor = crVSplit
Left = 0
Height = 5
Top = 200
Width = 499
Align = alTop
ResizeAnchor = akTop
end
inline BuildMacrosFrame: TCompOptBuildMacrosFrame
Left = 51
Top = 13
Align = alClient
Visible = True
end
end

View File

@ -1,56 +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. *
* *
***************************************************************************
Author: Mattias Gaertner
Abstract:
Frame for compiler options to edit build macros and conditionals.
}
unit Compiler_Conditionals_Options;
{$mode objfpc}
interface
uses
Classes, SysUtils, FileUtil, Forms, StdCtrls, ExtCtrls,
Compiler_CondTree, Compiler_BuildMacro_Options;
type
{ TCompOptsConditionalsFrame }
TCompOptsConditionalsFrame = class(TFrame)
BuildMacrosFrame: TCompOptBuildMacrosFrame;
BuildMacrosGroupBox: TGroupBox;
ConditionalsGroupBox: TGroupBox;
ConditionalsSplitter: TSplitter;
ConditionalsTreeFrame: TCompOptsCondTreeFrame;
private
{ private declarations }
public
{ public declarations }
end;
implementation
{$R *.lfm}
end.

View File

@ -1,32 +0,0 @@
object CompOptsCondTreeFrame: TCompOptsCondTreeFrame
Left = 0
Height = 170
Top = 0
Width = 385
ClientHeight = 170
ClientWidth = 385
TabOrder = 0
Visible = False
DesignLeft = 449
DesignTop = 401
object COCTreeView: TTreeView
Left = 0
Height = 170
Top = 0
Width = 385
Align = alClient
AutoExpand = True
DefaultItemHeight = 19
PopupMenu = COCPopupMenu
RowSelect = True
TabOrder = 0
OnEdited = COCTreeViewEdited
OnEditing = COCTreeViewEditing
Options = [tvoAutoExpand, tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoRowSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoShowSeparators, tvoToolTips]
end
object COCPopupMenu: TPopupMenu
OnPopup = COCPopupMenuPopup
left = 48
top = 48
end
end

View File

@ -1,623 +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. *
* *
***************************************************************************
Author: Mattias Gaertner
Abstract:
TCompOptsCondTreeFrame is a frame to edit conditional compiler options.
}
unit Compiler_CondTree;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LCLProc, FileProcs, Controls, Forms, ComCtrls,
Menus, Dialogs,
ProjectIntf, IDEImagesIntf,
LazarusIDEStrConsts, CompOptsModes, CompOptCondPropsDlg;
type
{ TCompOptsExprEditor }
TCompOptsExprEditor = class(TComponent)
procedure DeleteMenuItemClick(Sender: TObject);
procedure InsertAboveMenuItemClick(Sender: TObject);
procedure InsertBelowMenuItemClick(Sender: TObject);
procedure InsertChildMenuItemClick(Sender: TObject);
procedure MoveDownMenuItemClick(Sender: TObject);
procedure MoveLvlDownMenuItemClick(Sender: TObject);
procedure MoveLvlUpMenuItemClick(Sender: TObject);
procedure MoveUpMenuItemClick(Sender: TObject);
procedure PropertiesMenuItemClick(Sender: TObject);
private
FAllowedValueTypes: TCOCValueTypes;
FConditionals: TCompOptConditionals;
FDefaultNodeType: TCOCNodeType;
FDefaultValue: string;
FDefaultValueType: TCOCValueType;
FRootNode: TTreeNode;
FTreeView: TTreeView;
FNodeTypeImageIDs: array[TCOCNodeType] of integer;
procedure SetAllowedValueTypes(const AValue: TCOCValueTypes);
procedure SetConditionals(const AValue: TCompOptConditionals);
procedure SetRootNode(const AValue: TTreeNode);
procedure SetTreeView(const AValue: TTreeView);
procedure ClearTreeView;
function NodeToCaption(Node: TCompOptCondNode): string;
procedure FillTreeView;
procedure ConsistencyCheck;
function GetSelectedNode(out COCNode: TCompOptCondNode;
out TVNode: TTreeNode; RootAsDefault: boolean): boolean;
procedure CreateNewNode(AttachMode: TNodeAttachMode);
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure FillPopupMenu(aPopupMenu: TPopupMenu);
procedure TreeViewEditing(Sender: TObject; Node: TTreeNode;
var AllowEdit: Boolean);
procedure TreeViewEdited(Sender: TObject; Node: TTreeNode; var S: string);
procedure Setup(NewTreeView: TTreeView; NewRootNode: TTreeNode;
NewConditionals: TCompOptConditionals; NewAllowedValueTypes: TCOCValueTypes);
property TreeView: TTreeView read FTreeView write SetTreeView;
property RootNode: TTreeNode read FRootNode write SetRootNode;
property Conditionals: TCompOptConditionals read FConditionals write SetConditionals;
property AllowedValueTypes: TCOCValueTypes read FAllowedValueTypes write SetAllowedValueTypes;
property DefaultNodeType: TCOCNodeType read FDefaultNodeType write FDefaultNodeType;
property DefaultValueType: TCOCValueType read FDefaultValueType write FDefaultValueType;
property DefaultValue: string read FDefaultValue write FDefaultValue;
end;
{ TCompOptsCondTreeFrame }
TCompOptsCondTreeFrame = class(TFrame)
COCTreeView: TTreeView;
COCPopupMenu: TPopupMenu;
procedure COCPopupMenuPopup(Sender: TObject);
procedure COCTreeViewEdited(Sender: TObject; Node: TTreeNode; var S: string
);
procedure COCTreeViewEditing(Sender: TObject; Node: TTreeNode;
var AllowEdit: Boolean);
private
FEditor: TCompOptsExprEditor;
function GetAllowedValueTypes: TCOCValueTypes;
function GetConditionals: TCompOptConditionals;
procedure SetAllowedValueTypes(const AValue: TCOCValueTypes);
procedure SetConditionals(const AValue: TCompOptConditionals);
public
constructor Create(TheOwner: TComponent); override;
property Conditionals: TCompOptConditionals read GetConditionals write SetConditionals;
property AllowedValueTypes: TCOCValueTypes read GetAllowedValueTypes write SetAllowedValueTypes;
property Editor: TCompOptsExprEditor read FEditor;
end;
implementation
{$R *.lfm}
{ TCompOptsCondTreeFrame }
procedure TCompOptsCondTreeFrame.COCPopupMenuPopup(Sender: TObject);
begin
COCPopupMenu.Items.Clear;
Editor.FillPopupMenu(COCPopupMenu);
end;
procedure TCompOptsCondTreeFrame.COCTreeViewEdited(Sender: TObject;
Node: TTreeNode; var S: string);
begin
Editor.TreeViewEdited(Sender,Node,S);
end;
procedure TCompOptsCondTreeFrame.COCTreeViewEditing(Sender: TObject;
Node: TTreeNode; var AllowEdit: Boolean);
begin
Editor.TreeViewEditing(Sender,Node,AllowEdit);
end;
procedure TCompOptsCondTreeFrame.SetConditionals(
const AValue: TCompOptConditionals);
begin
Editor.Conditionals:=AValue;
end;
procedure TCompOptsCondTreeFrame.SetAllowedValueTypes(
const AValue: TCOCValueTypes);
begin
Editor.AllowedValueTypes:=AValue;
end;
function TCompOptsCondTreeFrame.GetConditionals: TCompOptConditionals;
begin
Result:=Editor.Conditionals;
end;
function TCompOptsCondTreeFrame.GetAllowedValueTypes: TCOCValueTypes;
begin
Result:=Editor.AllowedValueTypes;
end;
constructor TCompOptsCondTreeFrame.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
FEditor:=TCompOptsExprEditor.Create(Self);
FEditor.TreeView:=COCTreeView;
end;
{ TCompOptsExprEditor }
procedure TCompOptsExprEditor.DeleteMenuItemClick(Sender: TObject);
var
COCNode: TCompOptCondNode;
TVNode: TTreeNode;
begin
if not GetSelectedNode(COCNode,TVNode,false) then exit;
if Conditionals.Root=COCNode then exit;
if MessageDlg('Delete?',
'Delete the node "'+TVNode.Text+'"?',mtConfirmation,[mbYes,mbNo],0)<>mrYes
then
exit;
TVNode.Delete;
COCNode.Free;
ConsistencyCheck;
end;
procedure TCompOptsExprEditor.InsertAboveMenuItemClick(Sender: TObject);
begin
CreateNewNode(naInsert);
end;
procedure TCompOptsExprEditor.InsertBelowMenuItemClick(Sender: TObject);
begin
CreateNewNode(naInsertBehind);
end;
procedure TCompOptsExprEditor.InsertChildMenuItemClick(Sender: TObject);
begin
CreateNewNode(naAddChildFirst);
end;
procedure TCompOptsExprEditor.MoveDownMenuItemClick(Sender: TObject);
// move selected node below sibling
var
COCNode: TCompOptCondNode;
TVNode: TTreeNode;
begin
if not GetSelectedNode(COCNode,TVNode,false) then exit;
if Conditionals.Root=COCNode then exit;
if TVNode.GetNextSibling=nil then exit;
TVNode.MoveTo(TVNode.GetNextSibling,naInsertBehind);
COCNode.Index:=COCNode.Index+1;
ConsistencyCheck;
end;
procedure TCompOptsExprEditor.MoveLvlDownMenuItemClick(Sender: TObject);
// make selected node a child of previous sibling
var
COCNode: TCompOptCondNode;
TVNode: TTreeNode;
Sibling: TCompOptCondNode;
begin
if not GetSelectedNode(COCNode,TVNode,false) then exit;
if Conditionals.Root=COCNode then exit;
if TVNode.GetPrevSibling=nil then exit;
TVNode.MoveTo(TVNode.GetPrevSibling,naAddChild);
Sibling:=COCNode.Parent.Childs[COCNode.Index-1];
COCNode.Move(Sibling,Sibling.Count);
ConsistencyCheck;
end;
procedure TCompOptsExprEditor.MoveLvlUpMenuItemClick(Sender: TObject);
// make selected node a sibling of its parent (below parent)
var
COCNode: TCompOptCondNode;
TVNode: TTreeNode;
begin
if not GetSelectedNode(COCNode,TVNode,false) then exit;
if COCNode.Parent=nil then exit;
if COCNode.Parent.Parent=nil then exit;
TVNode.MoveTo(TVNode.Parent,naInsertBehind);
COCNode.Move(COCNode.Parent.Parent,COCNode.Parent.Index+1);
ConsistencyCheck;
end;
procedure TCompOptsExprEditor.MoveUpMenuItemClick(Sender: TObject);
// move selected node above sibling
var
COCNode: TCompOptCondNode;
TVNode: TTreeNode;
begin
if not GetSelectedNode(COCNode,TVNode,false) then exit;
if Conditionals.Root=COCNode then exit;
if TVNode.GetPrevSibling=nil then exit;
TVNode.MoveTo(TVNode.GetPrevSibling,naInsert);
COCNode.Index:=COCNode.Index-1;
ConsistencyCheck;
end;
procedure TCompOptsExprEditor.PropertiesMenuItemClick(Sender: TObject);
var
COCNode: TCompOptCondNode;
TVNode: TTreeNode;
begin
if not GetSelectedNode(COCNode,TVNode,false) then exit;
EditCompOptCondProperties(COCNode,AllowedValueTypes);
TVNode.Text:=NodeToCaption(COCNode);
TVNode.ImageIndex:=FNodeTypeImageIDs[COCNode.NodeType];
TVNode.SelectedIndex:=TVNode.ImageIndex;
end;
procedure TCompOptsExprEditor.SetAllowedValueTypes(const AValue: TCOCValueTypes
);
var
v: TCOCValueType;
begin
if FAllowedValueTypes=AValue then exit;
FAllowedValueTypes:=AValue;
if not (FDefaultValueType in FAllowedValueTypes) then begin
for v:=Low(TCOCValueTypes) to High(TCOCValueTypes) do begin
if v in FAllowedValueTypes then begin
DefaultValueType:=v;
break;
end;
end;
end;
end;
procedure TCompOptsExprEditor.SetConditionals(const AValue: TCompOptConditionals
);
begin
if FConditionals=AValue then exit;
FConditionals:=AValue;
FillTreeView;
end;
procedure TCompOptsExprEditor.SetRootNode(const AValue: TTreeNode);
begin
if FRootNode=AValue then exit;
if TreeView<>nil then begin
TreeView.BeginUpdate;
ClearTreeView;
end;
FRootNode:=AValue;
if TreeView<>nil then begin
FillTreeView;
TreeView.EndUpdate;
end;
end;
procedure TCompOptsExprEditor.SetTreeView(const AValue: TTreeView);
begin
if FTreeView=AValue then exit;
ClearTreeView;
FTreeView:=AValue;
if (FTreeView<>nil) and (FTreeView.Images=nil) then
FTreeView.Images := IDEImages.Images_24;
FillTreeView;
end;
procedure TCompOptsExprEditor.ClearTreeView;
begin
if TreeView=nil then exit;
TreeView.BeginUpdate;
try
if RootNode<>nil then begin
while RootNode.GetLastChild<>nil do
RootNode.GetLastChild.Delete;
end else begin
TreeView.Items.Clear;
end;
finally
TreeView.EndUpdate;
end;
end;
function TCompOptsExprEditor.NodeToCaption(Node: TCompOptCondNode): string;
begin
case Node.NodeType of
cocntNone: Result:='Comment: '+Node.Value;
cocntIf: Result:='If '+Node.Value;
cocntIfdef: Result:='IfDef '+Node.Value;
cocntIfNdef: Result:='IfNDef '+Node.Value;
cocntElseIf: Result:='ElseIf '+Node.Value;
cocntElse: Result:='Else';
cocntAddValue:
begin
case Node.ValueType of
cocvtNone: Result:='None';
cocvtResult: Result:='Result:=Result+'+Node.Value;
cocvtUnitPath: Result:='Add unit path: '+Node.Value;
cocvtSrcPath: Result:='Add unit source path: '+Node.Value;
cocvtIncludePath: Result:='Add include path: '+Node.Value;
cocvtObjectPath: Result:='Add object path: '+Node.Value;
cocvtLibraryPath: Result:='Add library path: '+Node.Value;
cocvtDebugPath: Result:='Add debug path: '+Node.Value;
cocvtLinkerOptions: Result:='Add linker options: '+Node.Value;
cocvtCustomOptions: Result:='Add custom options: '+Node.Value;
else
Result:='(unknown ValueType)';
end;
end;
cocntSetValue:
begin
case Node.ValueType of
cocvtNone: Result:='None';
cocvtResult: Result:='Result:='+Node.Value;
cocvtUnitPath: Result:='Set unit path: '+Node.Value;
cocvtSrcPath: Result:='Set unit source path: '+Node.Value;
cocvtIncludePath: Result:='Set include path: '+Node.Value;
cocvtObjectPath: Result:='Set object path: '+Node.Value;
cocvtLibraryPath: Result:='Set library path: '+Node.Value;
cocvtDebugPath: Result:='Set debug path: '+Node.Value;
cocvtLinkerOptions: Result:='Set linker options: '+Node.Value;
cocvtCustomOptions: Result:='Set custom options: '+Node.Value;
else
Result:='(unknown ValueType)';
end;
end;
else
Result:='(unknown NodeType)';
end;
Result:=ValidUTF8String(Result);
end;
procedure TCompOptsExprEditor.FillTreeView;
procedure Add(COCNode: TCompOptCondNode; ParentTVNode: TTreeNode);
var
TVNode: TTreeNode;
i: Integer;
begin
if COCNode=nil then exit;
TVNode:=TreeView.Items.AddChildObject(ParentTVNode,NodeToCaption(COCNode),COCNode);
TVNode.ImageIndex:=FNodeTypeImageIDs[COCNode.NodeType];
TVNode.SelectedIndex:=TVNode.ImageIndex;
for i:=0 to COCNode.Count-1 do
Add(COCNode.Childs[i],TVNode);
end;
var
i: Integer;
begin
if TreeView=nil then exit;
TreeView.BeginUpdate;
ClearTreeView;
if (Conditionals<>nil) and (Conditionals.Root<>nil)
and (Conditionals.Root.Count>0) then begin
for i:=0 to Conditionals.Root.Count-1 do
Add(Conditionals.Root.Childs[i],RootNode);
end;
TreeView.EndUpdate;
ConsistencyCheck;
end;
procedure TCompOptsExprEditor.ConsistencyCheck;
procedure CheckChilds(COCNode: TCompOptCondNode; ChildTVNode: TTreeNode); forward;
procedure CheckNode(COCNode: TCompOptCondNode; TVNode: TTreeNode);
begin
if COCNode=nil then
RaiseCatchableException('');
if (TVNode=nil) then
RaiseCatchableException('');
if TVNode.Data=nil then
RaiseCatchableException('');
if COCNode<>TCompOptCondNode(TVNode.Data) then
RaiseCatchableException(TCompOptCondNode(TObject(TVNode.Data)).Value+'<>'+COCNode.Value+' TVNode='+TVNode.Text);
if NodeToCaption(COCNode)<>TVNode.Text then
RaiseCatchableException(NodeToCaption(COCNode)+'<>'+TVNode.Text);
if FNodeTypeImageIDs[COCNode.NodeType]<>TVNode.ImageIndex then
RaiseCatchableException(dbgs(FNodeTypeImageIDs[COCNode.NodeType])+'<>'+dbgs(TVNode.ImageIndex));
if FNodeTypeImageIDs[COCNode.NodeType]<>TVNode.SelectedIndex then
RaiseCatchableException(dbgs(FNodeTypeImageIDs[COCNode.NodeType])+'<>'+dbgs(TVNode.SelectedIndex));
CheckChilds(COCNode,TVNode.GetFirstChild);
end;
procedure CheckChilds(COCNode: TCompOptCondNode; ChildTVNode: TTreeNode);
var
i: Integer;
begin
if COCNode=nil then exit;
for i:=0 to COCNode.Count-1 do begin
CheckNode(COCNode.Childs[i],ChildTVNode);
ChildTVNode:=ChildTVNode.GetNextSibling;
end;
if ChildTVNode<>nil then
RaiseCatchableException('');
end;
var
TVNode: TTreeNode;
begin
if Conditionals=nil then exit;
Conditionals.WriteDebugReport;
if TreeView<>nil then begin
TreeView.WriteDebugReport(' ',true);
if (Conditionals=nil) or (Conditionals.Root=nil)
or (Conditionals.Root.Count=0) then begin
if (RootNode=nil) and (TreeView.Items.Count>0) then
RaiseCatchableException('');
end else begin
if RootNode=nil then
TVNode:=TreeView.Items.GetFirstNode
else
TVNode:=RootNode.GetFirstChild;
CheckChilds(Conditionals.Root,TVNode);
end;
end;
end;
constructor TCompOptsExprEditor.Create(TheOwner: TComponent);
var
nt: TCOCNodeType;
begin
inherited Create(TheOwner);
FAllowedValueTypes:=[low(TCOCValueType)..high(TCOCValueType)];
for nt:=Low(TCOCNodeType) to High(TCOCNodeType) do
FNodeTypeImageIDs[nt]:=-1;
FNodeTypeImageIDs[cocntNone]:=-1;
FNodeTypeImageIDs[cocntIf]:=IDEImages.LoadImage(24,'da_if');
FNodeTypeImageIDs[cocntIfdef]:=IDEImages.LoadImage(24,'da_ifdef');
FNodeTypeImageIDs[cocntIfNdef]:=IDEImages.LoadImage(24,'da_ifndef');
FNodeTypeImageIDs[cocntElseIf]:=IDEImages.LoadImage(24,'da_elseif');
FNodeTypeImageIDs[cocntElse]:=IDEImages.LoadImage(24,'da_else');
FNodeTypeImageIDs[cocntAddValue]:=IDEImages.LoadImage(24,'da_define');
end;
destructor TCompOptsExprEditor.Destroy;
begin
inherited Destroy;
end;
procedure TCompOptsExprEditor.FillPopupMenu(aPopupMenu: TPopupMenu);
function Add(aCaption: string; OnClickEvent: TNotifyEvent): TMenuItem;
begin
Result:=TMenuItem.Create(Self);
Result.Caption:=aCaption;
Result.OnClick:=OnClickEvent;
aPopupMenu.Items.Add(Result);
end;
function AddSeparator: TMenuItem;
begin
if aPopupMenu.Items.Count=0 then exit;
Result:=TMenuItem.Create(Self);
Result.Caption:='-';
aPopupMenu.Items.Add(Result);
end;
var
COCNode: TCompOptCondNode;
TVNode: TTreeNode;
HasSelection: Boolean;
NormalNodeIsSelected: Boolean;
InConditionalNodes: Boolean;
begin
GetSelectedNode(COCNode,TVNode,false);
HasSelection:=COCNode<>nil;
NormalNodeIsSelected:=HasSelection and (COCNode<>Conditionals.Root);
InConditionalNodes:=(RootNode=nil)
or ((TVNode<>nil) and (TVNode.HasAsParent(RootNode)))
or (TVNode=RootNode);
if NormalNodeIsSelected or InConditionalNodes then
AddSeparator;
if NormalNodeIsSelected then
Add('Insert new node above',@InsertAboveMenuItemClick);
if NormalNodeIsSelected then
Add('Insert new node below',@InsertBelowMenuItemClick);
if InConditionalNodes then
Add('Insert new child node',@InsertChildMenuItemClick);
if NormalNodeIsSelected then
Add('Delete node ...',@DeleteMenuItemClick);
if NormalNodeIsSelected then
Add('Properties ...',@PropertiesMenuItemClick);
if NormalNodeIsSelected and (TVNode.GetPrevSibling<>nil) then
Add('Move node one level down',@MoveLvlDownMenuItemClick);
if NormalNodeIsSelected and (COCNode.Parent.Parent<>nil) then
Add('Move node one level up',@MoveLvlUpMenuItemClick);
if NormalNodeIsSelected and (TVNode.GetNextSibling<>nil) then
Add('Move node down',@MoveDownMenuItemClick);
if NormalNodeIsSelected and (TVNode.GetPrevSibling<>nil) then
Add('Move node up',@MoveUpMenuItemClick);
end;
procedure TCompOptsExprEditor.TreeViewEditing(Sender: TObject; Node: TTreeNode;
var AllowEdit: Boolean);
begin
AllowEdit:=false;
end;
procedure TCompOptsExprEditor.TreeViewEdited(Sender: TObject; Node: TTreeNode;
var S: string);
begin
S:=Node.Text;
end;
procedure TCompOptsExprEditor.Setup(NewTreeView: TTreeView;
NewRootNode: TTreeNode; NewConditionals: TCompOptConditionals;
NewAllowedValueTypes: TCOCValueTypes);
begin
TreeView:=nil;
RootNode:=NewRootNode;
Conditionals:=NewConditionals;
AllowedValueTypes:=NewAllowedValueTypes;
// activate
TreeView:=NewTreeView;
end;
function TCompOptsExprEditor.GetSelectedNode(out COCNode: TCompOptCondNode; out
TVNode: TTreeNode; RootAsDefault: boolean): boolean;
begin
COCNode:=nil;
TVNode:=TreeView.Selected;
if (TVNode=nil) then begin
if RootAsDefault then begin
TVNode:=RootNode;
COCNode:=Conditionals.Root;
end;
end else begin
if (RootNode=nil) or TVNode.HasAsParent(RootNode) then
COCNode:=TCompOptCondNode(TVNode.Data)
else if (RootNode=TVNode) then begin
TVNode:=RootNode;
COCNode:=Conditionals.Root;
end;
end;
Result:=COCNode<>nil;
end;
procedure TCompOptsExprEditor.CreateNewNode(AttachMode: TNodeAttachMode);
var
TVNode: TTreeNode;
COCNode: TCompOptCondNode;
s: String;
NewTVNode: TTreeNode;
NewCOCNode: TCompOptCondNode;
begin
if not GetSelectedNode(COCNode,TVNode,true) then exit;
NewCOCNode:=TCompOptCondNode.Create(COCNode.Owner);
NewCOCNode.NodeType:=DefaultNodeType;
NewCOCNode.ValueType:=DefaultValueType;
NewCOCNode.Value:=DefaultValue;
s:=NodeToCaption(NewCOCNode);
NewTVNode:=TreeView.Items.AddObject(TVNode,s,NewCOCNode);
if TVNode<>nil then
NewTVNode.MoveTo(TVNode,AttachMode);
NewTVNode.ImageIndex:=FNodeTypeImageIDs[NewCOCNode.NodeType];
NewTVNode.SelectedIndex:=NewTVNode.ImageIndex;
case AttachMode of
naAdd: NewCOCNode.Move(COCNode.Parent,COCNode.Parent.Count);
naAddFirst: NewCOCNode.Move(COCNode.Parent,0);
naAddChild: NewCOCNode.Move(COCNode,COCNode.Count);
naAddChildFirst: NewCOCNode.Move(COCNode,0);
naInsert: NewCOCNode.Move(COCNode.Parent,COCNode.Index);
naInsertBehind: NewCOCNode.Move(COCNode.Parent,COCNode.Index+1);
end;
if TVNode<>nil then
TVNode.Expanded:=true;
ConsistencyCheck;
end;
end.

View File

@ -1,145 +0,0 @@
object CompOptCondPropsDialog: TCompOptCondPropsDialog
Left = 370
Height = 205
Top = 280
Width = 635
ActiveControl = NodeTypeComboBox
Caption = 'CompOptCondPropsDialog'
ClientHeight = 205
ClientWidth = 635
OnCreate = FormCreate
LCLVersion = '0.9.29'
object ButtonPanel1: TButtonPanel
Left = 6
Height = 34
Top = 165
Width = 623
OKButton.Name = 'OKButton'
OKButton.Caption = '&OK'
HelpButton.Name = 'HelpButton'
HelpButton.Caption = '&Help'
CloseButton.Name = 'CloseButton'
CloseButton.Caption = '&Close'
CloseButton.Enabled = False
CancelButton.Name = 'CancelButton'
CancelButton.Caption = 'Cancel'
TabOrder = 0
ShowButtons = [pbOK, pbCancel, pbHelp]
ShowBevel = False
end
object PropsGroupBox: TGroupBox
Left = 0
Height = 159
Top = 0
Width = 635
Align = alClient
Caption = 'PropsGroupBox'
ClientHeight = 138
ClientWidth = 627
TabOrder = 1
OnResize = PropsGroupBoxResize
object NodeTypeLabel: TLabel
AnchorSideLeft.Control = PropsGroupBox
AnchorSideTop.Control = NodeTypeComboBox
AnchorSideTop.Side = asrCenter
Left = 6
Height = 18
Top = 10
Width = 100
BorderSpacing.Around = 6
Caption = 'NodeTypeLabel'
ParentColor = False
end
object ValueTypeLabel: TLabel
AnchorSideLeft.Control = PropsGroupBox
AnchorSideTop.Control = ValueTypeComboBox
AnchorSideTop.Side = asrCenter
Left = 6
Height = 18
Top = 43
Width = 102
BorderSpacing.Around = 6
Caption = 'ValueTypeLabel'
ParentColor = False
end
object ValueLabel: TLabel
AnchorSideLeft.Control = PropsGroupBox
AnchorSideTop.Control = ValueEdit
AnchorSideTop.Side = asrCenter
Left = 6
Height = 18
Top = 76
Width = 108
BorderSpacing.Around = 6
Caption = 'ValueLabel.........'
ParentColor = False
end
object NodeTypeComboBox: TComboBox
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = PropsGroupBox
AnchorSideRight.Control = PropsGroupBox
AnchorSideRight.Side = asrBottom
Left = 132
Height = 27
Top = 6
Width = 489
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
BorderSpacing.Right = 6
ItemHeight = 0
OnEditingDone = NodeTypeComboBoxEditingDone
TabOrder = 0
Text = 'NodeTypeComboBox'
end
object ValueTypeComboBox: TComboBox
AnchorSideLeft.Control = NodeTypeComboBox
AnchorSideTop.Control = NodeTypeComboBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = PropsGroupBox
AnchorSideRight.Side = asrBottom
Left = 132
Height = 27
Top = 39
Width = 489
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
BorderSpacing.Right = 6
ItemHeight = 0
OnEditingDone = ValueTypeComboBoxEditingDone
TabOrder = 1
Text = 'ValueTypeComboBox'
end
object ValueEdit: TEdit
AnchorSideLeft.Control = NodeTypeComboBox
AnchorSideTop.Control = ValueTypeComboBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ValueButton
Left = 132
Height = 27
Top = 72
Width = 404
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
OnEditingDone = ValueEditEditingDone
TabOrder = 2
Text = 'ValueEdit'
end
object ValueButton: TButton
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ValueEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = PropsGroupBox
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 536
Height = 27
Top = 72
Width = 85
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Right = 6
Caption = '...'
TabOrder = 3
end
end
end

View File

@ -1,286 +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. *
* *
***************************************************************************
Author: Mattias Gaertner
Abstract:
}
unit CompOptCondPropsDlg;
{$mode objfpc}{$H+}
interface
uses
Math, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
ButtonPanel, StdCtrls,
ProjectIntf,
LazarusIDEStrConsts;
type
{ TCompOptCondPropsDialog }
TCompOptCondPropsDialog = class(TForm)
ValueButton: TButton;
ButtonPanel1: TButtonPanel;
NodeTypeComboBox: TComboBox;
ValueTypeComboBox: TComboBox;
ValueEdit: TEdit;
NodeTypeLabel: TLabel;
ValueTypeLabel: TLabel;
ValueLabel: TLabel;
PropsGroupBox: TGroupBox;
procedure ButtonPanel1OkClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure NodeTypeComboBoxEditingDone(Sender: TObject);
procedure PropsGroupBoxResize(Sender: TObject);
procedure ValueEditEditingDone(Sender: TObject);
procedure ValueTypeComboBoxEditingDone(Sender: TObject);
private
FAllowedValueTypes: TCOCValueTypes;
FOriginalNode: TCompOptCondNode;
FNodeType: TCOCNodeType;
FValueType: TCOCValueType;
FValue: string;
function GetNodeType: TCOCNodeType;
function GetValue: string;
function GetValueType: TCOCValueType;
procedure SetAllowedValueTypes(const AValue: TCOCValueTypes);
procedure SetNodeType(const AValue: TCOCNodeType);
procedure SetOriginalNode(const AValue: TCompOptCondNode);
procedure SetValue(const AValue: string);
procedure SetValueType(const AValue: TCOCValueType);
procedure UpdateNodeTypeControls;
procedure UpdateValueControls;
public
property OriginalNode: TCompOptCondNode read FOriginalNode write SetOriginalNode;
property NodeType: TCOCNodeType read GetNodeType write SetNodeType;
property ValueType: TCOCValueType read GetValueType write SetValueType;
property Value: string read GetValue write SetValue;
property AllowedValueTypes: TCOCValueTypes read FAllowedValueTypes write SetAllowedValueTypes;
end;
function EditCompOptCondProperties(Node: TCompOptCondNode;
const AllowedValueTypes: TCOCValueTypes): TModalResult;
implementation
{$R *.lfm}
function EditCompOptCondProperties(Node: TCompOptCondNode;
const AllowedValueTypes: TCOCValueTypes): TModalResult;
var
CompOptCondPropsDialog: TCompOptCondPropsDialog;
begin
CompOptCondPropsDialog:=TCompOptCondPropsDialog.Create(nil);
try
CompOptCondPropsDialog.OriginalNode:=Node;
CompOptCondPropsDialog.AllowedValueTypes:=AllowedValueTypes;
Result:=CompOptCondPropsDialog.ShowModal;
finally
CompOptCondPropsDialog.Free;
end;
end;
{ TCompOptCondPropsDialog }
procedure TCompOptCondPropsDialog.FormCreate(Sender: TObject);
var
nt: TCOCNodeType;
begin
Caption:=lisPropertiesOfConditionalCompilerOption;
PropsGroupBox.Caption:=lisHlpOptsProperties;
NodeTypeLabel.Caption:=lisUIDType;
ValueTypeLabel.Caption:=lisAction;
ValueLabel.Caption:=lisValue;
NodeTypeComboBox.Items.Clear;
for nt:=Low(TCOCNodeType) to High(TCOCNodeType) do
NodeTypeComboBox.Items.Add(COCNodeTypeLocalizedName(nt));
AllowedValueTypes:=[cocvtNone];
ButtonPanel1.OKButton.OnClick:=@ButtonPanel1OkClick;
end;
procedure TCompOptCondPropsDialog.ButtonPanel1OkClick(Sender: TObject);
begin
if FOriginalNode<>nil then begin
FOriginalNode.NodeType:=NodeType;
FOriginalNode.ValueType:=ValueType;
FOriginalNode.Value:=Value;
end;
ModalResult:=mrOk;
end;
procedure TCompOptCondPropsDialog.NodeTypeComboBoxEditingDone(Sender: TObject);
begin
GetNodeType;
UpdateValueControls;
end;
procedure TCompOptCondPropsDialog.PropsGroupBoxResize(Sender: TObject);
begin
NodeTypeComboBox.Left:=6+Max(Max(NodeTypeLabel.Left+NodeTypeLabel.Width,
ValueTypeLabel.Left+ValueTypeLabel.Width),
ValueLabel.Left+ValueLabel.Width);
end;
procedure TCompOptCondPropsDialog.ValueEditEditingDone(Sender: TObject);
begin
GetValue;
UpdateValueControls;
end;
procedure TCompOptCondPropsDialog.ValueTypeComboBoxEditingDone(Sender: TObject);
begin
GetValueType;
UpdateValueControls;
end;
procedure TCompOptCondPropsDialog.SetOriginalNode(const AValue: TCompOptCondNode);
begin
if FOriginalNode=AValue then exit;
FOriginalNode:=AValue;
if FOriginalNode<>nil then begin
FNodeType:=FOriginalNode.NodeType;
FValueType:=FOriginalNode.ValueType;
FValue:=FOriginalNode.Value;
end else begin
FNodeType:=cocntNone;
FValueType:=cocvtNone;
FValue:='';
end;
UpdateNodeTypeControls;
end;
function TCompOptCondPropsDialog.GetNodeType: TCOCNodeType;
var
i: LongInt;
begin
i:=NodeTypeComboBox.Items.IndexOf(NodeTypeComboBox.Text);
if i<0 then
FNodeType:=cocntNone
else
FNodeType:=TCOCNodeType(i);
Result:=FNodeType;
end;
function TCompOptCondPropsDialog.GetValue: string;
begin
FValue:=ValueEdit.Text;
Result:=FValue;
end;
function TCompOptCondPropsDialog.GetValueType: TCOCValueType;
var
i: LongInt;
begin
i:=ValueTypeComboBox.Items.IndexOf(ValueTypeComboBox.Text);
if i<0 then
FValueType:=cocvtNone
else
FValueType:=TCOCValueType(i);
Result:=FValueType;
end;
procedure TCompOptCondPropsDialog.SetAllowedValueTypes(
const AValue: TCOCValueTypes);
var
vt: TCOCValueType;
begin
if FAllowedValueTypes=AValue then exit;
FAllowedValueTypes:=AValue;
ValueTypeComboBox.Items.BeginUpdate;
ValueTypeComboBox.Items.Clear;
for vt:=Low(TCOCValueType) to High(TCOCValueType) do
if vt in AllowedValueTypes then
ValueTypeComboBox.Items.Add(COCValueTypeLocalizedName(vt));
ValueTypeComboBox.Items.EndUpdate;
end;
procedure TCompOptCondPropsDialog.SetNodeType(const AValue: TCOCNodeType);
begin
if FNodeType=AValue then exit;
FNodeType:=AValue;
UpdateNodeTypeControls;
end;
procedure TCompOptCondPropsDialog.UpdateNodeTypeControls;
var
NodeTypeStr: String;
begin
if OriginalNode=nil then begin
NodeTypeLabel.Enabled:=false;
NodeTypeComboBox.Enabled:=false;
ValueTypeLabel.Enabled:=false;
ValueTypeComboBox.Enabled:=false;
ValueLabel.Enabled:=false;
ValueEdit.Enabled:=false;
ValueButton.Enabled:=false;
end else begin
NodeTypeStr:=COCNodeTypeLocalizedName(FNodeType);
NodeTypeLabel.Enabled:=true;
NodeTypeComboBox.ItemIndex:=NodeTypeComboBox.Items.IndexOf(NodeTypeStr);
NodeTypeComboBox.Text:=NodeTypeStr;
UpdateValueControls;
end;
end;
procedure TCompOptCondPropsDialog.UpdateValueControls;
var
s: String;
begin
ValueTypeLabel.Enabled:=FNodeType in [cocntAddValue];
ValueTypeComboBox.Enabled:=ValueTypeLabel.Enabled;
s:=COCValueTypeLocalizedName(fValueType);
ValueTypeComboBox.ItemIndex:=ValueTypeComboBox.Items.IndexOf(s);
ValueTypeComboBox.Text:=s;
ValueLabel.Enabled:=fNodeType in [cocntNone,cocntIf,
cocntIfdef,cocntIfNdef,cocntElseIf,cocntAddValue,cocntSetValue];
ValueEdit.Enabled:=ValueLabel.Enabled;
ValueButton.Enabled:=ValueLabel.Enabled;
case fNodeType of
cocntNone: ValueLabel.Caption:=lisResult;
cocntIf, cocntElseIf: ValueLabel.Caption:=lisExpression;
cocntIfdef, cocntIfNdef: ValueLabel.Caption:=lisCodeToolsDefsVariable;
cocntAddValue: ValueLabel.Caption:=lisAddValue;
cocntSetValue: ValueLabel.Caption:=lisSetValue;
else ValueLabel.Caption:='?';
end;
ValueEdit.Text:=FValue;
PropsGroupBoxResize(nil);
end;
procedure TCompOptCondPropsDialog.SetValue(const AValue: string);
begin
if FValue=AValue then exit;
FValue:=AValue;
ValueEdit.Text:=FValue;
end;
procedure TCompOptCondPropsDialog.SetValueType(const AValue: TCOCValueType);
begin
if FValueType=AValue then exit;
FValueType:=AValue;
UpdateValueControls;
end;
end.

View File

@ -507,6 +507,7 @@ type
procedure SetSrcPath(const AValue: string); override;
procedure SetUnitPaths(const AValue: string); override;
procedure SetUnitOutputDir(const AValue: string); override;
procedure SetConditionals(const AValue: string); override;
procedure UpdateGlobals; virtual;
public
constructor Create(const AOwner: TObject); override;
@ -5506,6 +5507,16 @@ begin
Project.DefineTemplates.OutputDirectoryChanged;
end;
procedure TProjectCompilerOptions.SetConditionals(const AValue: string);
var
NewValue: String;
begin
NewValue:=Trim(AValue);
if Conditionals=NewValue then exit;
InvalidateOptions;
inherited SetConditionals(NewValue);
end;
procedure TProjectCompilerOptions.Assign(Source: TPersistent);
var
ProjCompOptions: TProjectCompilerOptions;

View File

@ -100,63 +100,6 @@ const
);
type
TLazCompOptConditionals = class;
{ TCompOptCondNode
a node in the conditional tree of the compiler options
of a project or package }
TCompOptCondNode = class
private
fChilds: TFPList; // list of TCompOptCondNode
fClearing: boolean;
FNodeType: TCOCNodeType;
FOwner: TLazCompOptConditionals;
FParent: TCompOptCondNode;
FValue: string;
FValueType: TCOCValueType;
function GetChilds(Index: integer): TCompOptCondNode;
function GetCount: integer;
function GetIndex: integer;
procedure SetIndex(const AValue: integer);
procedure SetNodeType(const AValue: TCOCNodeType);
procedure SetValue(const AValue: string);
procedure SetValueType(const AValue: TCOCValueType);
procedure Changed;
public
constructor Create(TheOwner: TLazCompOptConditionals);
destructor Destroy; override;
procedure ClearNodes;
procedure AddLast(Child: TCompOptCondNode);
procedure Insert(Index: integer; Child: TCompOptCondNode);
procedure Move(OldIndex, NewIndex: integer);
procedure Move(NewParent: TCompOptCondNode; NewIndex: integer);
procedure Delete(Index: integer);
procedure Assign(Source: TCompOptCondNode);
public
property NodeType: TCOCNodeType read FNodeType write SetNodeType;
property ValueType: TCOCValueType read FValueType write SetValueType;
property Value: string read FValue write SetValue;
property Owner: TLazCompOptConditionals read FOwner;
property Parent: TCompOptCondNode read FParent;
property Count: integer read GetCount;
property Childs[Index: integer]: TCompOptCondNode read GetChilds; default;
property Index: integer read GetIndex write SetIndex;
end;
{ TLazCompOptConditionals
- conditional compiler options }
TLazCompOptConditionals = class
private
FRoot: TCompOptCondNode;
public
constructor Create;
destructor Destroy; override;
procedure InvalidateValues; virtual; abstract;
procedure Assign(Source: TLazCompOptConditionals); virtual; abstract;
property Root: TCompOptCondNode read FRoot write FRoot;
end;
{ TLazBuildMacro
Every package/project can define build macros. A build macro has a name,
@ -242,7 +185,7 @@ type
fDebugPath: string;
// conditionals / build modes
FConditionals: TLazCompOptConditionals;
FConditionals: string;
fBuildMacros: TLazBuildMacros;
fLCLWidgetType: string;
@ -325,6 +268,7 @@ type
protected
procedure SetBaseDirectory(const AValue: string); virtual; abstract;
procedure SetCompilerPath(const AValue: String); virtual; abstract;
procedure SetConditionals(const AValue: string); virtual; abstract;
procedure SetCustomOptions(const AValue: string); virtual; abstract;
procedure SetIncludePaths(const AValue: String); virtual; abstract;
procedure SetLibraryPaths(const AValue: String); virtual; abstract;
@ -356,7 +300,7 @@ type
property UnitOutputDirectory: string read fUnitOutputDir write SetUnitOutputDir;
// conditional / build modes
property Conditionals: TLazCompOptConditionals read FConditionals;
property Conditionals: string read FConditionals write SetConditionals;
property BuildMacros: TLazBuildMacros read fBuildMacros;
// Beware: eventually LCLWidgetType will be replaced by a more generic solution
property LCLWidgetType: string read fLCLWidgetType write fLCLWidgetType;
@ -1049,152 +993,6 @@ begin
Result:=cetProgram;
end;
{ TCompOptCondNode }
procedure TCompOptCondNode.SetNodeType(const AValue: TCOCNodeType);
begin
if FNodeType=AValue then exit;
FNodeType:=AValue;
Changed;
end;
function TCompOptCondNode.GetChilds(Index: integer): TCompOptCondNode;
begin
Result:=TCompOptCondNode(fChilds[Index]);
end;
function TCompOptCondNode.GetCount: integer;
begin
Result:=fChilds.Count;
end;
function TCompOptCondNode.GetIndex: integer;
begin
if Parent=nil then
Result:=-1
else
Result:=Parent.fChilds.IndexOf(Self);
end;
procedure TCompOptCondNode.SetIndex(const AValue: integer);
var
OldIndex: LongInt;
begin
OldIndex:=GetIndex;
if OldIndex=AValue then exit;
Parent.Move(OldIndex,AValue);
end;
procedure TCompOptCondNode.SetValue(const AValue: string);
begin
if FValue=AValue then exit;
FValue:=AValue;
Changed;
end;
procedure TCompOptCondNode.SetValueType(const AValue: TCOCValueType);
begin
if FValueType=AValue then exit;
FValueType:=AValue;
Changed;
end;
procedure TCompOptCondNode.Changed;
begin
if (FOwner<>nil) and (not fClearing) then FOwner.InvalidateValues;
end;
constructor TCompOptCondNode.Create(TheOwner: TLazCompOptConditionals);
begin
FOwner:=TheOwner;
fChilds:=TFPList.Create;
end;
destructor TCompOptCondNode.Destroy;
begin
fClearing:=true;
ClearNodes;
if FParent<>nil then begin
FParent.fChilds.Remove(Self);
FParent.Changed;
FParent:=nil;
end;
FreeAndNil(fChilds);
inherited Destroy;
end;
procedure TCompOptCondNode.ClearNodes;
var
i: Integer;
OldClearing: Boolean;
begin
if fChilds.Count=0 then exit;
OldClearing:=fClearing;
fClearing:=true;
for i:=fChilds.Count-1 downto 0 do
TObject(fChilds[i]).Free;
fChilds.Clear;
fClearing:=OldClearing;
Changed;
end;
procedure TCompOptCondNode.AddLast(Child: TCompOptCondNode);
begin
Insert(Count,Child);
end;
procedure TCompOptCondNode.Insert(Index: integer; Child: TCompOptCondNode);
begin
fChilds.Insert(Index,Child);
Child.FParent:=Self;
Changed;
end;
procedure TCompOptCondNode.Move(OldIndex, NewIndex: integer);
begin
if OldIndex=NewIndex then exit;
fChilds.Move(OldIndex,NewIndex);
Changed;
end;
procedure TCompOptCondNode.Move(NewParent: TCompOptCondNode; NewIndex: integer
);
begin
if (NewParent=Parent) and (NewIndex=Index) then exit;
if FParent<>nil then begin
FParent.fChilds.Remove(Self);
FParent.Changed;
end;
FParent:=NewParent;
if FParent<>nil then begin
if (NewIndex<0) or (NewIndex>FParent.Count) then
NewIndex:=FParent.Count;
FParent.fChilds.Insert(NewIndex,Self);
FParent.Changed;
end;
end;
procedure TCompOptCondNode.Delete(Index: integer);
begin
Childs[Index].Free;
end;
procedure TCompOptCondNode.Assign(Source: TCompOptCondNode);
var
i: Integer;
Child: TCompOptCondNode;
begin
ClearNodes;
NodeType:=Source.NodeType;
ValueType:=Source.ValueType;
Value:=Source.Value;
for i:=0 to Source.Count-1 do begin
Child:=TCompOptCondNode.Create(Owner);
AddLast(Child);
Child.Assign(Source.Childs[i]);
end;
end;
{ TProjectFileDescriptor }
procedure TProjectFileDescriptor.SetResourceClass(
@ -1690,19 +1488,6 @@ begin
FDescriptor:=TNewItemProject(Source).Descriptor;
end;
{ TLazCompOptConditionals }
constructor TLazCompOptConditionals.Create;
begin
FRoot:=TCompOptCondNode.Create(Self);
end;
destructor TLazCompOptConditionals.Destroy;
begin
FreeAndNil(FRoot);
inherited Destroy;
end;
{ TLazBuildMacros }
constructor TLazBuildMacros.Create(TheOwner: TObject);

View File

@ -372,6 +372,7 @@ type
procedure SetSrcPath(const AValue: string); override;
procedure SetUnitPaths(const AValue: string); override;
procedure SetUnitOutputDir(const AValue: string); override;
procedure SetConditionals(const AValue: string); override;
public
constructor Create(const AOwner: TObject); override;
procedure Clear; override;
@ -3646,6 +3647,16 @@ begin
LazPackage.DefineTemplates.OutputDirectoryChanged;
end;
procedure TPkgCompilerOptions.SetConditionals(const AValue: string);
var
NewValue: String;
begin
NewValue:=Trim(AValue);
if Conditionals=NewValue then exit;
InvalidateOptions;
inherited SetConditionals(NewValue);
end;
constructor TPkgCompilerOptions.Create(const AOwner: TObject);
begin
inherited Create(AOwner);