Recent

Author Topic: Building a package with just FPC  (Read 4154 times)

dbannon

  • Hero Member
  • *****
  • Posts: 2792
    • tomboy-ng, a rewrite of the classic Tomboy
Building a package with just FPC
« on: August 16, 2020, 02:38:14 am »
I have a build process that uses lazbuild to build a package (kcontrols) that I require before building the main app with a direct fpc command line.

It would be nice to also build the package with fpc, that would simplify my build dependencies and as its done on Ubuntu's PPA servers, any simplification is a good thing.  I looked through the .lpk files and see a lot of xml, thats not going to help.  I obviously don't need to install the package into an IDE, just get it ready to be used in a compile.

I am assuming I would need to do more than just iterating over all the .pas files and generating .o ??

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

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Building a package with just FPC
« Reply #1 on: August 16, 2020, 01:24:05 pm »
Open the package->Options->Show Options, that's your fpc parameters. Do note that it expands the macros which might refer to some relative path like Lazarus components directory or something so take that into account.

dbannon

  • Hero Member
  • *****
  • Posts: 2792
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Building a package with just FPC
« Reply #2 on: August 17, 2020, 09:06:14 am »
Hmm, thanks Leledumbo, I am not sure I quite understand however.

When I build my project using fpc, I use the parameters from the projects "Show Options" button and follow that up with the name of the project :

Code: [Select]
fpc  [parameters]   Tomboy_NG.lpr [enter]
However, the package I am looking at does not have a project file, that is, one with an extension of "lpr".  Maybe it should have ??  Maybe the .lpk file is the one to use ?   Else how can I indicate to fpc just what needs to be compiled ?

In the Lazarus IDE I have opened one of the units in the package concerned in the Source Editor, then, top menu, 'Package' -> 'Open Package of Current Unit' -> New form opens, select the unit [../../source/kmemo.pas] I click 'Options' and then 'Show Options' - it does indeed show all the parameters except the last one ??

Thanks again !

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

PascalDragon

  • Hero Member
  • *****
  • Posts: 5469
  • Compiler Developer
Re: Building a package with just FPC
« Reply #3 on: August 17, 2020, 09:13:56 am »
Code: [Select]
fpc  [parameters]   Tomboy_NG.lpr [enter]
However, the package I am looking at does not have a project file, that is, one with an extension of "lpr".  Maybe it should have ??  Maybe the .lpk file is the one to use ?   Else how can I indicate to fpc just what needs to be compiled ?

There should be a pas file with the same name as the lpk file next to it. Pass that to the compiler, that is essentially the “build unit” that Lazarus uses for building the package as well.

dbannon

  • Hero Member
  • *****
  • Posts: 2792
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Building a package with just FPC
« Reply #4 on: August 18, 2020, 03:49:26 am »
> There should be a pas file with the same name as the lpk file next to it.

Thanks PascalDragon, but no, that does not seem to be the case.

kcontrols has a /package/kcontrols directory, it has mostly Delphi files, the only files relevant (IMHO) to Lazarus are -
kcontrolsbase.lpk
kcontrolsdesign.lrs
kcontrolslaz.lpk
kcontrols.lrs

kcontrolsdesign.pas
kpictureeditor.pas

As you can guess, when installing in the package in the ide, we install kcontrols and kcontrolsbase gets pulled in. 

Up 2 directories we have a /source and there is a kcontrols.pas file there (but no kcontrolsbase.pas) but kcontrols.pas appears like a normal source file rather than a central "catch them all" one.  But maybe I should point fpc at that and see what gets built ?

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

PascalDragon

  • Hero Member
  • *****
  • Posts: 5469
  • Compiler Developer
Re: Building a package with just FPC
« Reply #5 on: August 18, 2020, 09:18:50 am »
Up 2 directories we have a /source and there is a kcontrols.pas file there (but no kcontrolsbase.pas) but kcontrols.pas appears like a normal source file rather than a central "catch them all" one.  But maybe I should point fpc at that and see what gets built ?

I took a quick look now and it seems that you'll have to introduce a "catch all" unit yourself.

dbannon

  • Hero Member
  • *****
  • Posts: 2792
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Building a package with just FPC
« Reply #6 on: August 19, 2020, 06:17:17 am »
OK, and that would be just a compile of each unit ?   

Should be pretty easy.   Will the compiler follow a use clause ?  I mean that if Unit B is 'used' by Unit A, do I manually compile only Unit A and let the compiler sort it ?

Thanks,
 
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

PascalDragon

  • Hero Member
  • *****
  • Posts: 5469
  • Compiler Developer
Re: Building a package with just FPC
« Reply #7 on: August 19, 2020, 09:14:46 am »
Yes, you essentially need a unit like this (the settings used for this unit like mode or long strings are completely irrelevant):

Code: Pascal  [Select][+][-]
  1. unit KControlsAll;
  2.  
  3. interface
  4.  
  5. uses
  6.   KUnitA,
  7.   KUnitB,
  8.   KUnitC { etc. };
  9.  
  10. implementation
  11.  
  12. end.

Should there be any units of the KControls package that are not mentioned in this catch all unit, but used indirectly those will be compiled as well. This is essentially what Lazarus packages do by default and is for example done by fpmake as well if the option to use a build unit is passed.

dbannon

  • Hero Member
  • *****
  • Posts: 2792
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Building a package with just FPC
« Reply #8 on: August 23, 2020, 06:10:32 am »
Yep, that works perfectly pascaldragon, thanks !

Anyone watching from home :
All I did was create a directory $TARGET in the kcontrols/source dir, build a command line for fpc, using the parameters from the package options and pointed it to kmemo.pas, kmemo being the only component in the KControls suite that I needed.

I could then use those units in the next compile by adding -Fu <that Target dir> and it works perfectly. One less dependency in my build scripts !

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

 

TinyPortal © 2005-2018