[Lazarus] Where to define conditionals for FPC
Bo Berglund
bo.berglund at gmail.com
Mon May 11 09:33:35 CEST 2020
On Sun, 10 May 2020 14:37:12 +0200, Marc Weustink via lazarus
<lazarus at lists.lazarus-ide.org> wrote:
>The last weeks, since I'm working from home, I've been converting a lot
>of our Delphi 6 projects. I only use the convertor to get a Lazarus
>project from a dpr. All other changes I revert. The convertor breaks
>more than it fixes. Like in your case we still release our software
>build by Delphi. Once I have the lpi, I never use the convertor again.
>So it cannot touch defines and such.
Interesting!
I have a few questions:
1) Lazarus project file conversion
You state that you just use the converter to get a project in Lazarus
from the Delphi dpr file.
Exactly how do you do this?
2) Lazarus project file (lpi)
When you convert to Lazarus are you also getting an lpi file?
And does the lpi file contain references into the Delphi install
directories?
The lpi file from my first (failed) conversion contains stuff like
this:
<SearchPaths>
<IncludeFiles Value="C:\Programs\CodeGear\RAD
Studio\5.0\source\Win32\vcl\;..\..\..\CMP\SentinelAGI;..\..\..\CMP\Log3R;..\..\..\CMP\SystemResource;..\..\..\CMP\Version;..\..\Common;..\..\..\CMP\AsyncPro\source;..\..\..\CMP\DLPortIO\source;..\..\..\CMP\Indy10\Protocols;$(ProjOutDir)"/>
<OtherUnitFiles Value="C:\Programs\CodeGear\RAD
Studio\5.0\source\Win32\vcl\;..\..\..\CMP\SentinelAGI;..\..\..\CMP\Log3R;..\..\..\CMP\SystemResource;..\..\..\CMP\Version;..\..\Common;..\..\..\CMP\AsyncPro\source;..\..\..\CMP\DLPortIO\source;..\..\..\CMP\Indy10\Protocols;C:\Programs\CodeGear\RAD
Studio\5.0\source\Win32\rtl\win\"/>
<UnitOutputDirectory Value="..\bin"/>
</SearchPaths>
and:
<Other>
<CustomOptions Value="-dBorland -dVer150 -dDelphi7
-dCompiler6_Up -dPUREPASCAL"/>
</Other>
The lpr file looks pretty much like the dpr original except for the
added:
{$MODE Delphi}
3) Compiling same code with Delphi and FPC?
Do you convert your projects (manually) to make it possible to use
both Delphi and Lazarus as the IDE for further work on the same
sources?
If so do you have any hints as to what to look out for?
What I am doing now is that inside Delphi 2007 I am editing all of the
project files and adding this on top:
{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}
I also replace the uses reference to Windows with this (which is what
the converter dir in the failed run):
uses
{$IFDEF FPC}
LCLIntf,
LCLType,
LMessages,
{$ELSE}
Windows,
{$ENDIF}
Then I am also using conditionals to exclude functions relying on
Delphi-only units and replacing these with "neutral" units.
For example I am enabling Registry usage only if on Windows and
instead use conf files on Linux. The built in Lazarus Registry unit
handling of Registry calls on Linux is too complex for me...
And I am also purging no longer wanted old functions...
Grateful for any suggestions and advice!
--
Bo Berglund
Developer in Sweden
More information about the lazarus
mailing list