Boost logo

Boost-Build :

From: Jaroslav Gresula (jgresula.LEAVE-THIS-OUT_at_[hidden])
Date: 2008-01-05 14:11:59


K. Noel Belcourt wrote:
> On Jan 4, 2008, at 5:19 PM, Jaroslav Gresula wrote:
>> "K. Noel Belcourt" wrote:
>>> On Jan 4, 2008, at 4:38 PM, Jaroslav Gresula wrote:
>>>> is there a way a .jam file can find out its path?
>>>
>>> I wrote a small utility to do this, but it's not currently in the
>>> trunk. I've attempted to extract enough of it here to get you
>>> working. Here's what you do:
>>>
>>> (1) In the Jamfile whose path you want to know, create a local
>>> variable and call the path-relative-to rule.
>>>
>>> local path-to-jamfile = [ path-relative-to ] ;
>>>
>>> This will return the path to this Jamfile from the Jamroot (that's
>>> why it's a relative path).
>>>
>>> Next you need to add the code in the attached file to boost/tools/
>>> build/v2/build/project.jam around line 930 or so.
>>
>> Hi Noel,
>>
>> after fixing a minor typo in the attached code I'm getting
>>
>> rule path.find-directory-containing unknown in module jag_swig
>>
>> and really there is no such rule in path.jam.
>
> Oops, forgot to send you the path.jam rule for find-directory-
> containing.
>
>> Do you think that this mechanism is going to work even for a .jam file
>> (i.e. a utility file that is not a project) that has no parent
>> Jamroot?
>
> Good question, I'm not sure. Perhaps Volodya or Rene knows of a
> better approach.

Thanks anyway. Maybe if I describe my use case then someone could get
an idea working around the need of the .jam path.

I have a generator that invokes a 3rd party tool that produces a .cpp
file. I need to append several lines to the end of the .cpp file. My
idea is to put that lines to a separate file which resides in the same
directory as the .jam file containing the generator and append it in the
action body:

MY_DIR = [ get-directory-of-this-jam-file-somehow ] ;
MY_FILE = [ path.join $(MY_DIR) lines_to_append ] ;

action generator
{
  generate_cpp $(>) $(<)
  cat $(MY_FILE) >> $(<)
}

Thanks,

-- 
Jarda

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