Recent

Author Topic: Automatize build system  (Read 2295 times)

Чебурашка

  • Hero Member
  • *****
  • Posts: 586
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Automatize build system
« on: December 06, 2023, 12:20:44 pm »
Hello,
I have several projects made with Lazarus, and in this moment I use lazbuild embedded in .sh scripts in order to have a always repeatable build process to rebuild them all.
Lazbuild is great because I can add in the lpi build modes, hooks and many other nice features that work very well, and of course it is capable of reading .lpi like if I was inside Lazarus IDE.
The problem with lazbuild is that is designed to work for the Lazarus ide, so it adds compiler options useful to Lazarus, but that make the build process output too verbose.

What is a possible alternative tool for the scripted building, if possible capable of operation on the lpi files?
« Last Edit: December 06, 2023, 12:27:58 pm by Чебурашка »
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

CharlyTango

  • Jr. Member
  • **
  • Posts: 90
Re: Automatize build system
« Reply #1 on: December 07, 2023, 10:15:38 am »
the component LazProjectGroups in folder \lazarus\components\projectgroups could be a solution.
Combine different projects to a project group and compile them all with a single mouseclick
Lazarus stable, Win32/64

Чебурашка

  • Hero Member
  • *****
  • Posts: 586
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: Automatize build system
« Reply #2 on: December 07, 2023, 10:34:42 am »
the component LazProjectGroups in folder \lazarus\components\projectgroups could be a solution.
Combine different projects to a project group and compile them all with a single mouseclick

Thank vm for the suggestion.

As explained I am looking for a tool that allows me to call the compilation from command line (then embedded in sh scripts), that gives an output controlled by the fcp.cfg instad of adding extra information needed by Lazarus, like lazbuild does. Ideally, like lazbuild does, this tool should be able to use the lpis as input, because in lpis user is allowed to indicate amazing settings, on a project basis:

  • build modes
  • search paths
  • output directories
  • hooked events
  • custom options
  • custom defines
  • other amazing features

The tool that you suggest seems to me an aggregator of lpis, I guess it will operate using lazbuild, with the same output of lazbuild. So probably is not what I am looking for.
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

Thaddy

  • Hero Member
  • *****
  • Posts: 16154
  • Censorship about opinions does not belong here.
Re: Automatize build system
« Reply #3 on: December 07, 2023, 11:38:52 am »
Nobody would use the lpi files in a professional setting especially when using it in a team just like you should not use sourcecode contamination with the % macro´ s that Lazarus uses.
There are some solutions that I prefer, but takes a bit of work.
1. On Windows use msbuild
2. Take the luxury of writing a proper make file, like FPC does for its own builds. Once you put the time in once it frees up much valuable time later.

I personally dislike the lpi files since it is tied to the Lazarus IDE. It should be the case that the lpr files are governing.
My usual setup compiles from different editors, like Geany, that do not need lpi files, just a good setup.
Feel free to disagree. This is opinion, not fact.
« Last Edit: December 07, 2023, 11:47:38 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

Чебурашка

  • Hero Member
  • *****
  • Posts: 586
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: Automatize build system
« Reply #4 on: December 07, 2023, 12:00:41 pm »
Nobody would use the lpi files in a professional setting especially when using it in a team just like you should not use sourcecode contamination with the % macro´ s that Lazarus uses.
There are some solutions that I prefer, but takes a bit of work.
1. On Windows use msbuild
2. Take the luxury of writing a proper make file, like FPC does for its own builds. Once you put the time in once it frees up much valuable time later.

I personally dislike the lpi files since it is tied to the Lazarus IDE. It should be the case that the lpr files are governing.
My usual setup compiles from different editors, like Geany, that do not need lpi files, just a good setup.
Feel free to disagree. This is opinion, not fact.

Thanks Thaddy.
I was thinking that probably my needs could be best satisfied using some kind of make system rather than anything else. Your observation seems to confirm quite well what I was suspecting.
I asked in the forums because I was thinking that someone could suggest some existing tool that I don't know.
« Last Edit: December 07, 2023, 12:25:07 pm by Чебурашка »
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

Thaddy

  • Hero Member
  • *****
  • Posts: 16154
  • Censorship about opinions does not belong here.
Re: Automatize build system
« Reply #5 on: December 08, 2023, 11:08:49 am »
There is of course fpcmake to generate GNU make files in a slightly less cumbersome way but there is no graphical user interface for it afaik.
That would be a good idea for a project.
There is also fpmake which is heavily used by FPC itself and has a more comprehensible syntax, but also lacks a graphical user interface.
fpmake is well documented, though, and should be easy to get to grips with.

Then again, I often use shellscripts and batch files....
« Last Edit: December 08, 2023, 11:19:04 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

MarkMLl

  • Hero Member
  • *****
  • Posts: 8012
Re: Automatize build system
« Reply #6 on: December 08, 2023, 12:26:22 pm »
fpmake is well documented, though, and should be easy to get to grips with.

Where? There's no mention of it on https://www.freepascal.org/docs.html or on the tools page, and https://wiki.freepascal.org/FPMake is enough to send somebody used to standard tools away screaming.

If putting something on Github that might possibly be of interest to non-FPC users such as https://github.com/MarkMLl/Contec_cms50dplus I try to take the time to write a standard makefile. That's particularly the case if it can be compiled as either a console-only or dual-mode program, where it is relatively safe to assume that a user has (or is prepared to install) FPC but not necessarily safe to assume that he has (or can work out) Lazarus.

For my/our own stuff, the Lazarus build system possibly augmented by project groups works well. But I'm not sure the project groups addon installs itself into Lazbuild.

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

Чебурашка

  • Hero Member
  • *****
  • Posts: 586
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: Automatize build system
« Reply #7 on: December 08, 2023, 02:17:43 pm »
Then again, I often use shellscripts and batch files....

After ur first answer I spent couple of hours to write a makefile.

Then I realized that I was kinda wasting time, and in about 20 min I setup a decent set of shell scripts that serve more or less all what I need so far.

The only thing I felt missing of fpc is the possibility of supplying a specific fpc.cfg from command line, as he takes one in /etc, one somewhere in /usr and one in the home. Imho should be good to supply one as command line param, to get something project based.

For the rest sh is more that enough to me.
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

TRon

  • Hero Member
  • *****
  • Posts: 3623
Re: Automatize build system
« Reply #8 on: December 08, 2023, 06:01:10 pm »
The only thing I felt missing of fpc is the possibility of supplying a specific fpc.cfg from command line, as he takes one in /etc, one somewhere in /usr and one in the home. Imho should be good to supply one as command line param, to get something project based.
You already can by using @. Use in combination with option -n to ignore default options files. See https://www.freepascal.org/docs-html/user/userap1.html
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

Чебурашка

  • Hero Member
  • *****
  • Posts: 586
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: Automatize build system
« Reply #9 on: December 08, 2023, 06:13:21 pm »
The only thing I felt missing of fpc is the possibility of supplying a specific fpc.cfg from command line, as he takes one in /etc, one somewhere in /usr and one in the home. Imho should be good to supply one as command line param, to get something project based.
You already can by using @. Use in combination with option -n to ignore default options files. See https://www.freepascal.org/docs-html/user/userap1.html

Thank you VM, I will use this for sure! I did not find mention to it in the debian man page, maybe I did not check good enough
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

TRon

  • Hero Member
  • *****
  • Posts: 3623
Re: Automatize build system
« Reply #10 on: December 08, 2023, 06:22:36 pm »
Thank you VM, I will use this for sure! I did not find mention to it in the debian man page, maybe I did not check good enough
YMTW.

If you want to get "fancy", create a script or link that includes the -n and @ options and name it whatever you want, f.e. myfpcbuild and you have your custom FPC using it's own (hardcoded) .cfg setup and you never have to supply the options manually (again).
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

Чебурашка

  • Hero Member
  • *****
  • Posts: 586
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: Automatize build system
« Reply #11 on: December 09, 2023, 01:15:45 am »
You already can by using @. Use in combination with option -n to ignore default options files. See https://www.freepascal.org/docs-html/user/userap1.html

I see that the user guide says in

 https://www.freepascal.org/docs-html/current/user/usersu10.html#x24-310003.1.5

Quote
Unless you specify the -n (see page 104) option, the compiler will look for a configuration file fpc.cfg in the following places:

    Under unix (such as linux)
        1. The current directory.
        2. Your home directory, it looks for .fpc.cfg.
        3. The directory specified in the environment variable PPC_CONFIG_PATH.
        4. in the etc directory above the compiler directory.
          For instance, if the compiler is in /usr/local/bin, it will look in /usr/local/etc.
          See below for some additional information about this point.
        5. The directory /etc.

I just need to place a fpc.cfg in the directory where the script is located and ran...

 :D
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

TRon

  • Hero Member
  • *****
  • Posts: 3623
Re: Automatize build system
« Reply #12 on: December 09, 2023, 12:17:04 pm »
I just need to place a fpc.cfg in the directory where the script is located and ran...
Yes, that is indeed also possible and perhaps easier for your use case  :)

Not knowing your setup or setup that you wish to have I assumed you were looking for a more generic solution. I never let FPC decide which configuration file to load because you never know on which exact location it will load from (because it depends on the rules as quoted) so I personally always use -n and @ to make sure the correct configuration file is used and as such is a tremendous help in case you have multiple FPC and lazarus versions installed and/or are using (several) custom build scripts.
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

 

TinyPortal © 2005-2018