mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-30 17:50:19 +02:00
IDE: build modes: assign, isequal
git-svn-id: trunk@21572 -
This commit is contained in:
parent
9134c20b4b
commit
2fa1c1b7c6
@ -125,7 +125,7 @@ type
|
|||||||
|
|
||||||
{ TBuildModeFlag }
|
{ TBuildModeFlag }
|
||||||
|
|
||||||
TBuildModeFlag = class
|
TBuildModeFlag = class(TPersistent)
|
||||||
private
|
private
|
||||||
FFlagType: TBuildModeFlagType;
|
FFlagType: TBuildModeFlagType;
|
||||||
FValue: string;
|
FValue: string;
|
||||||
@ -133,6 +133,8 @@ type
|
|||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
procedure Assign(Source: TPersistent); override;
|
||||||
|
function IsEqual(aFlag: TBuildModeFlag): boolean;
|
||||||
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
||||||
DoSwitchPathDelims: boolean);
|
DoSwitchPathDelims: boolean);
|
||||||
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
||||||
@ -149,7 +151,7 @@ type
|
|||||||
- has a list of flags OR a list of modes to activate, but not both
|
- has a list of flags OR a list of modes to activate, but not both
|
||||||
- one mode is selected by the graph, and activates it }
|
- one mode is selected by the graph, and activates it }
|
||||||
|
|
||||||
TBuildMode = class
|
TBuildMode = class(TPersistent)
|
||||||
private
|
private
|
||||||
FActive: boolean;
|
FActive: boolean;
|
||||||
FFlags: TFPList; // lost TBuildModeFlag
|
FFlags: TFPList; // lost TBuildModeFlag
|
||||||
@ -177,6 +179,8 @@ type
|
|||||||
function AddFlag(FlagType: TBuildModeFlagType; Value: string;
|
function AddFlag(FlagType: TBuildModeFlagType; Value: string;
|
||||||
Variable: string = ''): TBuildModeFlag;
|
Variable: string = ''): TBuildModeFlag;
|
||||||
procedure DeleteFlag(Index: integer);
|
procedure DeleteFlag(Index: integer);
|
||||||
|
procedure Assign(Source: TPersistent); override; // copy without Name
|
||||||
|
function IsEqual(aMode: TBuildMode): boolean;
|
||||||
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
||||||
DoSwitchPathDelims: boolean);
|
DoSwitchPathDelims: boolean);
|
||||||
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
||||||
@ -196,7 +200,7 @@ type
|
|||||||
|
|
||||||
{ TBuildModeGraph }
|
{ TBuildModeGraph }
|
||||||
|
|
||||||
TBuildModeGraph = class
|
TBuildModeGraph = class(TPersistent)
|
||||||
private
|
private
|
||||||
FChangeStamp: integer;
|
FChangeStamp: integer;
|
||||||
FEvaluator: TExpressionEvaluator;
|
FEvaluator: TExpressionEvaluator;
|
||||||
@ -214,6 +218,8 @@ type
|
|||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
procedure Assign(Source: TPersistent); override;
|
||||||
|
function IsEqual(Graph: TBuildModeGraph): boolean;
|
||||||
procedure ClearModes;
|
procedure ClearModes;
|
||||||
procedure IncreaseChangeStamp;
|
procedure IncreaseChangeStamp;
|
||||||
property ChangeStamp: integer read FChangeStamp;
|
property ChangeStamp: integer read FChangeStamp;
|
||||||
@ -581,7 +587,7 @@ type
|
|||||||
procedure LoadCompilerOptions(UseExistingFile: Boolean);
|
procedure LoadCompilerOptions(UseExistingFile: Boolean);
|
||||||
procedure SaveCompilerOptions(UseExistingFile: Boolean);
|
procedure SaveCompilerOptions(UseExistingFile: Boolean);
|
||||||
procedure Assign(Source: TPersistent); override;
|
procedure Assign(Source: TPersistent); override;
|
||||||
function IsEqual(CompOpts: TBaseCompilerOptions): boolean;
|
function IsEqual(CompOpts: TBaseCompilerOptions): boolean; virtual;
|
||||||
procedure CreateDiff(CompOpts: TBaseCompilerOptions; Diff: TStrings);
|
procedure CreateDiff(CompOpts: TBaseCompilerOptions; Diff: TStrings);
|
||||||
procedure CreateDiff(CompOpts: TBaseCompilerOptions;
|
procedure CreateDiff(CompOpts: TBaseCompilerOptions;
|
||||||
Tool: TCompilerDiffTool); virtual;
|
Tool: TCompilerDiffTool); virtual;
|
||||||
@ -3661,6 +3667,45 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TBuildModeGraph.Assign(Source: TPersistent);
|
||||||
|
var
|
||||||
|
Src: TBuildModeGraph;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
if Source is TBuildModeGraph then begin
|
||||||
|
Src:=TBuildModeGraph(Source);
|
||||||
|
if IsEqual(Src) then exit;
|
||||||
|
IncreaseChangeStamp;
|
||||||
|
ClearModes;
|
||||||
|
// modes referene each other by name, so first create all modes
|
||||||
|
for i:=0 to Src.ModeCount-1 do
|
||||||
|
AddMode(Src.Modes[i].Name);
|
||||||
|
for i:=0 to ModeCount-1 do
|
||||||
|
Modes[i].Assign(Src.Modes[i]);
|
||||||
|
end else
|
||||||
|
inherited Assign(Source);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TBuildModeGraph.IsEqual(Graph: TBuildModeGraph): boolean;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
if (ModeCount<>Graph.ModeCount) then exit;
|
||||||
|
|
||||||
|
// check SelectedMode
|
||||||
|
if (SelectedMode=nil)<>(Graph.SelectedMode=nil) then exit;
|
||||||
|
if (SelectedMode<>nil)
|
||||||
|
and (SysUtils.CompareText(SelectedMode.Name,Graph.SelectedMode.Name)<>0) then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
// check modes
|
||||||
|
for i:=0 to ModeCount-1 do
|
||||||
|
if not Modes[i].IsEqual(Graph.Modes[i]) then exit;
|
||||||
|
|
||||||
|
Result:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TBuildModeGraph.ClearModes;
|
procedure TBuildModeGraph.ClearModes;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
@ -4858,6 +4903,50 @@ begin
|
|||||||
FFlags.Delete(Index);
|
FFlags.Delete(Index);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TBuildMode.Assign(Source: TPersistent);
|
||||||
|
var
|
||||||
|
Src: TBuildMode;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
if Source is TBuildMode then begin
|
||||||
|
Src:=TBuildMode(Source);
|
||||||
|
// name is not copied
|
||||||
|
FStoredInSession:=Src.FStoredInSession;
|
||||||
|
// copy includes
|
||||||
|
FIncludes.Clear;
|
||||||
|
for i:=0 to Src.IncludeCount-1 do
|
||||||
|
Include(Graph.FindModeWithName(Src.Includes[i].Name));
|
||||||
|
// copy flags
|
||||||
|
ClearFlags;
|
||||||
|
for i:=0 to Src.FlagCount-1 do begin
|
||||||
|
FFlags.Add(TBuildModeFlag.Create);
|
||||||
|
Flags[i].Assign(Src.Flags[i]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
end else
|
||||||
|
inherited Assign(Source);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TBuildMode.IsEqual(aMode: TBuildMode): boolean;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
if StoredInSession<>aMode.StoredInSession then exit;
|
||||||
|
if Name<>aMode.Name then exit;
|
||||||
|
if IncludeCount<>aMode.IncludeCount then exit;
|
||||||
|
for i:=0 to IncludeCount-1 do
|
||||||
|
if SysUtils.CompareText(Includes[i].Name,aMode.Includes[i].Name)<>0 then
|
||||||
|
exit;
|
||||||
|
// Note: do not compare includedby
|
||||||
|
if FlagCount<>aMode.FlagCount then exit;
|
||||||
|
for i:=0 to FlagCount-1 do
|
||||||
|
if not Flags[i].IsEqual(aMode.Flags[i]) then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
Result:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TBuildMode.LoadFromXMLConfig(XMLConfig: TXMLConfig;
|
procedure TBuildMode.LoadFromXMLConfig(XMLConfig: TXMLConfig;
|
||||||
const Path: string; DoSwitchPathDelims: boolean);
|
const Path: string; DoSwitchPathDelims: boolean);
|
||||||
var
|
var
|
||||||
@ -4914,6 +5003,28 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TBuildModeFlag.Assign(Source: TPersistent);
|
||||||
|
var
|
||||||
|
Src: TBuildModeFlag;
|
||||||
|
begin
|
||||||
|
if Source is TBuildModeFlag then begin
|
||||||
|
Src:=TBuildModeFlag(Source);
|
||||||
|
FFlagType:=Src.FFlagType;
|
||||||
|
FValue:=Src.FValue;
|
||||||
|
FVariable:=Src.FVariable;
|
||||||
|
end else
|
||||||
|
inherited Assign(Source);
|
||||||
|
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;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TBuildModeFlag.LoadFromXMLConfig(XMLConfig: TXMLConfig;
|
procedure TBuildModeFlag.LoadFromXMLConfig(XMLConfig: TXMLConfig;
|
||||||
const Path: string; DoSwitchPathDelims: boolean);
|
const Path: string; DoSwitchPathDelims: boolean);
|
||||||
begin
|
begin
|
||||||
|
@ -368,6 +368,7 @@ type
|
|||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
{ TProjectCompilationToolOptions }
|
{ TProjectCompilationToolOptions }
|
||||||
|
|
||||||
TProjectCompilationToolOptions = class(TCompilationToolOptions)
|
TProjectCompilationToolOptions = class(TCompilationToolOptions)
|
||||||
public
|
public
|
||||||
CompileReasons: TCompileReasons;
|
CompileReasons: TCompileReasons;
|
||||||
@ -413,6 +414,7 @@ type
|
|||||||
function GetDefaultMainSourceFileName: string; override;
|
function GetDefaultMainSourceFileName: string; override;
|
||||||
procedure GetInheritedCompilerOptions(var OptionsList: TFPList); override;
|
procedure GetInheritedCompilerOptions(var OptionsList: TFPList); override;
|
||||||
procedure Assign(Source: TPersistent); override;
|
procedure Assign(Source: TPersistent); override;
|
||||||
|
function IsEqual(CompOpts: TBaseCompilerOptions): boolean; override;
|
||||||
procedure CreateDiff(CompOpts: TBaseCompilerOptions;
|
procedure CreateDiff(CompOpts: TBaseCompilerOptions;
|
||||||
Tool: TCompilerDiffTool); override;
|
Tool: TCompilerDiffTool); override;
|
||||||
procedure InvalidateOptions;
|
procedure InvalidateOptions;
|
||||||
@ -4843,15 +4845,33 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TProjectCompilerOptions.Assign(Source: TPersistent);
|
procedure TProjectCompilerOptions.Assign(Source: TPersistent);
|
||||||
|
var
|
||||||
|
ProjCompOptions: TProjectCompilerOptions;
|
||||||
begin
|
begin
|
||||||
inherited Assign(Source);
|
inherited Assign(Source);
|
||||||
if Source is TProjectCompilerOptions
|
if Source is TProjectCompilerOptions then begin
|
||||||
then FCompileReasons := TProjectCompilerOptions(Source).FCompileReasons
|
ProjCompOptions:=TProjectCompilerOptions(Source);
|
||||||
else FCompileReasons := [crCompile, crBuild, crRun];
|
FCompileReasons := ProjCompOptions.FCompileReasons;
|
||||||
|
FBuildModes.Assign(ProjCompOptions.BuildModes);
|
||||||
|
end else begin
|
||||||
|
FCompileReasons := [crCompile, crBuild, crRun];
|
||||||
|
// keep BuildModes
|
||||||
|
end;
|
||||||
UpdateGlobals;
|
UpdateGlobals;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TProjectCompilerOptions.IsEqual(CompOpts: TBaseCompilerOptions
|
||||||
|
): boolean;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
if not inherited IsEqual(CompOpts) then exit;
|
||||||
|
if CompOpts is TProjectCompilerOptions then begin
|
||||||
|
if not TProjectCompilerOptions(CompOpts).BuildModes.IsEqual(BuildModes) then
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
Result:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TProjectCompilerOptions.CreateDiff(CompOpts: TBaseCompilerOptions;
|
procedure TProjectCompilerOptions.CreateDiff(CompOpts: TBaseCompilerOptions;
|
||||||
Tool: TCompilerDiffTool);
|
Tool: TCompilerDiffTool);
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user