Boost logo

Boost-Build :

From: David Abrahams (dave_at_[hidden])
Date: 2002-12-03 08:47:55

Anthony Roach <aroach_at_[hidden]> writes:

> Are you saying that the user can build with both msvc and gcc at the
> same time?

Of course! That ability is a crucial part of what it takes to develop
and test portable software.

> Would that mean test.exe would link in source1.obj, source2.obj,
> main-gcc.obj and main-msvc.obj? Wouldn't that result in two definitions for
> main()? Which linker would it use, link.exe or ld.exe? Anyway, you could
> still do this with a simple if statement in SCons:

Different C++ compilers (gcc and msvc in particular) generally don't
produce link-compatible outputs. You get two separate executables,
made from different sources depending on the toolset.

> test_src = ['source1.cpp', 'source2.cpp']
> if 'gcc' in toolset: test_src += ['main-gcc.cpp']
> if 'msvc' in toolset: test_src += ['main-msvc.cpp']
> if 'darwin' in toolset: test_src += ['main-darwin.cpp']
> env.Program('test', test_src)
> where toolset is a list of the toolsets currently in use. Hmm, oddly enough
> this example is more concise (i.e. less characters) in SCons than in
> Boost.Build, even though Boost.Build uses a language designed specially for
> describing builds.

If we wanted to say the same thing in Jam language, it might look like

test-src = source1.cpp source2.cpp ;
for t in gcc msvc darwin {
if $(t) in $(toolset) { test-src += main-$(t).cpp }
exe test : $(test-src) ;

However, we're trying to say something different ;-)


David Abrahams
dave_at_[hidden] *
Boost support, enhancements, training, and commercial distribution

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at