Boost logo

Boost-Build :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-02-20 02:38:57


"klapshin wrote:

> I am trying to apply V2 to my project and got couple of stupid newbie
> questions. Pointing to the right place in FM is appreciated.

Hi Kirill,

> First of all what would be the best place to specify custom rules,
> i.e. instead of Jamrules?

Depends. It's assumed that all project-wide customization happens in
"project-root.jam". Note however, that plain Jam rules declared there
won't be visible to other modules, unless you IMPORT them to the global
module, like this

rule a ( ) { }
IMPORT $(__name__) : a : : a ;

Here, '__name__' is the name of current module.

> For instance I have couple of scripts generating C-code, and some
> projects have to run them on source file and compile result
> afterwards.

This resembles very much what I need. In my settings, project-root.jam
contains:

path-constant UTILS_DIR : utils ;

and certain Jamfile two levels below has:

rule generate-strings ( variable-name targets * : sources * : * )
{
VARIABLE_NAME on $(<) = $(variable-name) ;
generate-strings2 $(targets) : $(sources) ;
}

actions generate-strings2
{
$(UTILS_DIR)/inline_file.py $(<) $(>) $(VARIABLE_NAME)
}

make host_markers.cpp : host_markers.verbatim
: generate-strings host_machine_markers ;

The last line specifies that target file should be produces from
source file and rule 'generate-string' must be called with additional
argument 'host_machine_markers'.

Of course, the generated file can be used:

exe cpp_mark
: cpp_mark.cpp generate_markup.cpp host_markers.cpp
cpp_lite ../i18n ../common @/boost/filesystem/fs
;

Putting those rules can be put to project-root.jam and then
importing generate-string to global module will enable this
functionality for the entire project.

Note that this particular syntax works only with up-to-date CVS
state: I had variable name hardcoded and just comitted a fix
which allows to specify it.

> Secondly, what is the right way to figure out path from current folder
> to project folder?
>
>
> I need it to resolve the problem that
> exe test : [ GLOB . : *.cpp ] ;
> works only if bjam is invoked from that project, if it invoked from
> root, then globbing fails. I tried to play with project.attribute but
> can't make it work.

The following works for me:

import project ;

exe a : [ GLOB [ project.attribute $(__name__) location ] : *.cpp ] ;

HTH,
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