From: Vladimir Prus (ghost_at_[hidden])
Date: 2002-12-03 08:53:51
Anthony Roach wrote:
> On Tuesday 03 December 2002 02:38 am, Vladimir Prus wrote:
>> source test-src-common : source1.cpp source2.cpp ;
>> source test-src : main-gcc.cpp test-src-common : <toolset>gcc ;
>> source test-src : main-msvc.cpp test-src-common : <toolset>msvc ;
>> source test-src : main-darwin.cpp test-src-common : <toolset>darwin ;
>> exe test : test-src ;
>>The point is that "test-src" target specifies all sources for "test"
>>exe, and those sources depend on used toolset. For example,
>>main-gcc.cpp will be included in "test" only when compiling with gcc.
>>I believe you can't achieve this effect with simple "if", because Jamfile
>>is read only one, but you can build with several toolsets.
> Are you saying that the user can build with both msvc and gcc at the same
> time? 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?
Actually, it would build *two* executables, one with msvc and another with
gcc. And main-gcc.cpp will be included only in one of them.
> Anyway, you could
> still do this with a simple if statement in SCons:
> 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.
My point was presicely that "if" statements won't work the way "source" would.
They will really compile main-gcc.cpp and main-msvc.cpp into *one* binary.
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