Copying source file required by target

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Copying source file required by target

Boost - Build mailing list
Hi,

I'm trying to replicate this CMake'ism for BBv2

f(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/mwe.cpp)
  configure_file(
    ${CMAKE_CURRENT_SOURCE_DIR}/mwe.cpp.in
    ${CMAKE_CURRENT_SOURCE_DIR}/mwe.cpp
    COPYONLY)
endif()

I'm trying to achieve that with the make rule and simple actions:

make mwe.cpp : mwe.cpp.in : @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 mwe.cpp.in?

I've tried to hack it modifying target path using the variables
expansion, but without luck.

I have also tried to follow the BBv2 generate example based on
file-target and common.copy action:
https://github.com/boostorg/build/tree/develop/example/generate
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
- it will have to check if file exists

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Copying source file required by target

Boost - Build mailing list
AMDG

On 07/26/2018 11:08 AM, Mateusz Loskot via Boost-build wrote:

> I'm trying to replicate this CMake'ism for BBv2
>
> f(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/mwe.cpp)
>   configure_file(
>     ${CMAKE_CURRENT_SOURCE_DIR}/mwe.cpp.in
>     ${CMAKE_CURRENT_SOURCE_DIR}/mwe.cpp
>     COPYONLY)
> endif()
>
> I'm trying to achieve that with the make rule and simple actions:
>
> make mwe.cpp : mwe.cpp.in : @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 mwe.cpp.in?
>
> 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 have also tried to follow the BBv2 generate example based on
> file-target and common.copy action:
> https://github.com/boostorg/build/tree/develop/example/generate
> 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.

> - 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.)

In Christ,
Steven Watanabe
_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Copying source file required by target

Boost - Build mailing list
On 26 July 2018 at 19:19, Steven Watanabe via Boost-build
<[hidden email]> wrote:

> AMDG
>
> On 07/26/2018 11:08 AM, Mateusz Loskot via Boost-build wrote:
>> I'm trying to replicate this CMake'ism for BBv2
>>
>> f(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/mwe.cpp)
>>   configure_file(
>>     ${CMAKE_CURRENT_SOURCE_DIR}/mwe.cpp.in
>>     ${CMAKE_CURRENT_SOURCE_DIR}/mwe.cpp
>>     COPYONLY)
>> endif()
>>
>> I'm trying to achieve that with the make rule and simple actions:
>>
>> make mwe.cpp : mwe.cpp.in : @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 mwe.cpp.in?
>>
>> 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 : mwe.cpp.in : @copy_mwe_if_not_exists <location>. ;
or
make mwe.cpp : mwe.cpp.in : <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
gcc.link bin/gcc-7.3.0/debug/mwe
...updated 5 targets...
mloskot@xenial:/mnt/d/_/workshop/bb_copy_file$ tree

$ tree -if
.
./bin
./bin/config.log
./bin/gcc-7.3.0
./bin/gcc-7.3.0/debug
./bin/gcc-7.3.0/debug/mwe
./bin/gcc-7.3.0/debug/mwe.o
./bin/mwe.cpp
./bin/project-cache.jam
./jamroot.jam
./mwe.cpp.in
./project-config.jam



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:
>> https://github.com/boostorg/build/tree/develop/example/generate
>> 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.)

Great!

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Copying source file required by target

Boost - Build mailing list
AMDG

On 07/27/2018 03:55 AM, Mateusz Loskot via Boost-build wrote:

> On 26 July 2018 at 19:19, Steven Watanabe via Boost-build
> <[hidden email]> wrote:
>> On 07/26/2018 11:08 AM, Mateusz Loskot via Boost-build wrote:
>>> <snip>
>>> make mwe.cpp : mwe.cpp.in : @copy_mwe_if_not_exists ;
>>> actions copy_mwe_if_not_exists { cp $(>) $(<) }
>>> <snip>
>>> How can I force it to create mwe.cpp in the same directory as mwe.cpp.in?
>>>
>>
>>
>> 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 : mwe.cpp.in : @copy_mwe_if_not_exists <location>. ;
> or
> make mwe.cpp : mwe.cpp.in : <location>. @copy_mwe_if_not_exists ;
>
> also trying to use absolute path instead of dot.
>
> <snip>
>
> Where the <location> should go for the desired effect?
>

$ b2 --help make.make
Rule 'make.make ( target-name : sources * : generating-rule + :
requirements * : usage-requirements * )':

Add a ':' between the rule and <location>.

>>> I have also tried to follow the BBv2 generate example based on
>>> file-target and common.copy action:
>>> https://github.com/boostorg/build/tree/develop/example/generate
>>> 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.
>

You don't need to create your own action block at
all.  Just pass @common.copy to make.

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

In Christ,
Steven Watanabe
_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Copying source file required by target

Boost - Build mailing list
On 27 July 2018 at 15:42, Steven Watanabe via Boost-build
<[hidden email]> wrote:

> On 07/27/2018 03:55 AM, Mateusz Loskot via Boost-build wrote:
>> On 26 July 2018 at 19:19, Steven Watanabe via Boost-build
>> <[hidden email]> wrote:
>>> On 07/26/2018 11:08 AM, Mateusz Loskot via Boost-build wrote:
>>>> <snip>
>>>> make mwe.cpp : mwe.cpp.in : @copy_mwe_if_not_exists ;
>>>> actions copy_mwe_if_not_exists { cp $(>) $(<) }
>>>> <snip>
>>>> How can I force it to create mwe.cpp in the same directory as mwe.cpp.in?
>>>
>>>
>>> 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 : mwe.cpp.in : @copy_mwe_if_not_exists <location>. ;
>> or
>> make mwe.cpp : mwe.cpp.in : <location>. @copy_mwe_if_not_exists ;
>>
>> also trying to use absolute path instead of dot.
>> <snip>
>>
>> Where the <location> should go for the desired effect?
>>
>
> $ b2 --help make.make
> Rule 'make.make ( target-name : sources * : generating-rule + :
> requirements * : usage-requirements * )':

I should have remembered to ask b2 for help :)
I've been trying quite sincerely to learn it from
https://boostorg.github.io/build/manual/develop/index.html


> Add a ':' between the rule and <location>.

Works, of course.

>>>> I have also tried to follow the BBv2 generate example based on
>>>> file-target and common.copy action:
>>>> https://github.com/boostorg/build/tree/develop/example/generate
>>>> 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.
>>
>
> You don't need to create your own action block at
> all.  Just pass @common.copy to make.

Heh, that is simple indeed!

Thank you

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Copying source file required by target

Boost - Build mailing list
AMDG

On 07/27/2018 10:34 AM, Mateusz Loskot via Boost-build wrote:
> On 27 July 2018 at 15:42, Steven Watanabe via Boost-build
> <[hidden email]> wrote:
>> <snip>
>> $ b2 --help make.make
>> Rule 'make.make ( target-name : sources * : generating-rule + :
>> requirements * : usage-requirements * )':
>
> I should have remembered to ask b2 for help :)

  The built-in help command is often more
useful if what you're looking for is the
exact signature of a rule.  We're slowly
working on getting all this information
into the html docs, but it's a work in
progress.

> I've been trying quite sincerely to learn it from
> https://boostorg.github.io/build/manual/develop/index.html
>

In Christ,
Steven Watanabe
_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Copying source file required by target

Boost - Build mailing list
On 7/27/2018 12:43 PM, Steven Watanabe via Boost-build wrote:

> AMDG
>
> On 07/27/2018 10:34 AM, Mateusz Loskot via Boost-build wrote:
>> On 27 July 2018 at 15:42, Steven Watanabe via Boost-build
>> <[hidden email]> wrote:
>>> <snip>
>>> $ b2 --help make.make
>>> Rule 'make.make ( target-name : sources * : generating-rule + :
>>> requirements * : usage-requirements * )':
>>
>> I should have remembered to ask b2 for help :)
>
>    The built-in help command is often more
> useful if what you're looking for is the
> exact signature of a rule.  We're slowly
> working on getting all this information
> into the html docs, but it's a work in
> progress.

I find it disappointing that there is no easy way to get an alphabetic
list and explanation of all b2 options. Even first 'b2 --help' and then
using 'b2 --help-options' does not list all the b2 options AFAICS. Also
of course the b2 options are not all listed in the html docs, as you say
above. Should not this be easier for Boost developers ? Maybe no one
actually knows all the options to b2, and that is why there is no simply
alphabetic listing with explanation of b2 options ?

>
>> I've been trying quite sincerely to learn it from
>> https://boostorg.github.io/build/manual/develop/index.html
>>
>
> In Christ,
> Steven Watanabe

_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Copying source file required by target

Boost - Build mailing list
AMDG

On 07/27/2018 03:12 PM, Edward Diener via Boost-build wrote:
> Maybe no one
> actually knows all the options to b2, and that is why there is no simply
> alphabetic listing with explanation of b2 options ?
>

  That's actually the case.  The main issue
is that options are open-ended.  The usual
method of handling an option is to search
ARGV.  Modules and Jamfiles can and do add
their own options at will.

In Christ,
Steven Watanabe
_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build