On 11-5-2020 09:33, Bo Berglund via lazarus wrote:
On Sun, 10 May 2020 14:37:12 +0200, Marc Weustink via lazarus
<[email protected]> 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?
Tools - Delphi conversion - Convert delphi project.
Disable scan files in parent directory
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>
Yep, didn't get those, but others. Just removed them.
and:
<Other>
<CustomOptions Value="-dBorland -dVer150 -dDelphi7
-dCompiler6_Up -dPUREPASCAL"/>
</Other>
I keep them, it might be used by some 3rd party packages, and some of
our earlier code. It doesn't hurt to keep them
The lpr file looks pretty much like the dpr original except for the
added:
{$MODE Delphi}
That one I remove as well. I define delphi mode in the compiler settings
of the project. This way the units can be used inh delphi too (without
adding extra ifdefs)
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?
Yes, it is a manual conversion. But in our case not that hard. Most of
the converted projects are windows (network) services.
The difference between a delphi service and a fpc daemon is covered in a
BaseServer class / unit. So for services derived from it there is no
different code.
Also we do have our own network/serial/async thread notification
libraries. So once those got converted, most of the projects would build.
Since we were using D6, a lot of newer win api functions were missing.
Therefore we already had Win32Api unit for all missing functions/types.
In case of FPC this unit is extended for missing functions in FPC (and
later functions/types existing in FPC but missing in Delphi)
This is also why I don't let the convertor touch the existing code, most
incompatibilities are handled in this unit (openfile/fileopen for instance).
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}
Not needed if you enable delphi mode in the compiler options
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}
This is what I need to do as well. It is a nice reevaluation if I still
need all those units.
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...
Most of our services are configured by cmdline (and it gets parsed
through our own helper class)
And I am also purging no longer wanted old functions...
Grateful for any suggestions and advice!
Marc
--
_______________________________________________
lazarus mailing list
[email protected]
https://lists.lazarus-ide.org/listinfo/lazarus