Boost logo

Boost-Build :

Subject: [Boost-build] how to define a rule that adds two targets
From: Joshua Napoli (jnapoli_at_[hidden])
Date: 2013-09-12 14:02:33


I'm trying to create rules to integrate PC-Lint. I encountered a problem,
where a rule has a different effect depending on whether it is defined in
an application Jamfile, or in a .jam module.

In lint.jam, I have:

type.register LINT : lint ;
generators.register-composing lint.lint : CPP C : LINT ;
rule init (...) { ... }
actions lint
{
    ...
}

In Jamroot, a "using" statement loads and configures lint.jam.

using lint : 9 : lint : lint/std.lnt ;

In the application Jamfile, I have something like this:

exe myprogram : [ glob *.cpp ] ;
lint myprogram.lint : [ glob *.cpp ] ;

To eliminate the redundancy in the Jamfile, I tried defining a rule like
this in the Jamfile:

rule lint-exe ( main-target-name : sources + : requirements * :
default-build * : usage-requirements * )
{
    local lint-target-name = "$(main-target-name).lint" ;
    exe $(main-target-name) : $(sources) : $(requirements) :
$(default-build) : $(usage-requirements) ;
    lint $(lint-target-name) : $(sources) : $(requirements) :
$(default-build) : $(usage-requirements) ;
}

lint-exe myprogram : [ glob *.cpp ] ;

This works. I would like to collect the lintexe helper rule into lint.jam.
When I do so, my application Jamfile ends up looking nicer:

import lint ;

lint.lint-exe myprogram : [ glob *.cpp ] ;

Unfortunately, the behavior has changed. The myprogram "exe" target still
gets built, but not the myprogram.lint target. The lint.lint-exe rule is
clearly being invoked (I double-checked by adding an ECHO statement). The
myprogram EXE target gets recorded properly, but not the myprogram.lint
target.

Does any boost build expert out there have any idea why?

Thanks,
Josh



Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk