Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2016-02

Lazbuild: calling of ExecuteBefore command with up-to-date project

3 messages · 1 person · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martok

Hi list,

(this is a repost from the forums, on suggestion of GetMem)

As I've recently worked to automate more of my project builds/release cycles, I've found a few inconsistencies between building via Lazbuild and Lazarus. Version increment handling is already being discussed on the forums. However, the most annoying for my build process is the handling of CompilerOptions.ExecuteBefore commands in projects that have no unmodified files. If building via the IDE, the "before" command is always executed, even if no source is modified. Building via lazbuild exits without executing the command:

Hint: (lazarus) Build Project: nothing to do. Hint: (lazarus) [TLazBuildApplication.BuildProject]

MainBuildBoss.DoCheckIfProjectNeedsCompilation nothing to do

This is a problem if the Pre-Build command modifies a file that would trigger compilation of just that file and relinking of the binary. My usecase here is an auto-generated git revision include file.

Lazbuild checking starts at ide/lazbuild.lpr:848, Lazarus is in ide/main.pp:6570. The only real difference I can see is that Lazarus has a pbfOnlyIfNeeded flag, and Lazbuild has the opposite as the BuildAll parameter, but the result is very different. Can someone explain where this difference comes from?

Regards,
Martok

Reply by email

Martok
to Martok

After some investigation, I noticed that there even is an option for that, but it is not actually checked in the proper place.

(These are the defaults so they wouldn't normally be written to the project file) <ExecuteBefore>
<Command Value="echo test"/>
<CompileReasons Compile="True" Build="True" Run="True"/> </ExecuteBefore>

So, a build tool is by default defined to be executed for all compile events as well as "Run" events. In my opinion, this means that it should also be executed for lazbuild runs that do not result in a build - they should be treated as crCompile. If Lazbuild was invoked with -B, that should be a crBuild reason. However, in the IDE (TMainIDE.DoBuildProject) crBuild only means "Rebuild" if pbfCleanCompile is given as well, there is no difference between crBuild and crCompile other than tool enable/disable flags. For me, crBuild=pbfCleanCompile and crRun=pbfOnlyIfNeeded, so these separate flags seem superfluous?

The intended behaviour for the IDE is documented in the wiki at <http://wiki.lazarus.freepascal.org/IDE_Window:_Project_Options#Execute_before> Note the definition for "Run" - this is currently not true, and technically the current LazBuild behaviour is more like "Run" than "Compile" since it skips building completely if not needed, while crCompile should at least compile the main file and relink.

This is confusing.
The only thing I'm sure about is that tool invocation needs to be moved *before* the check weather any compiler action is needed. On a side note, I've checked with Delphi's MSBuild configuration, and for them, Pre-Build commands are also independent of whether the compiler actually does something.

There is a lot of redundancy in this, but before I start working on it, I'd rather have some info on what the intention was behind the current structure.

Regards,

Sebastian

Reply by email

Martok
to Martok

Patch series now in the bugtracker as issue #29773 (and a related on on #27820).

I have thoroughly tested it and it now does exactly what the documentation says, but please verify.

Kind Regards,

Sebastian

Reply by email