mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 03:40:31 +02:00
IDE: removed buildmodeflagtype
git-svn-id: trunk@25563 -
This commit is contained in:
parent
db7ac79d9e
commit
f3e19f4829
@ -78,21 +78,6 @@ type
|
||||
procedure SetDefaultValue(const AValue: string); override;
|
||||
end;
|
||||
|
||||
type
|
||||
TBuildModeFlagType = (
|
||||
bmftNone,
|
||||
bmftAddUnitPath,
|
||||
bmftAddIncludePath,
|
||||
bmftAddLinkerPath,
|
||||
bmftAddObjectPath,
|
||||
bmftAddLinkerOption,
|
||||
bmftAddCustomOption,
|
||||
bmftSetVariable
|
||||
);
|
||||
TBuildModeFlagTypes = set of TBuildModeFlagType;
|
||||
const
|
||||
BuildModeFlagPaths = [bmftAddUnitPath,bmftAddIncludePath,bmftAddLinkerPath,bmftAddObjectPath];
|
||||
|
||||
type
|
||||
TBuildModeGraph = class;
|
||||
|
||||
@ -138,7 +123,6 @@ type
|
||||
|
||||
TBuildModeFlag = class(TPersistent)
|
||||
private
|
||||
FFlagType: TBuildModeFlagType;
|
||||
FValue: string;
|
||||
FVariable: string;
|
||||
public
|
||||
@ -151,7 +135,6 @@ type
|
||||
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
||||
UsePathDelim: TPathDelimSwitch);
|
||||
public
|
||||
property FlagType: TBuildModeFlagType read FFlagType write FFlagType;
|
||||
property Value: string read FValue write FValue;
|
||||
property Variable: string read FVariable write FVariable;
|
||||
end;
|
||||
@ -188,10 +171,9 @@ type
|
||||
procedure Include(aMode: TBuildMode);
|
||||
procedure Exclude(aMode: TBuildMode);
|
||||
function IsIncludedBy(aMode: TBuildMode): boolean;
|
||||
function AddFlag(FlagType: TBuildModeFlagType; Value: string;
|
||||
Variable: string = ''): TBuildModeFlag;
|
||||
function InsertFlag(InsertPos: integer; FlagType: TBuildModeFlagType;
|
||||
Value: string; Variable: string = ''): TBuildModeFlag;
|
||||
function AddFlag(Value: string; Variable: string = ''): TBuildModeFlag;
|
||||
function InsertFlag(InsertPos: integer;
|
||||
Value: string; Variable: string = ''): TBuildModeFlag;
|
||||
procedure DeleteFlag(Index: integer);
|
||||
procedure Assign(Source: TPersistent); override; // copy without Name
|
||||
function IsEqual(aMode: TBuildMode): boolean;
|
||||
@ -834,18 +816,6 @@ const
|
||||
symItem = '$Item';
|
||||
symLineNo = '$LineNum';
|
||||
|
||||
const
|
||||
BuildModeFlagTypeNames: array[TBuildModeFlagType] of string = (
|
||||
'None',
|
||||
'AddUnitPath',
|
||||
'AddIncludePath',
|
||||
'AddLinkerPath',
|
||||
'AddObjectPath',
|
||||
'AddLinkerOption',
|
||||
'AddCustomOption',
|
||||
'SetVariable'
|
||||
);
|
||||
function StrToBuildModeFlagType(const s: string): TBuildModeFlagType;
|
||||
var
|
||||
TestCompilerOptions: TNotifyEvent = nil;
|
||||
|
||||
@ -1110,13 +1080,6 @@ begin
|
||||
AConfig.SetDeleteValue(APath+'Run', crRun in AFlags, crRun in DefaultFlags);
|
||||
end;
|
||||
|
||||
function StrToBuildModeFlagType(const s: string): TBuildModeFlagType;
|
||||
begin
|
||||
for Result:=Low(TBuildModeFlagType) to high(TBuildModeFlagType) do
|
||||
if SysUtils.CompareText(s,BuildModeFlagTypeNames[Result])=0 then exit;
|
||||
Result:=bmftNone;
|
||||
end;
|
||||
|
||||
|
||||
{ TBaseCompilerOptions }
|
||||
|
||||
@ -5080,20 +5043,17 @@ begin
|
||||
Result:=false;
|
||||
end;
|
||||
|
||||
function TBuildMode.AddFlag(FlagType: TBuildModeFlagType; Value: string;
|
||||
Variable: string): TBuildModeFlag;
|
||||
function TBuildMode.AddFlag(Value: string; Variable: string): TBuildModeFlag;
|
||||
begin
|
||||
Result:=InsertFlag(FlagCount,FlagType,Value,Variable);
|
||||
Result:=InsertFlag(FlagCount,Value,Variable);
|
||||
end;
|
||||
|
||||
function TBuildMode.InsertFlag(InsertPos: integer;
|
||||
FlagType: TBuildModeFlagType; Value: string; Variable: string
|
||||
): TBuildModeFlag;
|
||||
function TBuildMode.InsertFlag(InsertPos: integer; Value: string;
|
||||
Variable: string): TBuildModeFlag;
|
||||
begin
|
||||
if (InsertPos<0) or (InsertPos>FlagCount) then
|
||||
RaiseGDBException('');
|
||||
Result:=TBuildModeFlag.Create;
|
||||
Result.FlagType:=FlagType;
|
||||
Result.Value:=Value;
|
||||
Result.Variable:=Variable;
|
||||
FFlags.Insert(InsertPos,Result);
|
||||
@ -5213,7 +5173,6 @@ var
|
||||
begin
|
||||
if Source is TBuildModeFlag then begin
|
||||
Src:=TBuildModeFlag(Source);
|
||||
FFlagType:=Src.FFlagType;
|
||||
FValue:=Src.FValue;
|
||||
FVariable:=Src.FVariable;
|
||||
end else
|
||||
@ -5223,7 +5182,6 @@ end;
|
||||
function TBuildModeFlag.IsEqual(aFlag: TBuildModeFlag): boolean;
|
||||
begin
|
||||
Result:=false;
|
||||
if FFlagType<>aFlag.FFlagType then exit;
|
||||
if FValue<>aFlag.FValue then exit;
|
||||
if FVariable<>aFlag.FVariable then exit;
|
||||
Result:=true;
|
||||
@ -5232,25 +5190,14 @@ end;
|
||||
procedure TBuildModeFlag.LoadFromXMLConfig(XMLConfig: TXMLConfig;
|
||||
const Path: string; DoSwitchPathDelims: boolean);
|
||||
begin
|
||||
FFlagType:=StrToBuildModeFlagType(XMLConfig.GetValue(Path+'Type',
|
||||
BuildModeFlagTypeNames[bmftAddCustomOption]));
|
||||
FValue:=XMLConfig.GetValue(Path+'Value','');
|
||||
if FFlagType in BuildModeFlagPaths then
|
||||
FValue:=SwitchPathDelims(FValue,DoSwitchPathDelims);
|
||||
FVariable:=XMLConfig.GetValue(Path+'Variable','');
|
||||
end;
|
||||
|
||||
procedure TBuildModeFlag.SaveToXMLConfig(XMLConfig: TXMLConfig;
|
||||
const Path: string; UsePathDelim: TPathDelimSwitch);
|
||||
var
|
||||
s: String;
|
||||
begin
|
||||
XMLConfig.SetDeleteValue(Path+'Type',BuildModeFlagTypeNames[FFlagType],
|
||||
BuildModeFlagTypeNames[bmftAddCustomOption]);
|
||||
s:=FValue;
|
||||
if FFlagType in BuildModeFlagPaths then
|
||||
SwitchPathDelims(FValue,UsePathDelim);
|
||||
XMLConfig.SetDeleteValue(Path+'Value',s,'');
|
||||
XMLConfig.SetDeleteValue(Path+'Value',FValue,'');
|
||||
XMLConfig.SetDeleteValue(Path+'Variable',FVariable,'');
|
||||
end;
|
||||
|
||||
|
@ -27,7 +27,8 @@
|
||||
Author: Mattias Gaertner
|
||||
|
||||
Abstract:
|
||||
- compiler options depending on build modes and environment
|
||||
This unit contains the implementation of the conditional compiler options
|
||||
that depend on build variables/modes and environment.
|
||||
}
|
||||
unit CompOptsModes;
|
||||
|
||||
|
@ -131,37 +131,10 @@ type
|
||||
property Grid: TBuildModesGrid read FGrid;
|
||||
end;
|
||||
|
||||
function BuildModeFlagTypeCaptions(f: TBuildModeFlagType): string;
|
||||
function CaptionToBuildModeFlagType(s: string): TBuildModeFlagType;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
function BuildModeFlagTypeCaptions(f: TBuildModeFlagType): string;
|
||||
begin
|
||||
case f of
|
||||
bmftAddUnitPath: Result:='+UnitPath';
|
||||
bmftAddIncludePath: Result:='+IncludePath';
|
||||
bmftAddLinkerPath: Result:='+LinkerPath';
|
||||
bmftAddObjectPath: Result:='+ObjectPath';
|
||||
bmftAddLinkerOption: Result:='+LinkerOptions';
|
||||
bmftAddCustomOption: Result:='+CustomOptions';
|
||||
else Result:='';
|
||||
end;
|
||||
end;
|
||||
|
||||
function CaptionToBuildModeFlagType(s: string): TBuildModeFlagType;
|
||||
begin
|
||||
if s='' then exit(bmftNone);
|
||||
for Result:=low(Result) to high(Result) do
|
||||
if SysUtils.CompareText(s,BuildModeFlagTypeCaptions(Result))=0 then exit;
|
||||
if IsValidIdent(s) then
|
||||
Result:=bmftSetVariable
|
||||
else
|
||||
Result:=bmftNone;
|
||||
end;
|
||||
|
||||
{ TBuildModesGrid }
|
||||
|
||||
function TBuildModesGrid.GetModeRows(Index: integer): TBuildModeGridRow;
|
||||
@ -223,12 +196,8 @@ begin
|
||||
TypeStr:='';
|
||||
ValueStr:='';
|
||||
if CurFlag<>nil then begin
|
||||
if CurFlag.FlagType=bmftSetVariable then
|
||||
begin
|
||||
TypeStr:=CurFlag.Variable;
|
||||
ValueStr:=CurFlag.Value;
|
||||
end else
|
||||
TypeStr:=BuildModeFlagTypeCaptions(CurFlag.FlagType);
|
||||
TypeStr:=CurFlag.Variable;
|
||||
ValueStr:=CurFlag.Value;
|
||||
end;
|
||||
Cells[TypeCol,i]:=TypeStr;
|
||||
Cells[ValueCol,i]:=ValueStr;
|
||||
@ -257,7 +226,6 @@ var
|
||||
CurModeRow: TBuildModeGridRow;
|
||||
TypeCol: Integer;
|
||||
ValueCol: Integer;
|
||||
FlagType: TBuildModeFlagType;
|
||||
begin
|
||||
Result:=true;
|
||||
if (aRow>=1) and (aRow<=ModeRowCount) then begin
|
||||
@ -285,19 +253,12 @@ begin
|
||||
NewValue:='';
|
||||
end else begin
|
||||
NewValue:=SpecialCharsToSpaces(NewValue,true);
|
||||
FlagType:=CaptionToBuildModeFlagType(NewValue);
|
||||
if (CurModeRow.Flag=nil) and (FlagType<>bmftNone) then begin
|
||||
if (CurModeRow.Flag=nil) then begin
|
||||
// create flag
|
||||
CurModeRow.FFlag:=CurModeRow.Mode.AddFlag(FlagType,'','');
|
||||
end else if CurModeRow.Flag<>nil then
|
||||
// set new FlagType
|
||||
CurModeRow.Flag.FlagType:=FlagType;
|
||||
if FlagType=bmftSetVariable then
|
||||
// set variable name
|
||||
CurModeRow.Flag.Variable:=NewValue
|
||||
else
|
||||
// clean up variable name
|
||||
CurModeRow.Flag.Variable:='';
|
||||
CurModeRow.FFlag:=CurModeRow.Mode.AddFlag('','');
|
||||
end;
|
||||
// set variable name
|
||||
CurModeRow.Flag.Variable:=NewValue;
|
||||
UpdateValuePickList;
|
||||
end;
|
||||
end else if ACol=ValueCol then begin
|
||||
@ -306,7 +267,7 @@ begin
|
||||
NewValue:='';
|
||||
end else begin
|
||||
NewValue:=SpecialCharsToSpaces(NewValue,true);
|
||||
if (CurModeRow.Flag=nil) or (CurModeRow.Flag.FlagType=bmftNone) then
|
||||
if (CurModeRow.Flag=nil) then
|
||||
// no flag => no value
|
||||
NewValue:=''
|
||||
else
|
||||
@ -359,8 +320,6 @@ var
|
||||
TypeCol: Integer;
|
||||
i: Integer;
|
||||
Node: TAvgLvlTreeNode;
|
||||
t: TBuildModeFlagType;
|
||||
s: String;
|
||||
sl: TStringList;
|
||||
begin
|
||||
//DebugLn(['TBuildModesGrid.UpdateTypePickList ']);
|
||||
@ -369,14 +328,6 @@ begin
|
||||
Identifiers:=TStringToStringTree.Create(false);
|
||||
sl:=nil;
|
||||
try
|
||||
// add types
|
||||
for t:=low(TBuildModeFlagType) to high(TBuildModeFlagType) do
|
||||
begin
|
||||
s:=BuildModeFlagTypeCaptions(t);
|
||||
if s<>'' then
|
||||
Identifiers[s]:='';
|
||||
end;
|
||||
|
||||
// add standard variable names
|
||||
Identifiers['TargetOS']:='';
|
||||
Identifiers['TargetCPU']:='';
|
||||
@ -417,26 +368,23 @@ begin
|
||||
sl:=TStringList.Create;
|
||||
try
|
||||
if (CurModeRow<>nil) and (CurModeRow.Flag<>nil) then begin
|
||||
if CurModeRow.Flag.FlagType=bmftSetVariable then begin
|
||||
Identifier:=CurModeRow.Flag.Variable;
|
||||
// check standard variables
|
||||
if SysUtils.CompareText(Identifier,'TargetOS')=0 then begin
|
||||
for i:=low(FPCOperatingSystemNames) to high(FPCOperatingSystemNames) do
|
||||
sl.Add(FPCOperatingSystemNames[i]);
|
||||
end
|
||||
else if SysUtils.CompareText(Identifier,'TargetCPU')=0 then begin
|
||||
for i:=low(FPCProcessorNames) to high(FPCProcessorNames) do
|
||||
sl.Add(FPCProcessorNames[i]);
|
||||
end
|
||||
else begin
|
||||
// search build variable
|
||||
FindBuildVariable(Identifier,Vars,aVariable);
|
||||
if aVariable<>nil then
|
||||
sl.Assign(aVariable.Values);
|
||||
end;
|
||||
Columns[ValueCol].ButtonStyle:=cbsPickList;
|
||||
end else if CurModeRow.Flag.FlagType in BuildModeFlagPaths then
|
||||
Columns[ValueCol].ButtonStyle:=cbsEllipsis;
|
||||
Identifier:=CurModeRow.Flag.Variable;
|
||||
// check standard variables
|
||||
if SysUtils.CompareText(Identifier,'TargetOS')=0 then begin
|
||||
for i:=low(FPCOperatingSystemNames) to high(FPCOperatingSystemNames) do
|
||||
sl.Add(FPCOperatingSystemNames[i]);
|
||||
end
|
||||
else if SysUtils.CompareText(Identifier,'TargetCPU')=0 then begin
|
||||
for i:=low(FPCProcessorNames) to high(FPCProcessorNames) do
|
||||
sl.Add(FPCProcessorNames[i]);
|
||||
end
|
||||
else begin
|
||||
// search build variable
|
||||
FindBuildVariable(Identifier,Vars,aVariable);
|
||||
if aVariable<>nil then
|
||||
sl.Assign(aVariable.Values);
|
||||
end;
|
||||
Columns[ValueCol].ButtonStyle:=cbsPickList;
|
||||
end;
|
||||
sl.Sort;
|
||||
Columns[ValueCol].PickList:=sl;
|
||||
@ -499,27 +447,10 @@ end;
|
||||
procedure TBuildModesGrid.BuildModesGridEditButtonClick(Sender: TObject);
|
||||
var
|
||||
CurModeRow: TBuildModeGridRow;
|
||||
CurPathEditor: TPathEditorDialog;
|
||||
ValueCol: Integer;
|
||||
begin
|
||||
CurModeRow:=SelectedModeRow;
|
||||
if CurModeRow=nil then exit;
|
||||
if CurModeRow.Flag=nil then exit;
|
||||
ValueCol:=GetTypeCol+1;
|
||||
if CurModeRow.Flag.FlagType in BuildModeFlagPaths then begin
|
||||
CurPathEditor:=TPathEditorDialog.Create(nil);
|
||||
try
|
||||
CurPathEditor.BaseDirectory:=Project1.ProjectDirectory;
|
||||
CurPathEditor.Path:=CurModeRow.Flag.Value;
|
||||
CurPathEditor.Templates:='';
|
||||
if CurPathEditor.ShowModal=mrOk then begin
|
||||
CurModeRow.Flag.Value:=CurPathEditor.Path;
|
||||
Cells[ValueCol,Row]:=CurModeRow.Flag.Value;
|
||||
end;
|
||||
finally
|
||||
CurPathEditor.Free;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TBuildModesGrid.GetCheckBoxState(const aCol, aRow: Integer;
|
||||
@ -775,7 +706,7 @@ begin
|
||||
Columns[InsertCol].ButtonStyle:=cbsCheckboxColumn;
|
||||
inc(FGroupModeCount);
|
||||
end else begin
|
||||
CurFlag:=Result.AddFlag(bmftNone,'');
|
||||
CurFlag:=Result.AddFlag('');
|
||||
InsertPos:=ModeRowCount;
|
||||
end;
|
||||
InsertRow:=InsertPos+1;
|
||||
@ -810,7 +741,7 @@ begin
|
||||
mtError, [mbCancel], 0);
|
||||
exit;
|
||||
end;
|
||||
Result:=CurModeRow.Mode.InsertFlag(CurModeRow.IndexInGroup+1,bmftNone,'','');
|
||||
Result:=CurModeRow.Mode.InsertFlag(CurModeRow.IndexInGroup+1,'','');
|
||||
InsertPos:=Row+1;
|
||||
GridRow:=TBuildModeGridRow.Create(CurModeRow.Mode,Result);
|
||||
FModeRows.Insert(InsertPos-1,GridRow);
|
||||
@ -838,8 +769,7 @@ begin
|
||||
if (CurModeRow.Flag.Value<>'') or (CurModeRow.Flag.Variable<>'') then
|
||||
begin
|
||||
if MessageDlg(lisDeleteSetting2,
|
||||
Format(lisDeleteSetting3, ['"', BuildModeFlagTypeCaptions(
|
||||
CurModeRow.Flag.FlagType), '"']),
|
||||
'Delete '+CurModeRow.Flag.Variable+'='+CurModeRow.Flag.Value,
|
||||
mtConfirmation,[mbYes,mbNo],0)<>mrYes
|
||||
then
|
||||
exit;
|
||||
|
@ -145,8 +145,7 @@ type
|
||||
end;
|
||||
|
||||
{ TLazCompOptConditionals
|
||||
- conditional compiler options
|
||||
- additions dependending }
|
||||
- conditional compiler options }
|
||||
|
||||
TLazCompOptConditionals = class
|
||||
private
|
||||
@ -159,7 +158,13 @@ type
|
||||
property Root: TCompOptCondNode read FRoot write FRoot;
|
||||
end;
|
||||
|
||||
{ TLazBuildVariable }
|
||||
{ TLazBuildVariable
|
||||
Build variables are like macros. Every package/project can define build
|
||||
variables. A variable has a name, a description, a list of possible values
|
||||
and a default value. The default value can be an expression using other
|
||||
build variables.
|
||||
The IDE defines various variables like TargetOS and TargetCPU.
|
||||
The LCL package defines the variable LCLWidgetType. }
|
||||
|
||||
TLazBuildVariable = class
|
||||
protected
|
||||
@ -182,7 +187,9 @@ type
|
||||
property DefaultValue: TLazCompOptConditionals read FDefaultValue;
|
||||
end;
|
||||
|
||||
{ TLazBuildVariables }
|
||||
{ TLazBuildVariables
|
||||
The list of build variables of a package/project.
|
||||
They are stored in the compiler options. }
|
||||
|
||||
TLazBuildVariables = class
|
||||
private
|
||||
|
Loading…
Reference in New Issue
Block a user