Lazarus

Using the Lazarus IDE => General => Topic started by: 440bx on May 11, 2025, 05:43:08 pm

Title: how to compile multiple modes in one step ?
Post by: 440bx on May 11, 2025, 05:43:08 pm
Hello,

I commonly have 4 build modes: Win32 debug, Win32 release, Win64 debug and Win64 release.

So far I've been switching from one mode to another when I need the build in whatever other mode I want at the time.  This switching from one mode to another gets tedious after a while.

My question is: is there a way to have Lazarus automatically compile for each build mode ?  e.g, in the case of 4 build modes, start at the top one and build for each mode until the last one is reached.

Thank you for your help.
Title: Re: how to compile multiple modes in one step ?
Post by: Thaddy on May 11, 2025, 05:48:04 pm
A script? Just make sure every build has its own directory.
Title: Re: how to compile multiple modes in one step ?
Post by: 440bx on May 11, 2025, 05:57:17 pm
A script?
That would be fine.  Do you have a script that does that ?

Just make sure every build has its own directory.
That's already taken care of.
Title: Re: how to compile multiple modes in one step ?
Post by: Thaddy on May 11, 2025, 06:07:28 pm
I can make one. A bat or a sh?
Something like (depends on fpc.cfg):
Code: Bash  [Select][+][-]
  1. #!/bin/sh
  2.  
  3. # Configuration
  4. SOURCE="MyProgram.pas"
  5. DEBUG_DIR="bin/debug"
  6. RELEASE_DIR="bin/release"
  7.  
  8. # Check if FPC is available
  9. if ! command -v fpc >/dev/null 2>&1; then
  10.     echo "Free Pascal Compiler (fpc) not found in PATH"
  11.     exit 1
  12. fi
  13.  
  14. # Create output directories
  15. mkdir -p "$DEBUG_DIR/units"
  16. mkdir -p "$RELEASE_DIR/units"
  17.  
  18. # Debug build
  19. echo "Compiling DEBUG version..."
  20. fpc -dDEBUG -gl -FE$DEBUG_DIR -FU$DEBUG_DIR/units "$SOURCE"
  21. if [ $? -ne 0 ]; then
  22.     echo "DEBUG build failed!"
  23.     exit 1
  24. fi
  25.  
  26. # Release build
  27. echo "Compiling RELEASE version..."
  28. fpc -dRELEASE -O3 -CX -XX -FE$RELEASE_DIR -FU$RELEASE_DIR/units "$SOURCE"
  29. if [ $? -ne 0 ]; then
  30.     echo "RELEASE build failed!"
  31.     exit 1
  32. fi
  33.  
  34. echo "Both builds completed successfully!"
  35. echo "Debug output:   $DEBUG_DIR"
  36. echo "Release output: $RELEASE_DIR"
Not tested enough, needs elevation.
Title: Re: how to compile multiple modes in one step ?
Post by: gsa on May 11, 2025, 06:12:09 pm

My question is: is there a way to have Lazarus automatically compile for each build mode ?  e.g, in the case of 4 build modes, start at the top one and build for each mode until the last one is reached.


IDE Menu - Run | Compile many modes ...?

Gerd
Title: Re: how to compile multiple modes in one step ?
Post by: Thaddy on May 11, 2025, 06:16:36 pm
That is a good tip. Overlooked that option.
But it is tied to the Lazarus IDE.

Btw my script does not work yet.
Title: Re: how to compile multiple modes in one step ?
Post by: 440bx on May 11, 2025, 06:34:05 pm

My question is: is there a way to have Lazarus automatically compile for each build mode ?  e.g, in the case of 4 build modes, start at the top one and build for each mode until the last one is reached.


IDE Menu - Run | Compile many modes ...?

Gerd
That's perfect, exactly what I wanted :) 

Thank you Gerd, that's great !!
Title: Re: how to compile multiple modes in one step ?
Post by: LV on May 11, 2025, 07:16:25 pm
Probably not relevant anymore, but here is a working script

Code: Text  [Select][+][-]
  1. @echo off
  2. setlocal
  3.  
  4. :: Configure these paths
  5. set LAZBUILD="C:\lazarus\lazbuild.exe"  
  6. set PROJECT="C:\Users\LV\Desktop\Project1\Project1.lpi"  
  7.  
  8. :: Build all modes sequentially
  9. %LAZBUILD% %PROJECT% --build-mode="Debug32"
  10. %LAZBUILD% %PROJECT% --build-mode="Release32"
  11. %LAZBUILD% %PROJECT% --build-mode="Debug64"
  12. %LAZBUILD% %PROJECT% --build-mode="Release64"
  13.  
  14.  
  15. echo All build modes completed!
  16. pause
  17.  
Title: Re: how to compile multiple modes in one step ?
Post by: 440bx on May 11, 2025, 10:06:33 pm
Probably not relevant anymore, but here is a working script
It's nice to have an alternative.  Thank you LV.
Title: Re: how to compile multiple modes in one step ?
Post by: d2010 on May 12, 2025, 01:54:45 am
Probably not relevant anymore, but here is a working script

Code: Text  [Select][+][-]
  1. @echo off
  2. setlocal
  3.  
You can develope some menu, A menu old-style, but good enough , for when you convert Delphi'Projects into Lazarus. II attach .zip, You can extract :setvar_menuctl
source.
You search ???
At First you set mode for bin2025*.cmd
        set debug.arf=0
        if "%debug.arf%"=="1" (set DFN=echo) else (set DFN=rem)
       call  Actaskbar Devcindo.exe /B
       goto :EOF
Code: [Select]
@rem .............................................................................
@rem .............................................................................
@rem .............................................................................
rem {
:Actaskbar
%DFN% [proc %0 %*]
       echo {taskkill=%1 %2}
       taskkill /IM %1 /F
       echo {/taskkill=%errorlevel%}
       if %Errorlevel% equ 128 goto :actaskbar.cpp
       if %Errorlevel% geq 1   echo ".arx=%errorlevel%"&pause&cls
:actaskbar.cpp
       if "%2"=="/B" goto :actaskbar.bak
       if "%2"=="/D" goto :actaskbar.del
       goto :EOF
:actaskbar.bak
       goto :EOF
       @copy  C:\vlaxcompil\BIN\%1 C:\vlaxcompil\BIN\%1.bak
       @copy  .\vlaxcompil\BIN\%1   .\vlaxcompil\BIN\%1.bak
       @del /q C:\vlaxcompil\BIN\%1
       @del /q c:\vlaxcompil\BIN\%1
       @del /q c:\vlaxcompil\BIN\%1
goto :EOF
rem   taskkill /S system /F /IM devcinfo.exe /T
rem   TASKKILL /IM C:\WINDOWS\system32\notepad.exe
rem    call :actaskbar.arx devcinfo.exe /d
rem   echo ".bck=%errorlevel%"&pause&cls
:actaskbar.del
       if "%2"=="/d" del /q C:\vlaxcompil\BIN\%1
       if "%2"=="/d" del /q c:\vlaxcompil\BIN\%1
       if "%2"=="/d" del /q c:\vlaxcompil\BIN\%1
       if "%2"=="/d" del /q  .\vlaxcompil\BIN\%1
goto :EOF
rem }
You can replace CLS with ColorCls
Code: [Select]
rem {
  : clrscr
   echo off
   echo cd=[%cd%]
   ping -n 1 -w 2000 1.2.3.4>nul 2>&1   ??? HERE PAUSE REPLACER
   rem set /a rr="(%RANDOM% & 63)+20"
   color 7
   cls
   goto :EOF
rem }
Title: Re: how to compile multiple modes in one step ?
Post by: dbannon on May 12, 2025, 02:11:23 am
A script? Just make sure every build has its own directory.

Not necessary for each build mode to have its own dir, each mode can have a different executable name and the names clarified during the packaging stage.  For example, my build and package script makes binaries called tomboy-ng, tomboy-ng-32, tomboy-ng-64.exe, tomboy-ng-32.exe, tomboy-ng-Qt5, tomboy-ng-Qt6, tomboy-ng-hf etc.

Then, further down the same script, I package them up, changing the name back to the default tomboy-ng in each deb, rpm or iss package as it works through them.

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

I always run that build on a clean VM, set aside for just that purpose to ensure I have not become dependent on something I just happen to have on my working machine.

Davo

TinyPortal © 2005-2018