Boost logo

Boost-Build :

Subject: Re: [Boost-build] Copying source file required by target
From: Mateusz Loskot (mateusz_at_[hidden])
Date: 2018-07-27 09:55:28

On 26 July 2018 at 19:19, Steven Watanabe via Boost-build
<boost-build_at_[hidden]> wrote:
> On 07/26/2018 11:08 AM, Mateusz Loskot via Boost-build wrote:
>> I'm trying to replicate this CMake'ism for BBv2
>> configure_file(
>> endif()
>> I'm trying to achieve that with the make rule and simple actions:
>> make mwe.cpp : : @copy_mwe_if_not_exists ;
>> actions copy_mwe_if_not_exists { cp $(>) $(<) }
>> exe mwe : mwe.cpp : ;
>> Basically, this works, but there is one major issue"
>> - it creates source file in bin/mwe.cpp.
>> How can I force it to create mwe.cpp in the same directory as
>> I've tried to hack it modifying target path using the variables
>> expansion, but without luck.
> Since you want to put the file in a fixed place,
> use <location>.

I've fiddled with the property but I must be doing something wrong

make mwe.cpp : : @copy_mwe_if_not_exists <location>. ;
make mwe.cpp : : <location>. @copy_mwe_if_not_exists ;

also trying to use absolute path instead of dot.

In all cases mwe.cpp is generated inside bin sub-directory

$ b2
...found 9 targets...
...updating 5 targets...
Jamfile</mnt/d/_/workshop/bb_copy_file>.copy_mwe_if_not_exists bin/mwe.cpp
gcc.compile.c++ bin/gcc-7.3.0/debug/mwe.o bin/gcc-7.3.0/debug/mwe
...updated 5 targets...
mloskot_at_xenial:/mnt/d/_/workshop/bb_copy_file$ tree

$ tree -if

Where the <location> should go for the desired effect?

>> I have also tried to follow the BBv2 generate example based on
>> file-target and common.copy action:
>> But constructing a target seems like an overkill for my purpose.
>> And, the rule (or common.copy) also creates file in `bin` directory.
>> BTW, I am aware the `copy_mwe_if_not_exists` is incomplete regarding its name:
>> - it will have to use cp or copy depending on OS
> common.copy does this already.

I'm simply failing to figure out how to use it in the simple actions {} block.

Do I need to get back to generate rule approach mentioned earlier,
in order to be able to use common.copy?

>> - it will have to check if file exists
> This is the normal behavior of all targets.
> (If you don't want to check whether it's out-of-date,
> you can mark the target as NOUPDATE.)


Best regards,

Mateusz Loskot,

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