Boost logo

Boost-Build :

Subject: Re: [Boost-build] how to define a rule that adds two targets
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2013-09-12 20:47:06


AMDG

On 09/12/2013 11:02 AM, Joshua Napoli wrote:
> 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?
>

It's a scoping problem. "lint" in the lint module
refers to "actions lint," not the global rule that
constructs targets of type LINT.

In Christ,
Steven Watanabe


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