Commit 5df4b7fc authored by Juha Manninen's avatar Juha Manninen
Browse files

IdeIntf: A new interface class TLazCompilationToolOptions with a Command and...

IdeIntf: A new interface class TLazCompilationToolOptions with a Command and CompileReasons. Issue #34283.

git-svn-id: trunk@59043 -
parent 7a46670f
......@@ -18,7 +18,7 @@ interface
uses
Classes, SysUtils,
// LazUtils
LazMethodList,
LazMethodList, LazFileCache,
// IdeIntf
IDEOptionsIntf;
......@@ -116,6 +116,27 @@ const
crAll = [crCompile, crBuild, crRun];
type
{ TLazCompilationToolOptions }
TLazCompilationToolOptions = class
private
procedure SetCommand(AValue: string);
protected
FChangeStamp: int64;
FCommand: string;
FCompileReasons: TCompileReasons;
FOnChanged: TNotifyEvent;
procedure SetCompileReasons(const {%H-}AValue: TCompileReasons); virtual;
public
procedure Clear; virtual;
procedure IncreaseChangeStamp;
public
property ChangeStamp: int64 read FChangeStamp;
property Command: string read FCommand write SetCommand;
property CompileReasons: TCompileReasons read FCompileReasons write SetCompileReasons;
property OnChanged: TNotifyEvent read FOnChanged write FOnChanged;
end;
{ TLazCompilerOptions }
TLazCompilerOptions = class(TAbstractIDEOptions)
......@@ -271,6 +292,10 @@ type
// Turn specific types of compiler messages on or off
fMessageFlags: TAbstractCompilerMsgIDFlags;
// Other tools:
fExecuteBefore: TLazCompilationToolOptions;
fExecuteAfter: TLazCompilationToolOptions;
// Other:
fDontUseConfigFile: Boolean;
fCustomConfigFile: Boolean;
......@@ -440,7 +465,9 @@ type
property WriteFPCLogo: Boolean read fWriteFPCLogo write SetWriteFPCLogo;
property StopAfterErrCount: integer read fStopAfterErrCount write SetStopAfterErrCount;
property MessageFlags: TAbstractCompilerMsgIDFlags read fMessageFlags;
// other tools
property ExecuteBefore: TLazCompilationToolOptions read fExecuteBefore;
property ExecuteAfter: TLazCompilationToolOptions read fExecuteAfter;
// other
property DontUseConfigFile: Boolean read fDontUseConfigFile write SetDontUseConfigFile;
property CustomConfigFile: Boolean read fCustomConfigFile write SetCustomConfigFile;
......@@ -448,7 +475,6 @@ type
property CustomOptions: string read GetCustomOptions write SetCustomOptions;
property UseCommentsInCustomOptions: Boolean read fUseCommentsInCustomOptions
write SetUseCommentsInCustomOptions;
// execute
property CompilerPath: String read GetCompilerPath write SetCompilerPath;
procedure SetAlternativeCompile(const Command: string; ScanFPCMsgs: boolean); virtual; abstract; // disable normal compile and call this instead
......@@ -456,6 +482,33 @@ type
implementation
{ TLazCompilationToolOptions }
procedure TLazCompilationToolOptions.Clear;
begin
Command:='';
end;
procedure TLazCompilationToolOptions.IncreaseChangeStamp;
begin
LUIncreaseChangeStamp64(FChangeStamp);
if Assigned(OnChanged) then
OnChanged(Self);
end;
procedure TLazCompilationToolOptions.SetCommand(AValue: string);
begin
if FCommand=AValue then exit;
FCommand:=AValue;
IncreaseChangeStamp;
end;
procedure TLazCompilationToolOptions.SetCompileReasons(const AValue: TCompileReasons);
begin
raise Exception.Create('TLazCompilationToolOptions does not support CompileReasons.'
+' Use an inherited class instead.');
end;
{ TLazBuildMacros }
constructor TLazBuildMacros.Create(TheOwner: TObject);
......
......@@ -333,17 +333,13 @@ type
{ TCompilationToolOptions }
TCompilationToolOptions = class
TCompilationToolOptions = class(TLazCompilationToolOptions)
private
FChangeStamp: int64;
FCommand: string;
FOnChanged: TNotifyEvent;
FOwner: TObject;
FParsers: TStrings;
FParsedCommandStamp: integer;
FParsedCommand: string;
function GetHasParser(aParserName: string): boolean;
procedure SetCommand(const AValue: string);
procedure SetHasParser(aParserName: string; const AValue: boolean);
procedure SetParsers(const AValue: TStrings);
protected
......@@ -351,7 +347,7 @@ type
public
constructor Create(TheOwner: TObject); virtual;
destructor Destroy; override;
procedure Clear; virtual;
procedure Clear; override;
function CreateDiff(CompOpts: TCompilationToolOptions;
Tool: TCompilerDiffTool = nil): boolean; virtual;
procedure Assign(Src: TCompilationToolOptions); virtual;
......@@ -361,14 +357,10 @@ type
UsePathDelim: TPathDelimSwitch); virtual;
function Execute(const WorkingDir, ToolTitle, CompileHint: string): TModalResult;
function CreateExtTool(const WorkingDir, ToolTitle, CompileHint: string): TAbstractExternalTool;
property ChangeStamp: int64 read FChangeStamp;
procedure IncreaseChangeStamp;
property OnChanged: TNotifyEvent read FOnChanged write FOnChanged;
function GetParsedCommand: string; // resolved macros
function HasCommands: boolean; // true if there is something to execute
public
property Owner: TObject read FOwner;
property Command: string read FCommand write SetCommand;
property Parsers: TStrings read FParsers write SetParsers;
property HasParser[aParserName: string]: boolean read GetHasParser write SetHasParser;
end;
......@@ -433,12 +425,9 @@ type
FStorePathDelim: TPathDelimSwitch;
FOtherDefines: TStrings; // list of user selectable defines for custom options
FFPCMsgFile: TFPCMsgFilePoolItem;
// other tools
fExecuteBefore: TCompilationToolOptions;
fExecuteAfter: TCompilationToolOptions;
FCreateMakefileOnBuild: boolean;
function GetExecuteAfter: TCompilationToolOptions;
function GetExecuteBefore: TCompilationToolOptions;
procedure OnItemChanged(Sender: TObject);
procedure SetCreateMakefileOnBuild(AValue: boolean);
protected
......@@ -580,14 +569,12 @@ type
property BaseDirectory: string read GetBaseDirectory write SetBaseDirectory;
property DefaultMakeOptionsFlags: TCompilerCmdLineOptions
read FDefaultMakeOptionsFlags write SetDefaultMakeOptionsFlags;
// stored properties
property StorePathDelim: TPathDelimSwitch read FStorePathDelim write FStorePathDelim;
property OtherDefines: TStrings read FOtherDefines;
// compilation
property ExecuteBefore: TCompilationToolOptions read fExecuteBefore;
property ExecuteAfter: TCompilationToolOptions read fExecuteAfter;
property ExecuteBefore: TCompilationToolOptions read GetExecuteBefore;
property ExecuteAfter: TCompilationToolOptions read GetExecuteAfter;
property CreateMakefileOnBuild: boolean read FCreateMakefileOnBuild
write SetCreateMakefileOnBuild;
end;
......@@ -1393,6 +1380,16 @@ begin
Result:=ParsedOpts.Values[pcosUnitPath].UnparsedValue;
end;
function TBaseCompilerOptions.GetExecuteAfter: TCompilationToolOptions;
begin
Result:=TCompilationToolOptions(fExecuteAfter);
end;
function TBaseCompilerOptions.GetExecuteBefore: TCompilationToolOptions;
begin
Result:=TCompilationToolOptions(fExecuteBefore);
end;
procedure TBaseCompilerOptions.SetBaseDirectory(AValue: string);
begin
if BaseDirectory=AValue then exit;
......@@ -4237,16 +4234,6 @@ end;
{ TCompilationToolOptions }
procedure TCompilationToolOptions.SetCommand(const AValue: string);
begin
if FCommand=AValue then exit;
FCommand:=AValue;
{$IFDEF VerboseIDEModified}
debugln(['TCompilationToolOptions.SetCommand ',AValue]);
{$ENDIF}
IncreaseChangeStamp;
end;
function TCompilationToolOptions.GetHasParser(aParserName: string): boolean;
begin
Result:=FParsers.IndexOf(aParserName)>=0;
......@@ -4285,6 +4272,7 @@ end;
constructor TCompilationToolOptions.Create(TheOwner: TObject);
begin
inherited Create;
FOwner:=TheOwner;
FParsers:=TStringList.Create;
end;
......@@ -4297,7 +4285,7 @@ end;
procedure TCompilationToolOptions.Clear;
begin
Command:='';
inherited Clear;
Parsers.Clear;
end;
......@@ -4436,12 +4424,6 @@ begin
end;
end;
procedure TCompilationToolOptions.IncreaseChangeStamp;
begin
CTIncreaseChangeStamp64(FChangeStamp);
if assigned(OnChanged) then OnChanged(Self);
end;
function TCompilationToolOptions.GetParsedCommand: string;
begin
if FParsedCommandStamp<>CompilerParseStamp then begin
......
......@@ -485,11 +485,10 @@ type
TProjectCompilationToolOptions = class(TCompilationToolOptions)
private
FCompileReasons: TCompileReasons;
FDefaultCompileReasons: TCompileReasons;
procedure SetCompileReasons(const AValue: TCompileReasons);
procedure SetDefaultCompileReasons(const AValue: TCompileReasons);
protected
procedure SetCompileReasons(const AValue: TCompileReasons); override;
procedure SubstituteMacros(var s: string); override;
public
procedure Clear; override;
......@@ -502,7 +501,6 @@ type
UsePathDelim: TPathDelimSwitch); override;
function GetProject: TProject;
public
property CompileReasons: TCompileReasons read FCompileReasons write SetCompileReasons;
property DefaultCompileReasons: TCompileReasons read FDefaultCompileReasons write SetDefaultCompileReasons;
end;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment