[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
usual.

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"?>
<CONFIG>
  <ProjectOptions>
    <Version Value="9"/>
    <PathDelim Value="\"/>
    <General>
      <Flags>
        <MainUnitHasCreateFormStatements Value="False"/>
        <MainUnitHasTitleStatement Value="False"/>
      </Flags>
      <SessionStorage Value="InProjectDir"/>
      <MainUnit Value="0"/>
      <Title Value="project1"/>
      <UseAppBundle Value="False"/>
      <ResourceType Value="res"/>
    </General>
    <i18n>
      <EnableI18N LFM="False"/>
    </i18n>
    <VersionInfo>
      <StringTable ProductVersion=""/>
    </VersionInfo>
    <BuildModes Count="1">
      <Item1 Name="Default" Default="True"/>
    </BuildModes>
    <PublishOptions>
      <Version Value="2"/>
      <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
      <ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
    </PublishOptions>
    <RunParams>
      <local>
        <FormatVersion Value="1"/>
      </local>
    </RunParams>
    <Units Count="1">
      <Unit0>
        <Filename Value="project1.lpr"/>
        <IsPartOfProject Value="True"/>
        <UnitName Value="project1"/>
      </Unit0>
    </Units>
  </ProjectOptions>
  <CompilerOptions>
    <Version Value="11"/>
    <PathDelim Value="\"/>
    <SearchPaths>
      <IncludeFiles Value="$(ProjOutDir)"/>
    </SearchPaths>
    <Other>
      <CompilerMessages>
        <UseMsgFile Value="True"/>
      </CompilerMessages>
      <CompilerPath Value="$(CompPath)"/>
    </Other>
  </CompilerOptions>
  <Debugging>
    <Exceptions Count="3">
      <Item1>
        <Name Value="EAbort"/>
      </Item1>
      <Item2>
        <Name Value="ECodetoolError"/>
      </Item2>
      <Item3>
        <Name Value="EFOpenError"/>
      </Item3>
    </Exceptions>
  </Debugging>
</CONFIG>





More information about the Lazarus mailing list