Automatize build system lazarus / 62-General ---------------------------------------------------------------------- Чебурашка · 2023-12-06 11:20 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? ---------------------------------------------------------------------- CharlyTango · 2023-12-07 09:15 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 ---------------------------------------------------------------------- Чебурашка · 2023-12-07 09:34 Quote from: CharlyTango on December 07, 2023, 10:15:38 amthe 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 modessearch pathsoutput directorieshooked eventscustom optionscustom definesother 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. ---------------------------------------------------------------------- Thaddy · 2023-12-07 10:38 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. ---------------------------------------------------------------------- Чебурашка · 2023-12-07 11:00 Quote from: Thaddy on December 07, 2023, 11:38:52 amNobody 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. ---------------------------------------------------------------------- Thaddy · 2023-12-08 10:08 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.... ---------------------------------------------------------------------- MarkMLl · 2023-12-08 11:26 Quote from: Thaddy on December 08, 2023, 11:08:49 amfpmake 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 ---------------------------------------------------------------------- Чебурашка · 2023-12-08 13:17 Quote from: Thaddy on December 08, 2023, 11:08:49 amThen 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. ---------------------------------------------------------------------- TRon · 2023-12-08 17:01 Quote from: Чебурашка on December 08, 2023, 02:17:43 pmThe 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 ---------------------------------------------------------------------- Чебурашка · 2023-12-08 17:13 Quote from: TRon on December 08, 2023, 06:01:10 pmQuote from: Чебурашка on December 08, 2023, 02:17:43 pmThe 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 ---------------------------------------------------------------------- TRon · 2023-12-08 17:22 Quote from: Чебурашка on December 08, 2023, 06:13:21 pmThank 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). ---------------------------------------------------------------------- Чебурашка · 2023-12-09 00:15 Quote from: TRon on December 08, 2023, 06:01:10 pmYou 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 QuoteUnless 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... ---------------------------------------------------------------------- TRon · 2023-12-09 11:17 Quote from: Чебурашка on December 09, 2023, 01:15:45 amI 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.