Recent

Author Topic: Lazarus Cross-Platform Project  (Read 27719 times)

mijen67

  • Full Member
  • ***
  • Posts: 130
  • It's hard to beat the bandwidth of a flying DVD
Re: Lazarus Cross-Platform Project
« Reply #30 on: April 06, 2018, 06:05:10 pm »
Here's something I was working on earlier this summer. Realized today that summer is almost over and it's time to post this thing!

-Phil

Great contribution!
In my opinion this should be integrated to be core part of Lazarus.

Question.
How is appname, vendor, and version communicated to the OS? I know it's a long story, but could I get a brief variant?

Does the project support changing these if they are changed during development?

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Lazarus Cross-Platform Project
« Reply #31 on: April 06, 2018, 06:07:01 pm »
Question.
How is appname, vendor, and version communicated to the OS? I know it's a long story, but could I get a brief variant?

Does the project support changing these if they are changed during development?

Not sure if I understand your questions. Could you elaborate, maybe give an example?

mijen67

  • Full Member
  • ***
  • Posts: 130
  • It's hard to beat the bandwidth of a flying DVD
Re: Lazarus Cross-Platform Project
« Reply #32 on: April 06, 2018, 06:10:44 pm »
Question.
How is appname, vendor, and version communicated to the OS? I know it's a long story, but could I get a brief variant?

Does the project support changing these if they are changed during development?

Not sure if I understand your questions. Could you elaborate, maybe give an example?

Sure. I'm mostly working on Windows, so this is my perspective. If I open control panel and programs, I can find a list of programs with above information and more, e.g. size, last used etc. How does this information (appname, version, vendor) flow from creating Cross-Platform Project"  to the OS?
« Last Edit: April 06, 2018, 06:13:22 pm by mijen67 »

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Lazarus Cross-Platform Project
« Reply #33 on: April 06, 2018, 06:14:43 pm »
Sure. I'm mostly working on Windows, so this is my perspective. If I open control panel and programs, I can find a list of programs including above information and more, e.g. size, last used etc. How does this information (appname, version, vendor) flow from creating Cross-Platform Project"  to the OS?

Ah yes, that's put there by the installer. In this case, the installer .exe created by Inno Setup from the project's .iss file.

Have you used Inno Setup before? Quite a nice tool, very powerful for creating installers on Windows.

mijen67

  • Full Member
  • ***
  • Posts: 130
  • It's hard to beat the bandwidth of a flying DVD
Re: Lazarus Cross-Platform Project
« Reply #34 on: April 06, 2018, 06:16:59 pm »
Sure. I'm mostly working on Windows, so this is my perspective. If I open control panel and programs, I can find a list of programs including above information and more, e.g. size, last used etc. How does this information (appname, version, vendor) flow from creating Cross-Platform Project"  to the OS?

Ah yes, that's put there by the installer. In this case, the installer .exe created by Inno Setup from the project's .iss file.

Have you used Inno Setup before? Quite a nice tool, very powerful for creating installers on Windows.

Yes, I've used Inno Setup, and I agree.

Ok, so how does this information get from "Creating Cross-Platform Project" to the installer? And can it be altered if changed?

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Lazarus Cross-Platform Project
« Reply #35 on: April 06, 2018, 06:22:47 pm »
Ok, so how does this information get from "Creating Cross-Platform Project" to the installer? And can it be altered if changed?

I assume you've read this:

https://macpgmr.github.io/MacXPlatform/LazXProj.html#HowItWorks

The .lpi file contains a place for Windows version information. Some of this information is used for Mac and Linux too (version, etc.).

For example, when you update the version in Project Options in Lazarus, the version resource gets updated and compiled into the Windows .exe. At runtime your app can read this info, for example to get the app name and version and copyright. The installer script also gets updated by fix_xproj, etc.

mijen67

  • Full Member
  • ***
  • Posts: 130
  • It's hard to beat the bandwidth of a flying DVD
Re: Lazarus Cross-Platform Project
« Reply #36 on: April 06, 2018, 08:14:09 pm »
Ok, so how does this information get from "Creating Cross-Platform Project" to the installer? And can it be altered if changed?

I assume you've read this:

https://macpgmr.github.io/MacXPlatform/LazXProj.html#HowItWorks

I did, but I couldn't follow you all the way, I apologize.

Quote
The .lpi file contains a place for Windows version information. Some of this information is used for Mac and Linux too (version, etc.).

For example, when you update the version in Project Options in Lazarus, the version resource gets updated and compiled into the Windows .exe. At runtime your app can read this info, for example to get the app name and version and copyright. The installer script also gets updated by fix_xproj, etc.

So the settings in the .lpi file can be controlled through the Lazarus IDE - by following below menus: 

-> Options for Project: <projectname> -> Application -> Title ...I assume is Name of App that will be registered with Windows, Linux, Mac?

-> Options for Project: <projectname> -> Application -> For Windows -> Name:  CompanyName.ProductName.AppName is used where?

-> Options for Project: <projectname> -> Application -> For Windows -> Description: Is used where?

-> Options for Project: <projectname> -> Version Info -> Check "Include version info in executable", and add Version number, CompanyName, ProductName, ProductVersion?

Is ProductVersion used, or is Version Info number used?

I guess, I'm asking what fields are required, and what fields are nice to have?

Regarding:

Quote
Since the app name may not be the same as the target executable, it uses the target name to create a symlink to the actual app bundle if they differ. This is required so Lazarus can debug the app.

Does this also go for Windows, Linux? If positive, how is it handled if they are set differently?
« Last Edit: April 06, 2018, 08:18:40 pm by mijen67 »

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Lazarus Cross-Platform Project
« Reply #37 on: April 06, 2018, 10:08:00 pm »
-> Options for Project: <projectname> -> Application -> Title ...I assume is Name of App that will be registered with Windows, Linux, Mac?

Doesn't use the title. You can set that yourself to whatever you want. But since it typically duplicates what's in the version info, I would just set it at runtime, for example to ProductName from version info.

Be sure to familiarize yourself with the MS doc linked to in the LazXProj article.

-> Options for Project: <projectname> -> Application -> For Windows -> Name:  CompanyName.ProductName.AppName is used where?

I assume you mean the bundle ID here. That's a Mac-specific way of identifying the app. All Mac IDEs prompt for this when they create a new project. All except Lazarus, of course, but then Lazarus is not really a Mac IDE, it's a Unix IDE that happens to run on Mac.

Like Delphi, Lazarus supports more than just the standard MS version info items, so I added BundleIdentifier, since it's so critical to a Mac app.

-> Options for Project: <projectname> -> Application -> For Windows -> Description: Is used where?

Wherever you want, for example in an About box. See MS docs.

-> Options for Project: <projectname> -> Version Info -> Check "Include version info in executable", and add Version number, CompanyName, ProductName, ProductVersion?

Is ProductVersion used, or is Version Info number used?

Version Info is the entire set of items. Maybe you mean FileVersion? See MS docs. FileVersion is typically the build version.

I guess, I'm asking what fields are required, and what fields are nice to have?

Nothing is really required except perhaps the bundle ID with a Mac app.

Quote
Since the app name may not be the same as the target executable, it uses the target name to create a symlink to the actual app bundle if they differ. This is required so Lazarus can debug the app.

Does this also go for Windows, Linux? If positive, how is it handled if they are set differently?

An app bundle is Mac-only.

mijen67

  • Full Member
  • ***
  • Posts: 130
  • It's hard to beat the bandwidth of a flying DVD
Re: Lazarus Cross-Platform Project
« Reply #38 on: April 06, 2018, 11:04:51 pm »
-> Options for Project: <projectname> -> Application -> Title ...I assume is Name of App that will be registered with Windows, Linux, Mac?

Doesn't use the title. You can set that yourself to whatever you want. But since it typically duplicates what's in the version info, I would just set it at runtime, for example to ProductName from version info.

Phew ... you know your stuff. However, does it answer my questions?

Let me rephrase:

When starting a new Cross-Platform Project I need to provide:

Application Name,
Project Name,
Bundle identifier
Creates Files in.

I'm assuming the following, please correct when I'm wrong:

Application Name -> Is the application name that will be presented at top bar of program, and to the OS when the application is registered with the OS?

Project Name: Used for?

Bundle Identifier: Used when creating Mac bundle, that part is clear.

Create Files In: The folder to hold the Lazarus project files and the templates etc, that part is clear.

How/where do I set:

Version number - that gets communicated to OS when registering app with OS?

Vendor name? - that gets communicated to OS when registering app with OS?

And should I decide to change any of Application name, version number and vendor name - can I do it? And if positive where is it done?

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Lazarus Cross-Platform Project
« Reply #39 on: April 06, 2018, 11:20:28 pm »
Application Name -> Is the application name that will be presented at top bar of program, and to the OS when the application is registered with the OS?

That sets the ProductName in the version info.

It's also used to set the BundleName in the Mac app's Info.plist file. macOS uses this then for the app's menu (the menu to the left of the File menu). Since Mac app names are never all lower-case, this is typically a mixed-case name. That makes sense for the product name too, of course, on other platforms too.

You can use ProductName to set the app's title, for example in the main form's FormCreate event handler:

  Application.Title := VersionList.Values['ProductName'];

Project Name: Used for?

That sets the project file names (.lpi).

Version number - that gets communicated to OS when registering app with OS?

Vendor name? - that gets communicated to OS when registering app with OS?

And should I decide to change any of Application name, version number and vendor name - can I do it? And if positive where is it done?

In Laz Project Options under Version Info. Set some of these things, save the project, then open the .lpi file in a text editor to see how the version info is stored in the .lpi file.

Most can be changed without any problem.

mijen67

  • Full Member
  • ***
  • Posts: 130
  • It's hard to beat the bandwidth of a flying DVD
Re: Lazarus Cross-Platform Project
« Reply #40 on: April 06, 2018, 11:28:25 pm »
Version number - that gets communicated to OS when registering app with OS?

Vendor name? - that gets communicated to OS when registering app with OS?

And should I decide to change any of Application name, version number and vendor name - can I do it? And if positive where is it done?

In Laz Project Options under Version Info. Set some of these things, save the project, then open the .lpi file in a text editor to see how the version info is stored in the .lpi file.

Most can be changed without any problem.

I like the comment "most" ... then you haven't promised anything  :D

I was assuming that your utilities carries the discussed information from Lazarus Project Options (among others?) to installation files / resource files / bundle files, plist ... but since you can't give clear answers to where they should be set / changed, my assumption may be wrong?

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Lazarus Cross-Platform Project
« Reply #41 on: April 06, 2018, 11:32:55 pm »
Version number - that gets communicated to OS when registering app with OS?

Vendor name? - that gets communicated to OS when registering app with OS?

And should I decide to change any of Application name, version number and vendor name - can I do it? And if positive where is it done?

In Laz Project Options under Version Info. Set some of these things, save the project, then open the .lpi file in a text editor to see how the version info is stored in the .lpi file.

Most can be changed without any problem.

I like the comment "most" ... then you haven't promised anything  :D

I was assuming that your utilities carries the discussed information from Lazarus Project Options (among others?) to installation files / resource files / bundle files, plist ... but since you can't give clear answers to where they should be set / changed, my assumption may be wrong?

Yes, the fix_xproj utility that gets run automatically by Lazarus after each compile attempts to update the version info for all platforms, both in the app files and the installer scripts. Look at the VersionInfoListEx.pas unit.


mijen67

  • Full Member
  • ***
  • Posts: 130
  • It's hard to beat the bandwidth of a flying DVD
Re: Lazarus Cross-Platform Project
« Reply #42 on: April 07, 2018, 12:30:48 am »
Yes, the fix_xproj utility that gets run automatically by Lazarus after each compile attempts to update the version info for all platforms, both in the app files and the installer scripts. Look at the VersionInfoListEx.pas unit.

As a newbie I'm probably not the best to ask for reading others code. I saw some code snippets mentioning INI files. Are you using ini files for the registration of the app on Windows? Instead of the Windows Registry? It doesn't seem like the "modern way". I'm probably wrong?
« Last Edit: April 07, 2018, 12:40:34 am by mijen67 »

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Lazarus Cross-Platform Project
« Reply #43 on: April 07, 2018, 12:40:55 am »
Are you using ini files for the registration of the app on Windows? Instead of the Windows Registry? It doesn't seem like to "modern way". I'm probably wrong?

The .ini file is used for saving app preferences or any other configuration or state information that you want to save between runs of the app. "Registration", if I understand you correctly, is done by the installer. See the Inno Setup installer script - it "registers" the app so that information appears in the Control Panel for uninstalling, etc. The installer saves this info in the registry.


mijen67

  • Full Member
  • ***
  • Posts: 130
  • It's hard to beat the bandwidth of a flying DVD
Re: Lazarus Cross-Platform Project
« Reply #44 on: April 07, 2018, 01:00:49 am »
Are you using ini files for the registration of the app on Windows? Instead of the Windows Registry? It doesn't seem like to "modern way". I'm probably wrong?

The .ini file is used for saving app preferences or any other configuration or state information that you want to save between runs of the app. "Registration", if I understand you correctly, is done by the installer. See the Inno Setup installer script - it "registers" the app so that information appears in the Control Panel for uninstalling, etc. The installer saves this info in the registry.

Ok, so actually the Windows part of your system is kind of old school, see e.q. quote from https://en.wikipedia.org/wiki/INI_file : "Starting with Windows NT, Microsoft favored the use of the registry, and began to steer developers away from using INI files for configuration". However it seems that .net applications now are back to using files (.xml) for storing settings, so who cares.

Are you actively using your system on Windows also?

 

TinyPortal © 2005-2018