Boost logo

Boost-Build :

Subject: Re: [Boost-build] what exactly does determine-target-name ?
From: Vladimir Prus (ghost_at_[hidden])
Date: 2010-02-21 05:05:17


On Thursday 18 February 2010 20:07:35 Fabien CHÊNE wrote:

> Hi,
>
> I encounter an issue with a custom generator. It used to work with an
> older boost build (2.0-m11), and unfortunately, it no longer works.
> Depending where I invoke bjam, object files are written in different
> directories. Invoking bjam in the top directory, a file is generated
> here:
>
> e_spnav/LDE/generated/src/bin/gcc-3.4/debug/address-model-32/architecture-x86/idl-typecode-any-nosplit/instruction-set-i686/omniidl-use-spn-wrapper-yes/threading-multi/GeneralConfigLDE.genSK.o
>
> If I invoke bjam in a subdirectory, it generates the same file here:
> e_spnav/LDE/generated/src/bin/gcc-3.4/debug/address-model-32/architecture-x86/idl-typecode-any-nosplit/instruction-set-i686/omniidl-use-spn-wrapper-yes/threading-multi/e_spnav/LDE/generated/src/GeneralConfigLDE.genSK.o
>
> I have spent a hard time understanding why. My guilty is the function
> determine-output-name, which calls determine-target-name.
>
> rule determine-target-name ( fullname : prefix ? : postfix ? )
> {
> # See if we need to add directory to the target name.
> local dir = $(fullname:D) ;
> local name = $(fullname:B) ;
>
> name = $(prefix:E=)$(name) ;
> name = $(name)$(postfix:E=) ;
>
> if $(dir) &&
> # Never append '..' to target path.
> ! [ MATCH .*(\\.\\.).* : $(dir) ]
> &&
> ! [ path.is-rooted $(dir) ]
> {
> # Relative path is always relative to the source
> # directory. Retain it, so that users can have files
> # with the same in two different subdirectories.
> name = $(dir)/$(name) ;
> }
> return $(name) ;
> }
>
> I don't understand why, depending on the fact that the path is
> relative or not, the target name should be prefixed by the directory.
> 2.0-m11 only made: name = $(name:D=)

Fabien,

the point of this code is so that if you have:

        exe a : a.cpp helpers/a.cpp ;

you get object files generated to a different directory. Therefore, if
we notice that if source target name has a directory part ('helpers' in my example),
we prepend that directory to destination target name (so you get:
<buildir>/helpers/a.o).

Could you show the definition of target that creates GeneralConfigLDE.genSK.o ?
Could you add

        ECHO "XXX" $(fullname) :

to the top of the above function and show what values are printed in both 'build from root'
and 'build from subdirectory' cases?

Thanks,

--
Vladimir Prus
http://vladimir_prus.blogspot.com
Boost.Build: http://boost.org/boost-build2

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