Recent

Author Topic: SetAlternativeCompile "for after"  (Read 8314 times)

Mathias

  • Jr. Member
  • **
  • Posts: 88
Re: SetAlternativeCompile "for after"
« Reply #15 on: September 15, 2018, 09:14:41 pm »
This has been done since the Lazarus team have incorporated this into the newest trunk.

Thanks to the team

ccrause

  • Hero Member
  • *****
  • Posts: 845
Re: SetAlternativeCompile "for after"
« Reply #16 on: September 17, 2018, 07:24:21 am »
What I have not managed yet are the Reasons parameters.
Looking at TProjectCompilerOptions.Create in ide/project.pp shows that the ExecuteBefore/after properties of TBaseCompilerOptions are created as type TProjectCompilationToolOptions, which contains a CompileReasons property.

I tried declaring a properties with get/set methods in TLazCompilerOptions:
Code: Pascal  [Select][+][-]
  1.   protected
  2.     function GetExecuteBeforeReasons: TCompileReasons; virtual; abstract;
  3.     function GetExecuteAfterReasons: TCompileReasons; virtual; abstract;
  4.     procedure SetExecuteBeforeReasons(Areasons: TCompileReasons); virtual; abstract;
  5.     procedure SetExecuteAfterReasons(Areasons: TCompileReasons); virtual; abstract;
  6. ...
  7.   public
  8.     property ExecuteBeforeReasons: TCompileReasons read GetExecuteBeforeReasons write SetExecuteBeforeReasons;
  9.     property ExecuteAfterReasons: TCompileReasons read GetExecuteAfterReasons write SetExecuteAfterReasons;
  10.  
With the following overrides in TProjectCompilerOptions:
Code: Pascal  [Select][+][-]
  1.     function GetExecuteBeforeReasons: TCompileReasons; override;
  2.     function GetExecuteAfterReasons: TCompileReasons; override;
  3. ...
  4. function TProjectCompilerOptions.GetExecuteBeforeReasons: TCompileReasons;
  5. begin
  6.   Result := TProjectCompilationToolOptions(ExecuteBefore).CompileReasons;
  7. end;
  8.  
  9. function TProjectCompilerOptions.GetExecuteAfterReasons: TCompileReasons;
  10. begin
  11.   Result := TProjectCompilationToolOptions(ExecuteAfter).CompileReasons;
  12. end;
  13.  
This gives an abstract error when calling as follows:
Code: Pascal  [Select][+][-]
  1.   AProject.LazCompilerOptions.ExecuteAfterReasons := [crRun];
  2.  
I'm not sure why this doesn't work like the ExecuteAfterCommand changes. An alternative may be to move the definitions of TCompilationToolOptions and TProjectCompilationToolOptions to projintf.p, move fExecuteBefore and property ExecuteBefore etc up the hierarchy to TLasCompilerOptions and implement the get/set functionality in TLazCompilerOptions. Not sure if this is a good way of refactoring the classes.

kupferstecher

  • Hero Member
  • *****
  • Posts: 583
Re: SetAlternativeCompile "for after"
« Reply #17 on: September 17, 2018, 08:52:45 am »
I tested the same and it works for me (Laz 1.8.0).
What is the actual error message you get?

In your post you didn't implement SetExecuteAfterReasons which you call with AProject.LazCompilerOptions.ExecuteAfterReasons := [crRun];

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: SetAlternativeCompile "for after"
« Reply #18 on: September 17, 2018, 12:03:48 pm »
Please see my comment in
 https://bugs.freepascal.org/view.php?id=34289
Things are starting to go wrong! Let's do the API properly please.

[Edit]
Now only the original issue is open. Please see my latest comment and test with r59043.
 https://bugs.freepascal.org/view.php?id=34283
« Last Edit: September 17, 2018, 02:44:55 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: SetAlternativeCompile "for after"
« Reply #19 on: September 17, 2018, 03:08:39 pm »
Looking at TProjectCompilerOptions.Create in ide/project.pp shows that the ExecuteBefore/after properties of TBaseCompilerOptions are created as type TProjectCompilationToolOptions, which contains a CompileReasons property.
Yes and it seems it is the only tool class ever used. The base TCompilationToolOptions does not have other inherited classes and an instance object of it is never created.
The IDE may have many useless checks like "if xxx is TProjectCompilationToolOptions then ...".

BTW, TProjectCompilerOptions also has CompileReasons. Would it be needed in the interface?
Now only the ExecuteBefore/after tool's CompileReasons is moved to the interface.

[Edit]
I improved the code and removed some TProjectCompilationToolOptions tests + cleaned the code in r59044. Please test more.
« Last Edit: September 17, 2018, 07:10:33 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

ccrause

  • Hero Member
  • *****
  • Posts: 845
Re: SetAlternativeCompile "for after"
« Reply #20 on: September 17, 2018, 09:23:36 pm »
I've tested r59045 with Mathias's AVR plugin and it works as expected.

 

TinyPortal © 2005-2018