Recent

Author Topic: Cross Platform Procedure to Find Lazarus and FPC Executables  (Read 640 times)

simsee

  • Full Member
  • ***
  • Posts: 100
Cross Platform Procedure to Find Lazarus and FPC Executables
« on: August 01, 2022, 03:44:39 pm »
My application needs to run Lazarus and / or FPC. Therefore I would need to develop a cross platform procedure that automatically finds the absolute path of the Lazarus and FPC executables. I thought about using the information in environmentoptions.xml, but this file does not contain all the necessary information. Furthermore, it is not even trivial to write a procedure that finds a file with a certain name that works well on all file systems due to the their different organization (for example in FAT and NTFS, all drives must be enumerated, because they do not have a root directory). Do you have any suggestions? Thank you.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 10282
  • FPC developer.
Re: Cross Platform Procedure to Find Lazarus and FPC Executables
« Reply #1 on: August 01, 2022, 03:59:21 pm »
There is no procedure because there is not guaranteed just one. FPC/Lazarus both allow multiple installations.

In nearly all cases, the "fpc" binary in the system PATH is the preferred one, and in more complicated it is best for the user to provide hints in your configuration. There is no centralized administration of installs in FPC files (though maybe you can query the system's  package system).

Then initialize that configuration by first checking if there is one in the PATH, and then maybe check some common paths. Maybe the Windows innosetup installer sets some registry key that you could query.


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8260
  • Debugger - SynEdit - and more
    • wiki
Re: Cross Platform Procedure to Find Lazarus and FPC Executables
« Reply #2 on: August 01, 2022, 04:05:16 pm »
For Lazarus:

On Windows, the installer (if it is used) writes an entry to the list of "installed apps". So the uninstaller can be run from the OS. (see the inno setup files tools/install/windows/ in the lazarus dir)

For a 2ndary install there are some changes to the name of the entry (IIRC).

But people also can install Lazarus in many other ways. And they have nothing in common as to where the install will be going to. Or where to find any hints.

Mind that the lazarus config files, can also be anywhere. (on any OS).
Lazarus checks a lazarus.cfg in the same dir as the [start]lazarus.exe.





simsee

  • Full Member
  • ***
  • Posts: 100
Re: Cross Platform Procedure to Find Lazarus and FPC Executables
« Reply #3 on: August 01, 2022, 04:05:58 pm »
Thanks Marcov. I hadn't thought about using the PATH environment variable. But I noticed that on my pc (with Windows 10), PATH does not have Lazarus / FPC paths among its paths.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 10282
  • FPC developer.
Re: Cross Platform Procedure to Find Lazarus and FPC Executables
« Reply #4 on: August 08, 2022, 04:24:29 pm »
Thanks Marcov. I hadn't thought about using the PATH environment variable. But I noticed that on my pc (with Windows 10), PATH does not have Lazarus / FPC paths among its paths.

Yes, but such standalone installations are a sign that there might be multiple versions, so in that case it is probably better to prompt the user.

MarkMLl

  • Hero Member
  • *****
  • Posts: 5136
Re: Cross Platform Procedure to Find Lazarus and FPC Executables
« Reply #5 on: August 08, 2022, 06:03:36 pm »
Yes, but such standalone installations are a sign that there might be multiple versions, so in that case it is probably better to prompt the user.

Although certainly in the Linux case, a single (and usually recent) fpc binary can invoke multiple compiler backends (-V option etc.).

The result of that is that once there's a single fpc binary on the path and multiple (appropriately-named) ppcXXX binaries, the internal paths set up during installation take over.

I mention this not to find fault with what anybody's written, but in case it's possible to make use of it during installation to simplify things.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 10282
  • FPC developer.
Re: Cross Platform Procedure to Find Lazarus and FPC Executables
« Reply #6 on: August 08, 2022, 08:19:14 pm »
Yes, but such standalone installations are a sign that there might be multiple versions, so in that case it is probably better to prompt the user.

Although certainly in the Linux case, a single (and usually recent) fpc binary can invoke multiple compiler backends (-V option etc.).

I know, I added it in 9b39a588c3c54a831b7e4b0837a7296e623617c6

But it still doesn't help you enumerate the variants.

MarkMLl

  • Hero Member
  • *****
  • Posts: 5136
Re: Cross Platform Procedure to Find Lazarus and FPC Executables
« Reply #7 on: August 08, 2022, 08:22:31 pm »
I know, I added it in 9b39a588c3c54a831b7e4b0837a7296e623617c6

Really? I thought it predated the use of Git.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

PascalDragon

  • Hero Member
  • *****
  • Posts: 4540
  • Compiler Developer
Re: Cross Platform Procedure to Find Lazarus and FPC Executables
« Reply #8 on: August 08, 2022, 10:46:26 pm »
My application needs to run Lazarus and / or FPC. Therefore I would need to develop a cross platform procedure that automatically finds the absolute path of the Lazarus and FPC executables. I thought about using the information in environmentoptions.xml, but this file does not contain all the necessary information. Furthermore, it is not even trivial to write a procedure that finds a file with a certain name that works well on all file systems due to the their different organization (for example in FAT and NTFS, all drives must be enumerated, because they do not have a root directory). Do you have any suggestions? Thank you.

At least for Windows I posted an utility here that lists all the FPC and Lazarus installations. You could use that code plus looking through the directories of the PATH variable (which is more cross platform) to generate a list.

I know, I added it in 9b39a588c3c54a831b7e4b0837a7296e623617c6

Really? I thought it predated the use of Git.

The whole repository including all SVN and even CVS commits was converted to Git. It simply makes no sense anymore to refer to SVN commits, because they wouldn't be accessible anyway. So the correct way is to post the Git hash of the commit which will not change anyway. Though it would have been nice of marcov to post a link to the commit as well... ;)

MarkMLl

  • Hero Member
  • *****
  • Posts: 5136
Re: Cross Platform Procedure to Find Lazarus and FPC Executables
« Reply #9 on: August 08, 2022, 10:53:09 pm »
The whole repository including all SVN and even CVS commits was converted to Git. It simply makes no sense anymore to refer to SVN commits, because they wouldn't be accessible anyway. So the correct way is to post the Git hash of the commit which will not change anyway. Though it would have been nice of marcov to post a link to the commit as well... ;)

Just this once, I'll admit I was trolling.

But you know my feeling about the loss of linear revision numbers, and I feel that giving one for a patch during which they were still "what mattered" would have been appropriate.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 10282
  • FPC developer.
Re: Cross Platform Procedure to Find Lazarus and FPC Executables
« Reply #10 on: August 08, 2022, 10:53:43 pm »
The whole repository including all SVN and even CVS commits was converted to Git. It simply makes no sense anymore to refer to SVN commits, because they wouldn't be accessible anyway. So the correct way is to post the Git hash of the commit which will not change anyway. Though it would have been nice of marcov to post a link to the commit as well... ;)

There is a conversion/mapping file for SVN that is useful for revisions in commit messages. The mergelogs use it, and it will be needed at least till the current release cycle is complete.


 

TinyPortal © 2005-2018