Recent

Author Topic: Is there a Lazbuild compile many modes option ?  (Read 762 times)

440bx

  • Hero Member
  • *****
  • Posts: 5592
Is there a Lazbuild compile many modes option ?
« on: June 03, 2025, 08:05:45 am »
Hello,

As the title says, I'd like to know if it is possible to instruct Lazbuild to compile/build for each mode found in a .lpi file ?

Another question is: is it possible to have Lazbuild save the build/compilation result in a file named after the project, e.g, <.lpr name only>.<build mode>.lbmessages.txt ?

IOW, if a .lpi file has 4 build modes, is it possible to have Lazbuild iterate through each mode and create an output text file named after each mode ?

if the answers to those two questions is "no" and, you happen to be familiar with the Lazbuild code then, I'd like to have your estimate as to how hard and time consuming it would be to add those options to Lazbuild. 

Thank you for your help.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v4.0rc3) on Windows 7 SP1 64bit.

n7800

  • Sr. Member
  • ****
  • Posts: 399
Re: Is there a Lazbuild compile many modes option ?
« Reply #1 on: June 03, 2025, 01:26:55 pm »
I'd like to know if it is possible to instruct Lazbuild to compile/build for each mode found in a .lpi file ?

To specify the build mode, use the option:

Code: Bash  [Select][+][-]
  1. lazbuild project1.lpi --bm=release

Without specifying it, the last selected in the IDE is used by default.



The --bm parameter supports wildcards ("*"), and to specify all build modes, use:

Code: Bash  [Select][+][-]
  1. lazbuild project1.lpi --bm=*

Another question is: is it possible to have Lazbuild save the build/compilation result in a file named after the project, e.g, <.lpr name only>.<build mode>.lbmessages.txt ?

Yes, if you have the same output file name in some build modes, they will simply be overwritten...

Recently, lazbuild added the ability to specify compiler options from the command line (add/override options from the build mode), and you can specify a specific file name:

Code: Bash  [Select][+][-]
  1. lazbuild project1.lpi --opt=-oNewName.exe



You can use IDE macros in these options. To output to a file with the project name and build mode, you will need:

Code: Bash  [Select][+][-]
  1. lazbuild project1.lpi --bm=* --opt=-o$NameOnly($ProjFile())-$BuildMode().exe

Note that the build mode name may contain characters that may not be valid in the current file system.

IOW, if a .lpi file has 4 build modes, is it possible to have Lazbuild iterate through each mode and create an output text file named after each mode ?

If you want to save the console output to a file, just use redirection:

Code: Bash  [Select][+][-]
  1. lazbuild ... > output.txt

But if you want it to be saved in a separate file with the project name and build mode, things get much more complicated. You will have to manually write a script to list the build modes "--get-build-modes", and for each one, generate an output name.



To simply query the macro result (get the project name) for use in a script, you can also use the recently added "--get" option:

Code: Bash  [Select][+][-]
  1. lazbuild project1.lpi --get=$NameOnly($ProjFile())

440bx

  • Hero Member
  • *****
  • Posts: 5592
Re: Is there a Lazbuild compile many modes option ?
« Reply #2 on: June 03, 2025, 01:34:21 pm »
That is extremely useful information. :)

Thank you very much @n7800.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v4.0rc3) on Windows 7 SP1 64bit.

Mark Paley

  • Newbie
  • Posts: 3
Re: Is there a Lazbuild compile many modes option ?
« Reply #3 on: July 12, 2025, 09:56:45 pm »
If Lazbuild can accept build modes, then perhaps it's possible to create a 2-pass Lazbuild process, in order to attain Whole Program Optimization for the IDE itself?
(as per https://wiki.freepascal.org/Whole_Program_Optimization#Concrete_Lazarus_IDE_example)

dbannon

  • Hero Member
  • *****
  • Posts: 3421
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Is there a Lazbuild compile many modes option ?
« Reply #4 on: July 13, 2025, 03:23:33 am »

Code: Pascal  [Select][+][-]
  1. $> lazbuild -B
  2. or
  3. $> lazbuild --build-all

Lazbuild will also give you a list of known build modes for the project, "--get-build-modes" which could be input to a script.

I always define a different output file name when adding a build mode, eg tomboy-ng-64, tomboy-ng-A32 etc. But I would not find the lazbuild  --build-all option very useful because I have as many debug modes in there as release modes.  Easier to have the desired release mode names hard wired into a script that does my build eg

https://github.com/tomboy-notes/tomboy-ng/blob/master/package/package.bash

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

440bx

  • Hero Member
  • *****
  • Posts: 5592
Re: Is there a Lazbuild compile many modes option ?
« Reply #5 on: July 13, 2025, 04:10:23 am »
This is helpful, thank you Davo.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v4.0rc3) on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018