Attaching a Jam target to the Boost Build Clean rule

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Attaching a Jam target to the Boost Build Clean rule

Boost - Build mailing list

Hello,


I have user-defined meta-target rule invocations in my Jamfiles that should only execute when option --clean is provided to the Boost b2 executable. What is the easiest way to have this happen?


Here is an some example Jamfile.file input:


mytest-clean test-01.clean

    : test-01.out

;

explicit test-01.clean ;



mytest-clean is a user-defined rule that I want invoked when the user specifies --clean on the b2 command line. Note that test-01 is a target name that is created by another user-defined generator.


Many thanks and with regards,


DougC



_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Attaching a Jam target to the Boost Build Clean rule

Boost - Build mailing list
AMDG

On 12/26/2017 07:35 PM, Capeci, Doug via Boost-build wrote:
>
> I have user-defined meta-target rule invocations in my Jamfiles that should only execute when option --clean is provided to the Boost b2 executable. What is the easiest way to have this happen?
>

  There's no good way to do this.  The --clean option
does not provide any hook to specify how a target
gets cleaned.  I'm not sure why you would need clean
to do anything other than rm all the targets that
exist, anyway.

  You can make it work for --clean-all, by adjusting
the generator for test-01, to add
DEPENDS clean-all : test-01.clean ;
(Note: I'm assuming that test-01.clean is a
jam level target here, not a metatarget.)

  It's tricky to make this work for clean, because
clean allows you to select specific targets to
clean, instead of just deleting everything that
is reachable.

>
> Here is an some example Jamfile.file input:
>
>
> mytest-clean test-01.clean
>
>     : test-01.out
>
> ;
>
> explicit test-01.clean ;
>
>
>
> mytest-clean is a user-defined rule that I want invoked when the user specifies --clean on the b2 command line. Note that test-01 is a target name that is created by another user-defined generator.
>

In Christ,
Steven Watanabe
_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Attaching a Jam target to the Boost Build Clean rule

Boost - Build mailing list
After some experimentation, I have found an acceptable solution. The trick is to have the clean rule associated with the meta target probe the global ARGV variable that is associated with the Boost command line for the presence of options --clean or --clean-all to determine that the user is explicitly requesting a clean. If either option is found, the clean rule removes the files that it is responsible for.

The reason why this is useful is that we have integrated other tools in the overall tool chain that have their own user-defined meta targets. These tools produce output files that we would like to have removed when the user explicitly requests a clean on the Boost b2 command line.

Many thanks and with regards,

DougC

________________________________________
From: Boost-build <[hidden email]> on behalf of Steven Watanabe via Boost-build <[hidden email]>
Sent: Tuesday, December 26, 2017 10:36 PM
To: Capeci, Doug via Boost-build
Cc: Steven Watanabe
Subject: Re: [Boost-build] Attaching a Jam target to the Boost Build Clean rule

AMDG

On 12/26/2017 07:35 PM, Capeci, Doug via Boost-build wrote:
>
> I have user-defined meta-target rule invocations in my Jamfiles that should only execute when option --clean is provided to the Boost b2 executable. What is the easiest way to have this happen?
>

  There's no good way to do this.  The --clean option
does not provide any hook to specify how a target
gets cleaned.  I'm not sure why you would need clean
to do anything other than rm all the targets that
exist, anyway.

  You can make it work for --clean-all, by adjusting
the generator for test-01, to add
DEPENDS clean-all : test-01.clean ;
(Note: I'm assuming that test-01.clean is a
jam level target here, not a metatarget.)

  It's tricky to make this work for clean, because
clean allows you to select specific targets to
clean, instead of just deleting everything that
is reachable.

>
> Here is an some example Jamfile.file input:
>
>
> mytest-clean test-01.clean
>
>     : test-01.out
>
> ;
>
> explicit test-01.clean ;
>
>
>
> mytest-clean is a user-defined rule that I want invoked when the user specifies --clean on the b2 command line. Note that test-01 is a target name that is created by another user-defined generator.
>

In Christ,
Steven Watanabe
_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build