[Lazarus] Compiling LCL units via commandline

Reinier Olislagers reinierolislagers at gmail.com
Wed Jul 25 16:23:38 CEST 2012

On 25-7-2012 15:57, Mattias Gaertner wrote:
> On Wed, 25 Jul 2012 13:26:01 +0200
> Reinier Olislagers <reinierolislagers at gmail.com> wrote:
>> Probably because your fpc.cfg is processed by lazbuild as well..
> lazbuild does not read fpc.cfg, but it calls the compiler which reads
> it.
Sorry, yes, that's what I meant.

>> Perhaps it's a good idea to change lazbuild to use a switch (e.g.
>> --quiet or -q) to output less details?
> I guess a simply flag is not sufficient. See the many verbosity flags
> in the IDE. They were all added on users demand.
True. First user demand for lazbuild though :)

Perhaps we could just pass on -v (and --verbose=) flags to fpc unless no
-v flags specified and then use current behaviour?
Then we can use -v0 (show nothing except errors) to make lazbuild quieter.

>> Also, it may be possible to adapt lazbuild to be able to compile your
>> example program (and similar programs) without need for creating an .lpi
>> or .lpr file.
> Some people suggests to use compiler and IDE directives in the lpr
> file, which the IDE and lazbuild can use if no lpi is present.
Mmm yes, if we do that we could also move all lpi data into the lpr anyway?

Have just created a simple console project (see below).
I suppose lazbuild could perhaps use code from the IDE to create a new
blank Program type project, change ProjectOptions & CompilerOptions
PathDelim, Title, Unit0 Filename and UnitName, and then save it with the
same filename as the .pas file but with .lpi extension, and build it as

Of course, we're in trouble if we specify non-res resources or do more
complicated stuff.

Perhaps something like this is best left to a wrapper program?

<?xml version="1.0"?>
    <Version Value="9"/>
    <PathDelim Value="\"/>
        <MainUnitHasCreateFormStatements Value="False"/>
        <MainUnitHasTitleStatement Value="False"/>
      <SessionStorage Value="InProjectDir"/>
      <MainUnit Value="0"/>
      <Title Value="project1"/>
      <UseAppBundle Value="False"/>
      <ResourceType Value="res"/>
      <EnableI18N LFM="False"/>
      <StringTable ProductVersion=""/>
    <BuildModes Count="1">
      <Item1 Name="Default" Default="True"/>
      <Version Value="2"/>
      <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
      <ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
        <FormatVersion Value="1"/>
    <Units Count="1">
        <Filename Value="project1.lpr"/>
        <IsPartOfProject Value="True"/>
        <UnitName Value="project1"/>
    <Version Value="11"/>
    <PathDelim Value="\"/>
      <IncludeFiles Value="$(ProjOutDir)"/>
        <UseMsgFile Value="True"/>
      <CompilerPath Value="$(CompPath)"/>
    <Exceptions Count="3">
        <Name Value="EAbort"/>
        <Name Value="ECodetoolError"/>
        <Name Value="EFOpenError"/>

More information about the Lazarus mailing list