mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-02 06:23:35 +01:00
IDE: mode matrix: do not store session info in project and ide
git-svn-id: trunk@41390 -
This commit is contained in:
parent
ecd140c985
commit
d97e869846
@ -137,11 +137,12 @@ type
|
||||
end;
|
||||
|
||||
// assign
|
||||
function IsEqual(Options: TBuildMatrixOptions; StorageGroup: TGroupedMatrixGroup): boolean;
|
||||
function IsEqual(Options: TBuildMatrixOptions; StorageGroup: TGroupedMatrixGroup;
|
||||
NotStoredModes: TStrings): boolean;
|
||||
procedure AssignBuildMatrixOptionsToGroup(Options: TBuildMatrixOptions;
|
||||
Matrix: TGroupedMatrix; StorageGroup: TGroupedMatrixGroup);
|
||||
Matrix: TGroupedMatrix; StorageGroup: TGroupedMatrixGroup; NotStoredModes: TStrings);
|
||||
procedure AssignBuildMatrixGroupToOptions(StorageGroup: TGroupedMatrixGroup;
|
||||
Options: TBuildMatrixOptions; InvalidateBuildMacros: boolean);
|
||||
Options: TBuildMatrixOptions; InvalidateBuildMacros: boolean; NotStoredModes: TStrings);
|
||||
|
||||
// targets, see BuildMatrixTargetFits
|
||||
function TargetsPrefix: string;
|
||||
@ -195,8 +196,8 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function IsEqual(Options: TBuildMatrixOptions; StorageGroup: TGroupedMatrixGroup
|
||||
): boolean;
|
||||
function IsEqual(Options: TBuildMatrixOptions; StorageGroup: TGroupedMatrixGroup;
|
||||
NotStoredModes: TStrings): boolean;
|
||||
// ignore empty targets
|
||||
var
|
||||
OptIndex: Integer;
|
||||
@ -226,7 +227,8 @@ begin
|
||||
// compare option
|
||||
Option:=Options[OptIndex];
|
||||
if Option.Targets<>Target.Value then exit;
|
||||
if Option.Modes<>ValueRow.GetNormalizedModes then exit;
|
||||
if Option.Modes[bmmtActive]<>ValueRow.GetNormalizedModes(nil) then exit;
|
||||
if Option.Modes[bmmtStored]<>ValueRow.GetNormalizedModes(NotStoredModes) then exit;
|
||||
if Option.Typ<>CaptionToBuildMatrixOptionType(ValueRow.Typ) then exit;
|
||||
if Option.Typ=bmotIDEMacro then begin
|
||||
SplitMatrixMacro(ValueRow.Value,MacroName,MacroValue,false);
|
||||
@ -242,14 +244,15 @@ begin
|
||||
end;
|
||||
|
||||
procedure AssignBuildMatrixOptionsToGroup(Options: TBuildMatrixOptions;
|
||||
Matrix: TGroupedMatrix; StorageGroup: TGroupedMatrixGroup);
|
||||
Matrix: TGroupedMatrix; StorageGroup: TGroupedMatrixGroup;
|
||||
NotStoredModes: TStrings);
|
||||
var
|
||||
OptIndex: Integer;
|
||||
Option: TBuildMatrixOption;
|
||||
TargetGrp: TGroupedMatrixGroup;
|
||||
Value: String;
|
||||
begin
|
||||
if IsEqual(Options,StorageGroup) then exit;
|
||||
if IsEqual(Options,StorageGroup,NotStoredModes) then exit;
|
||||
StorageGroup.Clear;
|
||||
TargetGrp:=nil;
|
||||
for OptIndex:=0 to Options.Count-1 do begin
|
||||
@ -259,13 +262,14 @@ begin
|
||||
Value:=Option.Value;
|
||||
if Option.Typ=bmotIDEMacro then
|
||||
Value:=Option.MacroName+':='+Value;
|
||||
Matrix.AddValue(TargetGrp,Option.Modes,
|
||||
Matrix.AddValue(TargetGrp,Option.Modes[bmmtActive],
|
||||
BuildMatrixOptionTypeCaption(Option.Typ),Value,Option.ID);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure AssignBuildMatrixGroupToOptions(StorageGroup: TGroupedMatrixGroup;
|
||||
Options: TBuildMatrixOptions; InvalidateBuildMacros: boolean);
|
||||
Options: TBuildMatrixOptions; InvalidateBuildMacros: boolean;
|
||||
NotStoredModes: TStrings);
|
||||
var
|
||||
GrpIndex: Integer;
|
||||
Target: TGroupedMatrixGroup;
|
||||
@ -275,7 +279,7 @@ var
|
||||
MacroName: string;
|
||||
MacroValue: string;
|
||||
begin
|
||||
if IsEqual(Options,StorageGroup) then exit;
|
||||
if IsEqual(Options,StorageGroup,NotStoredModes) then exit;
|
||||
Options.Clear;
|
||||
for GrpIndex:=0 to StorageGroup.Count-1 do begin
|
||||
Target:=TGroupedMatrixGroup(StorageGroup[GrpIndex]);
|
||||
@ -291,7 +295,8 @@ begin
|
||||
end;
|
||||
Option:=Options.Add(CaptionToBuildMatrixOptionType(ValueRow.Typ),
|
||||
Target.Value);
|
||||
Option.Modes:=ValueRow.GetNormalizedModes;
|
||||
Option.Modes[bmmtActive]:=ValueRow.GetNormalizedModes(nil);
|
||||
Option.Modes[bmmtStored]:=ValueRow.GetNormalizedModes(NotStoredModes);
|
||||
Option.ID:=ValueRow.ID;
|
||||
if Option.Typ=bmotIDEMacro then begin
|
||||
SplitMatrixMacro(ValueRow.Value,MacroName,MacroValue,false);
|
||||
@ -905,16 +910,23 @@ begin
|
||||
end;
|
||||
|
||||
procedure TCompOptModeMatrix.DoWriteSettings;
|
||||
var
|
||||
SessionModes: TStringList;
|
||||
begin
|
||||
// write IDE options
|
||||
AssignBuildMatrixGroupToOptions(GroupIDE,
|
||||
EnvironmentOptions.BuildMatrixOptions, true);
|
||||
// write Project options
|
||||
AssignBuildMatrixGroupToOptions(GroupProject,
|
||||
LazProject.BuildModes.SharedMatrixOptions, true);
|
||||
// write Session options
|
||||
AssignBuildMatrixGroupToOptions(GroupSession,
|
||||
LazProject.BuildModes.SessionMatrixOptions, true);
|
||||
SessionModes:=LazProject.BuildModes.GetSessionModes;
|
||||
try
|
||||
// write IDE options
|
||||
AssignBuildMatrixGroupToOptions(GroupIDE,
|
||||
EnvironmentOptions.BuildMatrixOptions,true,SessionModes);
|
||||
// write Project options
|
||||
AssignBuildMatrixGroupToOptions(GroupProject,
|
||||
LazProject.BuildModes.SharedMatrixOptions,true,SessionModes);
|
||||
// write Session options
|
||||
AssignBuildMatrixGroupToOptions(GroupSession,
|
||||
LazProject.BuildModes.SessionMatrixOptions,true,nil);
|
||||
finally
|
||||
SessionModes.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TCompOptModeMatrix.Create(TheOwner: TComponent);
|
||||
@ -1019,6 +1031,7 @@ end;
|
||||
procedure TCompOptModeMatrix.ReadSettings(AOptions: TAbstractIDEOptions);
|
||||
var
|
||||
CompOptions: TProjectCompilerOptions;
|
||||
SessionModes: TStringList;
|
||||
begin
|
||||
//debugln(['TCompOptModeMatrix.ReadSettings ',DbgSName(AOptions)]);
|
||||
if not (AOptions is TProjectCompilerOptions) then exit;
|
||||
@ -1033,18 +1046,23 @@ begin
|
||||
|
||||
UpdateModes(false);
|
||||
|
||||
// read IDE options
|
||||
AssignBuildMatrixOptionsToGroup(EnvironmentOptions.BuildMatrixOptions,
|
||||
Grid.Matrix,GroupIDE);
|
||||
fOldIDEOptions.Assign(EnvironmentOptions.BuildMatrixOptions);
|
||||
// read Project options
|
||||
AssignBuildMatrixOptionsToGroup(LazProject.BuildModes.SharedMatrixOptions,
|
||||
Grid.Matrix,GroupProject);
|
||||
fOldSharedOptions.Assign(LazProject.BuildModes.SharedMatrixOptions);
|
||||
// read Session options
|
||||
AssignBuildMatrixOptionsToGroup(LazProject.BuildModes.SessionMatrixOptions,
|
||||
Grid.Matrix,GroupSession);
|
||||
fOldSessionOptions.Assign(LazProject.BuildModes.SessionMatrixOptions);
|
||||
SessionModes:=LazProject.BuildModes.GetSessionModes;
|
||||
try
|
||||
// read IDE options
|
||||
AssignBuildMatrixOptionsToGroup(EnvironmentOptions.BuildMatrixOptions,
|
||||
Grid.Matrix,GroupIDE,SessionModes);
|
||||
fOldIDEOptions.Assign(EnvironmentOptions.BuildMatrixOptions);
|
||||
// read Project options
|
||||
AssignBuildMatrixOptionsToGroup(LazProject.BuildModes.SharedMatrixOptions,
|
||||
Grid.Matrix,GroupProject,SessionModes);
|
||||
fOldSharedOptions.Assign(LazProject.BuildModes.SharedMatrixOptions);
|
||||
// read Session options
|
||||
AssignBuildMatrixOptionsToGroup(LazProject.BuildModes.SessionMatrixOptions,
|
||||
Grid.Matrix,GroupSession,nil);
|
||||
fOldSessionOptions.Assign(LazProject.BuildModes.SessionMatrixOptions);
|
||||
finally
|
||||
SessionModes.Free;
|
||||
end;
|
||||
|
||||
// update Grid
|
||||
Grid.MatrixChanged;
|
||||
|
||||
@ -122,7 +122,7 @@ type
|
||||
property Value: string read FValue write SetValue;
|
||||
property Typ: string read FTyp write SetTyp;
|
||||
property Modes: TStrings read FModes write SetModes;
|
||||
function GetNormalizedModes: string;
|
||||
function GetNormalizedModes(IgnoreModes: TStrings = nil): string;
|
||||
function AsString: string; override;
|
||||
end;
|
||||
|
||||
@ -673,7 +673,7 @@ begin
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
function TGroupedMatrixValue.GetNormalizedModes: string;
|
||||
function TGroupedMatrixValue.GetNormalizedModes(IgnoreModes: TStrings): string;
|
||||
var
|
||||
i: Integer;
|
||||
m: String;
|
||||
@ -682,6 +682,9 @@ begin
|
||||
for i:=0 to Modes.Count-1 do begin
|
||||
m:=Modes[i];
|
||||
if m='' then continue;
|
||||
if (IgnoreModes<>nil)
|
||||
and (IndexInStringList(IgnoreModes,cstCaseInsensitive,m)>=0) then
|
||||
continue;
|
||||
if Result<>'' then Result+=#10;
|
||||
Result+=m;
|
||||
end;
|
||||
|
||||
@ -59,6 +59,12 @@ const
|
||||
type
|
||||
TBuildMatrixOptions = class;
|
||||
|
||||
TBMModesType = (
|
||||
bmmtStored,
|
||||
bmmtActive
|
||||
);
|
||||
TBMModesTypes = set of TBMModesType;
|
||||
|
||||
{ TBuildMatrixOption }
|
||||
|
||||
TBuildMatrixOption = class(TPersistent)
|
||||
@ -66,12 +72,13 @@ type
|
||||
FID: string;
|
||||
FList: TBuildMatrixOptions;
|
||||
FMacroName: string;
|
||||
FModes: string;
|
||||
FModes: array[TBMModesType] of string;
|
||||
FTargets: string;
|
||||
FTyp: TBuildMatrixOptionType;
|
||||
FValue: string;
|
||||
function GetModes(Typ: TBMModesType): string;
|
||||
procedure SetMacroName(AValue: string);
|
||||
procedure SetModes(AValue: string);
|
||||
procedure SetModes(Typ: TBMModesType; AValue: string);
|
||||
procedure SetTargets(AValue: string);
|
||||
procedure SetTyp(AValue: TBuildMatrixOptionType);
|
||||
procedure SetValue(AValue: string);
|
||||
@ -80,17 +87,17 @@ type
|
||||
constructor Create(aList: TBuildMatrixOptions);
|
||||
destructor Destroy; override;
|
||||
function FitsTarget(const Target: string): boolean;
|
||||
function FitsMode(const Mode: string): boolean;
|
||||
function FitsMode(const Mode: string; aTyp: TBMModesType): boolean;
|
||||
property List: TBuildMatrixOptions read FList;
|
||||
property ID: string read FID write FID;
|
||||
property Targets: string read FTargets write SetTargets;
|
||||
property Modes: string read FModes write SetModes; // modes separated by line breaks, case insensitive
|
||||
property Modes[Typ: TBMModesType]: string read GetModes write SetModes; // modes separated by line breaks, case insensitive
|
||||
property Typ: TBuildMatrixOptionType read FTyp write SetTyp;
|
||||
property MacroName: string read FMacroName write SetMacroName;
|
||||
property Value: string read FValue write SetValue;
|
||||
function Equals(Obj: TObject): boolean; override;
|
||||
function GetModesSeparatedByComma: string;
|
||||
procedure SetModesFromCommaSeparatedList(aList: string);
|
||||
function GetModesSeparatedByComma(aTyp: TBMModesType): string;
|
||||
procedure SetModesFromCommaSeparatedList(aList: string; aTyp: TBMModesType);
|
||||
procedure LoadFromConfig(Cfg: TConfigStorage);
|
||||
procedure SaveToConfig(Cfg: TConfigStorage);
|
||||
procedure LoadFromXMLConfig(Cfg: TXMLConfig; const aPath: string);
|
||||
@ -562,7 +569,7 @@ begin
|
||||
Value:=Trim(Option.Value);
|
||||
if Value='' then continue;
|
||||
if not Option.FitsTarget(Target) then continue;
|
||||
if not Option.FitsMode(ActiveMode) then continue;
|
||||
if not Option.FitsMode(ActiveMode,bmmtActive) then continue;
|
||||
if Options<>'' then Options+=' ';
|
||||
Options+=Value;
|
||||
end;
|
||||
@ -578,7 +585,7 @@ begin
|
||||
Option:=Items[i];
|
||||
if Option.Typ<>bmotOutDir then continue;
|
||||
if not Option.FitsTarget(Target) then continue;
|
||||
if not Option.FitsMode(ActiveMode) then continue;
|
||||
if not Option.FitsMode(ActiveMode,bmmtActive) then continue;
|
||||
OutDir:=Option.Value;
|
||||
end;
|
||||
end;
|
||||
@ -592,11 +599,17 @@ begin
|
||||
List.IncreaseChangeStep;
|
||||
end;
|
||||
|
||||
procedure TBuildMatrixOption.SetModes(AValue: string);
|
||||
function TBuildMatrixOption.GetModes(Typ: TBMModesType): string;
|
||||
begin
|
||||
if FModes=AValue then Exit;
|
||||
FModes:=AValue;
|
||||
List.IncreaseChangeStep;
|
||||
Result:=FModes[Typ];
|
||||
end;
|
||||
|
||||
procedure TBuildMatrixOption.SetModes(Typ: TBMModesType; AValue: string);
|
||||
begin
|
||||
if FModes[Typ]=AValue then exit;
|
||||
FModes[Typ]:=AValue;
|
||||
if Typ=bmmtStored then
|
||||
List.IncreaseChangeStep;
|
||||
end;
|
||||
|
||||
procedure TBuildMatrixOption.SetTargets(AValue: string);
|
||||
@ -623,12 +636,14 @@ end;
|
||||
procedure TBuildMatrixOption.Assign(Source: TPersistent);
|
||||
var
|
||||
aSource: TBuildMatrixOption;
|
||||
mt: TBMModesType;
|
||||
begin
|
||||
if Source is TBuildMatrixOption then
|
||||
begin
|
||||
aSource:=TBuildMatrixOption(Source);
|
||||
Targets:=aSource.Targets;
|
||||
Modes:=aSource.Modes;
|
||||
for mt:=Low(TBMModesType) to high(TBMModesType) do
|
||||
Modes[mt]:=aSource.Modes[mt];
|
||||
Typ:=aSource.Typ;
|
||||
MacroName:=aSource.MacroName;
|
||||
Value:=aSource.Value;
|
||||
@ -655,32 +670,35 @@ begin
|
||||
Result:=BuildMatrixTargetFits(Target,Targets);
|
||||
end;
|
||||
|
||||
function TBuildMatrixOption.FitsMode(const Mode: string): boolean;
|
||||
function TBuildMatrixOption.FitsMode(const Mode: string; aTyp: TBMModesType
|
||||
): boolean;
|
||||
begin
|
||||
Result:=BuildMatrixModeFits(Mode,Modes);
|
||||
Result:=BuildMatrixModeFits(Mode,Modes[aTyp]);
|
||||
end;
|
||||
|
||||
function TBuildMatrixOption.Equals(Obj: TObject): boolean;
|
||||
var
|
||||
Src: TBuildMatrixOption;
|
||||
mt: TBMModesType;
|
||||
begin
|
||||
Result:=false;
|
||||
if Obj=Self then exit;
|
||||
if not (Obj is TBuildMatrixOption) then exit;
|
||||
Src:=TBuildMatrixOption(Obj);
|
||||
if Src.Targets<>Targets then exit;
|
||||
if Src.Modes<>Modes then exit;
|
||||
for mt:=Low(TBMModesType) to high(TBMModesType) do
|
||||
if Src.Modes[mt]<>Modes[mt] then exit;
|
||||
if Src.Typ<>Typ then exit;
|
||||
if Src.MacroName<>MacroName then exit;
|
||||
if Src.Value<>Value then exit;
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
function TBuildMatrixOption.GetModesSeparatedByComma: string;
|
||||
function TBuildMatrixOption.GetModesSeparatedByComma(aTyp: TBMModesType): string;
|
||||
var
|
||||
p: Integer;
|
||||
begin
|
||||
Result:=Modes;
|
||||
Result:=Modes[aTyp];
|
||||
p:=1;
|
||||
while p<=length(Result) do begin
|
||||
case Result[p] of
|
||||
@ -700,7 +718,8 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TBuildMatrixOption.SetModesFromCommaSeparatedList(aList: string);
|
||||
procedure TBuildMatrixOption.SetModesFromCommaSeparatedList(aList: string;
|
||||
aTyp: TBMModesType);
|
||||
var
|
||||
p: Integer;
|
||||
begin
|
||||
@ -718,14 +737,14 @@ begin
|
||||
inc(p);
|
||||
end;
|
||||
end;
|
||||
Modes:=aList;
|
||||
Modes[aTyp]:=aList;
|
||||
end;
|
||||
|
||||
procedure TBuildMatrixOption.LoadFromConfig(Cfg: TConfigStorage);
|
||||
begin
|
||||
ID:=Cfg.GetValue('ID','');
|
||||
Targets:=Cfg.GetValue('Targets','*');
|
||||
SetModesFromCommaSeparatedList(Cfg.GetValue('Modes','*'));
|
||||
SetModesFromCommaSeparatedList(Cfg.GetValue('Modes','*'),bmmtStored);
|
||||
Typ:=Str2BuildMatrixOptionType(Cfg.GetValue('Type',''));
|
||||
MacroName:=Cfg.GetValue('MacroName','');
|
||||
Value:=Cfg.GetValue('Value','');
|
||||
@ -735,7 +754,7 @@ procedure TBuildMatrixOption.SaveToConfig(Cfg: TConfigStorage);
|
||||
begin
|
||||
Cfg.SetDeleteValue('ID',ID,'');
|
||||
Cfg.SetDeleteValue('Targets',Targets,'*');
|
||||
Cfg.SetDeleteValue('Modes',GetModesSeparatedByComma,'*');
|
||||
Cfg.SetDeleteValue('Modes',GetModesSeparatedByComma(bmmtStored),'*');
|
||||
Cfg.SetDeleteValue('Type',BuildMatrixOptionTypeNames[Typ],BuildMatrixOptionTypeNames[bmotCustom]);
|
||||
Cfg.SetDeleteValue('MacroName',MacroName,'');
|
||||
Cfg.SetDeleteValue('Value',Value,'');
|
||||
@ -746,7 +765,7 @@ procedure TBuildMatrixOption.LoadFromXMLConfig(Cfg: TXMLConfig;
|
||||
begin
|
||||
ID:=Cfg.GetValue(aPath+'ID','');
|
||||
Targets:=Cfg.GetValue(aPath+'Targets','*');
|
||||
SetModesFromCommaSeparatedList(Cfg.GetValue(aPath+'Modes','*'));
|
||||
SetModesFromCommaSeparatedList(Cfg.GetValue(aPath+'Modes','*'),bmmtStored);
|
||||
Typ:=Str2BuildMatrixOptionType(Cfg.GetValue(aPath+'Type',''));
|
||||
MacroName:=Cfg.GetValue(aPath+'MacroName','');
|
||||
Value:=Cfg.GetValue(aPath+'Value','');
|
||||
@ -757,7 +776,7 @@ procedure TBuildMatrixOption.SaveToXMLConfig(Cfg: TXMLConfig;
|
||||
begin
|
||||
Cfg.SetDeleteValue(aPath+'ID',ID,'');
|
||||
Cfg.SetDeleteValue(aPath+'Targets',Targets,'*');
|
||||
Cfg.SetDeleteValue(aPath+'Modes',GetModesSeparatedByComma,'*');
|
||||
Cfg.SetDeleteValue(aPath+'Modes',GetModesSeparatedByComma(bmmtStored),'*');
|
||||
Cfg.SetDeleteValue(aPath+'Type',BuildMatrixOptionTypeNames[Typ],BuildMatrixOptionTypeNames[bmotCustom]);
|
||||
Cfg.SetDeleteValue(aPath+'MacroName',MacroName,'');
|
||||
Cfg.SetDeleteValue(aPath+'Value',Value,'');
|
||||
|
||||
@ -734,6 +734,7 @@ type
|
||||
procedure AddOnChangedHandler(const Handler: TNotifyEvent);
|
||||
procedure RemoveOnChangedHandler(const Handler: TNotifyEvent);
|
||||
function IsModified(InSession: boolean): boolean;
|
||||
function GetSessionModes: TStringList;
|
||||
public
|
||||
property Items[Index: integer]: TProjectBuildMode read GetItems; default;
|
||||
property ChangeStamp: integer read FChangeStamp;
|
||||
@ -7260,6 +7261,19 @@ begin
|
||||
Result:=false;
|
||||
end;
|
||||
|
||||
function TProjectBuildModes.GetSessionModes: TStringList;
|
||||
var
|
||||
i: Integer;
|
||||
BuildMode: TProjectBuildMode;
|
||||
begin
|
||||
Result:=TStringList.Create;
|
||||
for i:=0 to Count-1 do begin
|
||||
BuildMode:=Items[i];
|
||||
if BuildMode.InSession then
|
||||
Result.Add(BuildMode.Identifier);
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterIDEOptionsGroup(GroupProject, TProject);
|
||||
RegisterIDEOptionsGroup(GroupCompiler, TProjectCompilerOptions);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user