Recent

Author Topic: Buil number as part of compiled binary file name  (Read 1571 times)

srnec

  • Newbie
  • Posts: 5
Buil number as part of compiled binary file name
« on: February 03, 2025, 08:31:24 am »
Hello, is it there a possibility to have build number included in file name or path? I searched in IDE macros and others settings but found nothing.

Thaddy

  • Hero Member
  • *****
  • Posts: 19139
  • Glad to be alive.
Re: Buil number as part of compiled binary file name
« Reply #1 on: February 03, 2025, 08:38:37 am »
The version info dialog in Lazarus




objects are fine constructs. You can even initialize them with constructors.

srnec

  • Newbie
  • Posts: 5
Re: Buil number as part of compiled binary file name
« Reply #2 on: February 03, 2025, 08:58:03 am »
The version info dialog in Lazarus

"The version info dialog" includes version info in compiled file itself, I am looking for build number in file name.

In the Project Options
Compiler - Paths - Target File name:
and use somethink like lib/myBinary-$(BuildNo)

dbannon

  • Hero Member
  • *****
  • Posts: 3803
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Buil number as part of compiled binary file name
« Reply #3 on: February 03, 2025, 09:14:29 am »
Lazarus will run a command or script after the compile

Code: Bash  [Select][+][-]
  1. $> mv project1 project1-b343

Er, Windows, its 'rename' perhaps ?

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

cdbc

  • Hero Member
  • *****
  • Posts: 2776
    • http://www.cdbc.dk
Re: Buil number as part of compiled binary file name
« Reply #4 on: February 03, 2025, 10:45:13 am »
Hi
You can set the 'Target-filename' in 'Project' -> 'Options' -> 'Paths'
See the attached screen-shot...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

MarkMLl

  • Hero Member
  • *****
  • Posts: 8572
Re: Buil number as part of compiled binary file name
« Reply #5 on: February 03, 2025, 10:53:57 am »
But as far as I can see there isn't an IDE macro which expands to the build number, so it can't be automated by either setting a target filename or by renaming after the build (without having an external program which reads the build version from the binary then renames it appropriately).

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

n7800

  • Hero Member
  • *****
  • Posts: 691
  • Lazarus IDE contributor
    • GitLab profile
Re: Buil number as part of compiled binary file name
« Reply #6 on: February 03, 2025, 12:15:27 pm »
There is no such macro, but it was added to trunk. It will be released in Lazarus 5.0.

440bx

  • Hero Member
  • *****
  • Posts: 6479
Re: Buil number as part of compiled binary file name
« Reply #7 on: February 03, 2025, 12:42:15 pm »
There is no such macro, but it was added to trunk. It will be released in Lazarus 5.0.
I am under the impression that the macro you are referring to returns Lazarus IDE information.  Is this correct ?

Also, I am under the impression that what the OP is asking for is to be able to use the _applicaton's_ build information (like what's stored in the Windows version info.)  If this is correct then the Lazarus macro you referred to does not apply.

Are either one of these impressions incorrect ?
FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 19139
  • Glad to be alive.
Re: Buil number as part of compiled binary file name
« Reply #8 on: February 03, 2025, 12:56:06 pm »
Yes, it is info about lazarus itself, not info about your own compiled binaries and that is what is asked.
The way to do that is to use two of the tips mentioned above:
1. Use the version info dialog
2. Extract the build info into a string and add that to the executable name by using mv or rename.

There are some other ways to achieve that. Have to check if these still work.
objects are fine constructs. You can even initialize them with constructors.

n7800

  • Hero Member
  • *****
  • Posts: 691
  • Lazarus IDE contributor
    • GitLab profile
Re: Buil number as part of compiled binary file name
« Reply #9 on: February 03, 2025, 12:59:20 pm »
It's sad to hear this, because I spent a lot of time writing the description and example of use... ((

The very first line says:
Quote
Adds a macro to the IDE that returns the project version number.

The last section "$LazVer() macro" (this is already a macro for the IDE version) says:
Quote
For consistency, the second commit adds the same optional parameters to the $LazVer() macro.

So, I added a macro for the project. And additionally added parameters for the IDE macro (which already exists, but has no parameters).

EDIT: Even the title also says:
Quote
IDE: Added IDE macro ProjVer to get project version. Issue #23198
« Last Edit: February 03, 2025, 01:01:29 pm by n7800 »

440bx

  • Hero Member
  • *****
  • Posts: 6479
Re: Buil number as part of compiled binary file name
« Reply #10 on: February 03, 2025, 01:04:52 pm »
It's sad to hear this, because I spent a lot of time writing the description and example of use...
Even if the macro you implemented doesn't solve the OP's problem, there is a good chance it will be useful to other people.

IOW, don't be sad, it is very likely to be useful.
FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

alpine

  • Hero Member
  • *****
  • Posts: 1412
Re: Buil number as part of compiled binary file name
« Reply #11 on: February 03, 2025, 02:56:11 pm »
1. Use the version info dialog
2. Extract the build info into a string and add that to the executable name by using mv or rename.
wmic can be used on Window$. Put that in a filever.cmd file:
Code: Text  [Select][+][-]
  1. @echo off
  2. rem display file version of an executable file
  3.  
  4.     setlocal enableextensions
  5.  
  6.     rem fully expand the file name
  7.     set "file=%~dp1%~nx1"
  8.        
  9.     if not defined file goto :eof
  10.     if not exist "%file%" goto :eof
  11.  
  12.     rem use wmic to get file version in %vers%
  13.     set "vers="
  14.     for /F "tokens=2 delims==" %%g in ('
  15.         wmic datafile where name^="%file:\=\\%" get Version /value
  16.     ') do set "vers=%%g"
  17.  
  18.     if not "%vers%"=="" echo %vers%
  19.  
  20.     endlocal

Then: filever.cmd somefile.exe

will output something like:
Code: Text  [Select][+][-]
  1. 7.14.0.3804

Don't know for Linux.
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

Thaddy

  • Hero Member
  • *****
  • Posts: 19139
  • Glad to be alive.
Re: Buil number as part of compiled binary file name
« Reply #12 on: February 03, 2025, 02:59:29 pm »
The way I proposed is cross-platform.

You can also do it manually by specifying the -o<version> option.
If you use a version control system like git or svn for your own sources, the version should be easy to script.
« Last Edit: February 03, 2025, 04:10:35 pm by Thaddy »
objects are fine constructs. You can even initialize them with constructors.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4715
  • I like bugs.
Re: Buil number as part of compiled binary file name
« Reply #13 on: February 03, 2025, 08:33:11 pm »
Even if the macro you implemented doesn't solve the OP's problem, there is a good chance it will be useful to other people.
Why wouldn't the $ProjVer() macro solve this problem? It looks like a perfect match to me.
The "Target file name (-o)" field in Project Options supports macros AFAIK.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

srnec

  • Newbie
  • Posts: 5
Re: Buil number as part of compiled binary file name
« Reply #14 on: February 03, 2025, 08:46:07 pm »
For me, the $ProjVer(build) looks like perfect solution. Clean and multiplatform.
There is possibility to extract "<BuildNr Value="xxx"/>" from .lpi file and rename compiled binary, but use of macro is more straightforward. I think adding new macro to IDE is useful also other purposes.

 

TinyPortal © 2005-2018