Recent

Author Topic: Converting from Delphi.  (Read 740 times)

Prime

  • Jr. Member
  • **
  • Posts: 62
Converting from Delphi.
« on: March 14, 2023, 11:40:48 am »
Hi all,

In the Delphi project converter, is there a way to specify extra Lazarus packages to be included when converting.

For example I have a Delphi project that uses Indy, and have Indy installed in Lazarus, but as it stands the project converter does not know this so can't find any of the Indy units during conversion.
I then, once I have added IndyLaz to the project have to go through the units using Indy and uncomment the commented out units so it can find them.
Would be much easier if I could specify this from the get go.

Cheers.

Phill.


JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4225
  • I like bugs.
Re: Converting from Delphi.
« Reply #1 on: March 14, 2023, 05:21:24 pm »
In the Delphi project converter, is there a way to specify extra Lazarus packages to be included when converting.

For example I have a Delphi project that uses Indy, and have Indy installed in Lazarus, but as it stands the project converter does not know this so can't find any of the Indy units during conversion.
I then, once I have added IndyLaz to the project have to go through the units using Indy and uncomment the commented out units so it can find them.
Would be much easier if I could specify this from the get go.
Good point. The converter tries to find a missing unit but apparently it does not search installed packages nor offer to install (online) packages. It should.
The same dialog that is used in Project Inspector -> Required Packages -> Add... should be used to select a package.
If you want to study the code, look at
 function TDelphiUnit.AskUnitPathFromUser: TModalResult;
in unit ConvertDelphi among other code.
I would love to see contributions for the converter as well. I have maintained it but recently my time was spent to other priorities.

[Edit] No, the converter searches from all packages. See
 function TConvertDelphiProjPack.CheckPackageDep(AUnitName: string): Boolean;
It has
  Pack:=PackageGraph.FindUnitInAllPackages(AUnitName, True);
A found package is then added to project dependencies. Why does it not work with Indy? I don't know. It requires debugging.
Can you please provide a test project to convert, I could look at it next weekend.
You can also debug the converter yourself.
« Last Edit: March 14, 2023, 05:38:45 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4225
  • I like bugs.
Re: Converting from Delphi.
« Reply #2 on: March 19, 2023, 10:00:13 am »
I found a "Minimal Web Server" Delphi project from Torry's and tried to convert it. I have installed Indy 10 in Lazarus through OPM.

The reason for problems was that Indy components are registered but are not part of the "indylaz" package.
PackageGraph.FindUnitInAllPackages only finds files added into packages.
I added a heuristic guess. The code now tries to find a registered component 'T'+UnitName. It works with Indy and the package dependency gets added.

Units IdHTTPServer and IdTCPServer have registered components and are found.
The other units like IdContext do not have components and are still reported as missing. Such a unit could be found using the package search path but I didn't figure out how to do it yet.

Please test with the latest "main" branch.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 12974
Re: Converting from Delphi.
« Reply #3 on: March 19, 2023, 10:16:03 am »
A true minimal - but complete - webserver would be TinyWeb, which simply compiles in FreePascal since 20 years or something (I translated it by just adding {$mode delphi} at the time).

I would not call Indy suitable as "minimal" however good it is. Also fcl-web has may minimal examples.
I actually get compliments for being rude... (well, Dutch, but that is the same)

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4225
  • I like bugs.
Re: Converting from Delphi.
« Reply #4 on: March 19, 2023, 12:19:06 pm »
A true minimal - but complete - webserver would be TinyWeb, which simply compiles in FreePascal since 20 years or something (I translated it by just adding {$mode delphi} at the time).
I would not call Indy suitable as "minimal" however good it is. Also fcl-web has may minimal examples.
I believe that is true.
I needed a Delphi project that uses Indy to test the conversion and just picked one from Torry's. I guess any project with Indy would do.
In fact it was not directly from Torry's page but there was a link to some old Indy archive. Anyway I found a project to test with.
« Last Edit: March 19, 2023, 12:21:23 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4225
  • I like bugs.
Re: Converting from Delphi.
« Reply #5 on: March 26, 2023, 02:53:00 pm »
Please test the converter in Lazarus "main" development branch.
It now finds a missing unit from any open package even if the unit file is not included in the package file. It searches the package's paths.
An "open package" means installed packages + packages open in the IDE.

Searching package links including OPM packages would be the next step. An OPM package should be installed then automatically.
A name of a package that was once opened in the IDE is remembered. Such a package is also a "package link".
« Last Edit: March 27, 2023, 06:45:05 am by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

 

TinyPortal © 2005-2018