mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-20 11:59:08 +02:00
IDE: compiler options: execute before/after: using project macros
git-svn-id: trunk@33421 -
This commit is contained in:
parent
78e66fbc68
commit
a54976dae0
@ -312,14 +312,20 @@ type
|
||||
FChangeStamp: int64;
|
||||
FCommand: string;
|
||||
FOnChanged: TNotifyEvent;
|
||||
FOwner: TObject;
|
||||
FScanForFPCMessages: boolean;
|
||||
FScanForMakeMessages: boolean;
|
||||
FShowAllMessages: boolean;
|
||||
FParsedCommandStamp: integer;
|
||||
FParsedCommand: string;
|
||||
procedure SetCommand(const AValue: string);
|
||||
procedure SetScanForFPCMessages(const AValue: boolean);
|
||||
procedure SetScanForMakeMessages(const AValue: boolean);
|
||||
procedure SetShowAllMessages(const AValue: boolean);
|
||||
protected
|
||||
procedure SubstituteMacros(var s: string); virtual;
|
||||
public
|
||||
constructor Create(TheOwner: TObject); virtual;
|
||||
procedure Clear; virtual;
|
||||
function CreateDiff(CompOpts: TCompilationToolOptions;
|
||||
Tool: TCompilerDiffTool = nil): boolean; virtual;
|
||||
@ -332,7 +338,9 @@ type
|
||||
property ChangeStamp: int64 read FChangeStamp;
|
||||
procedure IncreaseChangeStamp;
|
||||
property OnChanged: TNotifyEvent read FOnChanged write FOnChanged;
|
||||
function GetParsedCommand: string; // resolved macros
|
||||
public
|
||||
property Owner: TObject read FOwner;
|
||||
property Command: string read FCommand write SetCommand;
|
||||
property ScanForFPCMessages: boolean read FScanForFPCMessages write SetScanForFPCMessages;
|
||||
property ScanForMakeMessages: boolean read FScanForMakeMessages write SetScanForMakeMessages;
|
||||
@ -1000,9 +1008,9 @@ constructor TBaseCompilerOptions.Create(const AOwner: TObject;
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
FParsedOpts := TParsedCompilerOptions.Create(Self);
|
||||
FExecuteBefore := AToolClass.Create;
|
||||
FExecuteBefore := AToolClass.Create(Self);
|
||||
FExecuteBefore.OnChanged:=@OnItemChanged;
|
||||
FExecuteAfter := AToolClass.Create;
|
||||
FExecuteAfter := AToolClass.Create(Self);
|
||||
fExecuteAfter.OnChanged:=@OnItemChanged;
|
||||
fBuildMacros := TIDEBuildMacros.Create(Self);
|
||||
FCompilerMessages:=TCompilerMessagesList.Create;
|
||||
@ -3875,6 +3883,16 @@ begin
|
||||
IncreaseChangeStamp;
|
||||
end;
|
||||
|
||||
procedure TCompilationToolOptions.SubstituteMacros(var s: string);
|
||||
begin
|
||||
IDEMacros.SubstituteMacros(s);
|
||||
end;
|
||||
|
||||
constructor TCompilationToolOptions.Create(TheOwner: TObject);
|
||||
begin
|
||||
FOwner:=TheOwner;
|
||||
end;
|
||||
|
||||
procedure TCompilationToolOptions.Clear;
|
||||
begin
|
||||
Command:='';
|
||||
@ -3939,8 +3957,10 @@ var
|
||||
ProgramFilename, Params: string;
|
||||
ExtTool: TIDEExternalToolOptions;
|
||||
Filename: String;
|
||||
CurCommand: String;
|
||||
begin
|
||||
if Command='' then begin
|
||||
CurCommand:=GetParsedCommand;
|
||||
if CurCommand='' then begin
|
||||
Result:=mrOk;
|
||||
exit;
|
||||
end;
|
||||
@ -3948,7 +3968,7 @@ begin
|
||||
if SourceEditorManagerIntf<>nil then
|
||||
SourceEditorManagerIntf.ClearErrorLines;
|
||||
|
||||
SplitCmdLine(Command,ProgramFilename,Params);
|
||||
SplitCmdLine(CurCommand,ProgramFilename,Params);
|
||||
if not FilenameIsAbsolute(ProgramFilename) then begin
|
||||
Filename:=FindProgram(ProgramFilename,WorkingDir,true);
|
||||
if Filename<>'' then ProgramFilename:=Filename;
|
||||
@ -3979,6 +3999,18 @@ begin
|
||||
if assigned(OnChanged) then OnChanged(Self);
|
||||
end;
|
||||
|
||||
function TCompilationToolOptions.GetParsedCommand: string;
|
||||
begin
|
||||
if FParsedCommandStamp<>CompilerParseStamp then begin
|
||||
FParsedCommandStamp:=CompilerParseStamp;
|
||||
FParsedCommand:=Command;
|
||||
//debugln(['TCompilationToolOptions.GetParsedCommand Unparsed="',FParsedCommand,'"']);
|
||||
SubstituteMacros(FParsedCommand);
|
||||
//debugln(['TCompilationToolOptions.GetParsedCommand Parsed="',FParsedCommand,'"']);
|
||||
end;
|
||||
Result:=FParsedCommand;
|
||||
end;
|
||||
|
||||
{ TIDEBuildMacro }
|
||||
|
||||
procedure TIDEBuildMacro.SetIdentifier(const AValue: string);
|
||||
|
@ -477,6 +477,8 @@ type
|
||||
FDefaultCompileReasons: TCompileReasons;
|
||||
procedure SetCompileReasons(const AValue: TCompileReasons);
|
||||
procedure SetDefaultCompileReasons(const AValue: TCompileReasons);
|
||||
protected
|
||||
procedure SubstituteMacros(var s: string); override;
|
||||
public
|
||||
procedure Clear; override;
|
||||
function CreateDiff(CompOpts: TCompilationToolOptions;
|
||||
@ -486,6 +488,7 @@ type
|
||||
DoSwitchPathDelims: boolean); override;
|
||||
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
||||
UsePathDelim: TPathDelimSwitch); override;
|
||||
function GetProject: TProject;
|
||||
public
|
||||
property CompileReasons: TCompileReasons read FCompileReasons write SetCompileReasons;
|
||||
property DefaultCompileReasons: TCompileReasons read FDefaultCompileReasons write SetDefaultCompileReasons;
|
||||
@ -5782,6 +5785,18 @@ begin
|
||||
IncreaseChangeStamp;
|
||||
end;
|
||||
|
||||
procedure TProjectCompilationToolOptions.SubstituteMacros(var s: string);
|
||||
var
|
||||
CompOpts: TProjectCompilerOptions;
|
||||
begin
|
||||
if Owner is TProjectCompilerOptions then begin
|
||||
CompOpts:=TProjectCompilerOptions(Owner);
|
||||
//debugln(['TProjectCompilationToolOptions.SubstituteMacros ',DbgSName(Owner),' ',CompOpts.LazProject<>nil]);
|
||||
s:=CompOpts.SubstituteProjectMacros(s,false);
|
||||
end;
|
||||
inherited SubstituteMacros(s);
|
||||
end;
|
||||
|
||||
procedure TProjectCompilationToolOptions.Clear;
|
||||
begin
|
||||
inherited Clear;
|
||||
@ -5832,6 +5847,14 @@ begin
|
||||
//debugln(['TProjectCompilationToolOptions.SaveToXMLConfig ',Path,' ',crCompile in CompileReasons]);
|
||||
end;
|
||||
|
||||
function TProjectCompilationToolOptions.GetProject: TProject;
|
||||
begin
|
||||
if (Owner is TProjectCompilerOptions) then
|
||||
Result:=TProjectCompilerOptions(Owner).LazProject
|
||||
else
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
{ TProjectCompilerOptions }
|
||||
|
||||
procedure TProjectCompilerOptions.LoadFromXMLConfig(AXMLConfig: TXMLConfig;
|
||||
@ -5959,6 +5982,7 @@ function TProjectCompilerOptions.SubstituteProjectMacros(const s: string;
|
||||
begin
|
||||
Result:=s;
|
||||
if LazProject=nil then exit;
|
||||
//debugln(['TProjectCompilerOptions.SubstituteProjectMacros s="',s,'"']);
|
||||
if PlatformIndependent then
|
||||
LazProject.MacroEngine.SubstituteStr(Result,CompilerOptionMacroPlatformIndependent)
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user