On 04.02.2014 17:07, A. Schamp wrote:Hi Andrew,
We are using Boost.Build to build our software for two platforms, Linux x86 (32-bit) and PPC (32-bit). We have a cross compiler set up for
our PPC build, and so run both builds on our x86 platform using different toolset= declarations. Additionally, for our PPC build, we specify
architecture=power.
This works great for building our software, but we also have a suite of unit tests that are part of our main target, which we want to
execute automatically on native platforms.
We have some wrappers set up, they look like this (but they don't quite work):
feature.feature test-output : user report : incidental optional ;
# a helper rule to wrap the build stuff common to all boost.test test cases
rule run-test ( target : source : requirements * : properties * )
{
if <toolset>gcc-ppc
{
link $(source) boost_unit_test_framework $(requirements) : <define>BOOST_TEST_NO_MAIN <define>BOOST_TEST_MODULE=$(source:B) : $(target) ;
}
else
{
run $(source) boost_unit_test_framework $(requirements) : $(properties) : : <define>BOOST_TEST_NO_MAIN
<define>BOOST_TEST_MODULE=$(source:B) : $(target) : ;
}
}
I am attaching a example, somewhat simplified from what you have, that should do the trick. When I run it with
b2 toolset=gcc target-os=linux
the test is linked and run. When I do
b2 toolset=gcc target-os=window
It is just linked.
Let me explain what I did. Both the 'link' and 'run' functions create metatargets, which are then generated with specific
properties to create targets. When Jamfiles are read, and metatargets are created by run-test rule above, we don't know
what properties will be used to generate them, so that condition above won't work. We need to have conditional code
executed as part of generating targets from a metatarget.
I did that by creating new target type, and creating a generator for that type which recurses using either RUN or EXE
type. I've used the example/generator as base for this experiment.
Let me know if this helps?
- Volodya
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build