Lazarus

Programming => Operating Systems => Linux => Topic started by: Graham1 on November 27, 2022, 02:44:42 am

Title: Include version in target file name?
Post by: Graham1 on November 27, 2022, 02:44:42 am
Probably a stupid (Linux) beginners question, but how to I set up the "Target file name (-o)" line in the Project Options (Compiler Options / Paths) so that it will include the version number? So instead of having just "MyProg" when I compile my project I want to have "MyProg-1.0" where the version numbers are those on the Version info screen for the project.

Thank you!
Title: Re: Include version in target file name?
Post by: VTwin on November 27, 2022, 04:54:28 am
I'm not sure why you would want to do that, as it seems unusual for any applications that I am aware of. The version numbers can be used for display in about dialogs. I assume you would have to rename your application for each release.

Maybe someone else has another idea.
Title: Re: Include version in target file name?
Post by: MarkMLl on November 27, 2022, 09:59:17 am
I'm not sure why you would want to do that, as it seems unusual for any applications that I am aware of.

The fact is that he does want to do it, so let's do him the courtesy of assuming that he's got a good reason.

I'm not sure that you can do it directly. By and large you can do things like adding the target processor by putting e.g.

jds6600-$(TargetCPU)-$(TargetOS)-$(LCLWidgetType)

into "Target file name" noting that the support for this being used with "Set compiler options as default" is patchy.

If you look at the IDE's Tools -> Configure External Tools -> Add -> Macros you can see what's usable in that context, although I think there's additional subtleties in some of the naming.

You can also use the IDE's Compiler Commands -> Execute after -> Command to do various stuff, which suggests that if your target program had a --version option which output the build numbers, then you could filter that using a script and rename the binary.

An alternative would be to hold the build numbers in some sort of external file and inject them into the IDE's files (probably the .lpi) but if you attempted this you would be infringing on the developers' prerogatives by assuming that they would never change that file's format which would be extremely rash. For that same reason, I would suggest not attempting to have your final renaming operation not attempting to extract the build version from the IDE files itself.

See e.g. https://github.com/MarkMLl/Mastech_ms2115b for an example of processing the --version option in a project's .lpr and extracting the build version from the executable.

MarkMLl



Title: Re: Include version in target file name?
Post by: dbannon on November 27, 2022, 10:32:32 am
Graham, I'd suggest that having the version number in the Packaging name rather the binary is a good idea. And many apps, the binary, will report their version with a -v or --version command line or in an About box.

When I compile my app, for release, I set an Environment Variable that is read during compile so that the version number is available. So, in the app there is some code like -

Code: Pascal  [Select][+][-]
  1. const Version_string  = {$I %TOMBOY_NG_VER};
  2. ...
  3. ...
  4.     if Application.HasOption('v', 'version') then begin
  5.         debugln('tomboy-ng version ' + Version_String);
  6.         exit(False);
  7.      end;

And when I compile, I do -

Code: Bash  [Select][+][-]
  1. TOMBOY_NG_VERSION=0.35   fpc ......

Davo
TinyPortal © 2005-2018