Boost logo

Boost-Build :

Subject: Re: [Boost-build] make rule with extra variables + figuring out the full target path
From: Vladimir Prus (ghost_at_[hidden])
Date: 2010-02-08 17:07:54


On Friday 05 February 2010 00:44:50 Fadi Beyrouti wrote:

> Hello,
>
> I am using the make rule in the following fashion:
>
> make my_target_file :
> my_source_file :
> @my_action :
> <location>"dir1/dir2/dir3" ;
>
> actions my_action
> {
> my_command "$(>)" "$(<)"
> }
>
> However, I would like to introduce an extra variable to include in the command.
> For example:
>
> actions my_action
> {
> my_command "$(>)" "$(<)" $(EXTRA_VAR)
> }
>
> In order to do that I thought of doing the following after the make statement:
>
> $(EXTRA_VAR) on my_target_file = "SOME VALUE" ;

Let me first explain why this is not working. First, you have a mechanical error.
The thing before "on" should be a variable name. $(EXTRA_VAR) returns a variable
value -- empty at this point. Second, my_target_file would be OK in pure classic
Jam. In Boost.Build, the target passed to 'my_action' has additional decoration
to include the target path, build properties and other things, so it's not just
'my_target_file'.

>
> however, this is not working since I am not able to retrieve the correct path of
> my_target_file. My questions are:
>
> 1. Is there a way to get that path?
> 2. Is there a better/cleaner way of doing what I want to do?

Does it work if you add

        constant EXTRA_VAR : SOME_VALUE ;

somewhere in your Jamfile? In fact, even

        EXTRA_VAR = SOME_VALUE ;

will work, but 'constant' are inherited by child Jamfiles, so is better.

- Volodya


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