how to branch behaviour procedurally based on feature

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

how to branch behaviour procedurally based on feature

Matthew Herrmann-2
Hi,

I'm trying to detect in a rule definition whether or not the current target is
being built as variant=debug or variant=release. I know about conditional
properties, but they won't assist here, as I don't simply want to supply
different parameters to the compiler, I want to branch the whole behaviour.

I've tried simply reading _any_ feature specified at the command line into a
variable, and can't seem to do so:

Running the attached test.jam module from the command-line with

    bjam thing=hello

I'd expect to see hello assigned to thing, but isn't happening. This must be
something simple.

Thanks,
Matthew

-----------------------------------
# Contents of test.jam

import feature ;
import toolset ;
feature.feature thing : : free ;
toolset.flags test.test THING : <thing> ;

rule test ( )
{
        ECHO $(THING) ;
}


_______________________________________________
Boost-build mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: how to branch behaviour procedurally based on feature

Vladimir Prus
Hi Matthew,

> I'm trying to detect in a rule definition whether or not the current target
> is being built as variant=debug or variant=release. I know about
> conditional properties, but they won't assist here, as I don't simply want
> to supply different parameters to the compiler, I want to branch the whole
> behaviour.

Can you describe what you're trying to do in more detail? In general, by the
time a target is defined in Jamfile, you can't get current build properties,
because there are none. Each target defined in Jamfile can be build with 10
different properties set, and when you just define a target, it's not clear
which one of those 10 property sets you want.

> I've tried simply reading _any_ feature specified at the command line into
> a variable, and can't seem to do so:
>
> Running the attached test.jam module from the command-line with
>
>     bjam thing=hello

How did you run "test.jam"? The above comamnd line won't work unless you have
"Jamroot" file in the current directory (or "project-root.jam", for older V2).

> I'd expect to see hello assigned to thing, but isn't happening. This must
> be something simple.

That assignment will only happen when actual build commands are generated, and
only for file targets that are build with "test.test" action. Maybe you can
provide the complete test case you have?

- Volodya

_______________________________________________
Boost-build mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-build