Copy previous build target into current unit test directory

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Copy previous build target into current unit test directory

tr1gun
Hello,

i need to load a build com dll with an embedded manifest in a unit test.
The manifest loading requires the dll in the same directory as the build
unit test exe.
Is it possible to copy the build dll and another manifest file into the
created unit test directory?
Thanks in advance.


Best regards,

Bernhard
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Copy previous build target into current unit test directory

Steven Watanabe-4
AMDG

On 03/31/2014 11:41 AM, tr1gun wrote:
> i need to load a build com dll with an embedded manifest in a unit test.
> The manifest loading requires the dll in the same directory as the build
> unit test exe.
> Is it possible to copy the build dll and another manifest file into the
> created unit test directory?
>

Copying files is easy.  Just use make with common.copy.
The problem is knowing the destination directory.
The easiest way is to use the unit-test rule instead
of run and use common.copy without an explicit <location>.
This will create a copy of the file in the build directory.
To handle run, you need to set <location-prefix> to
match the run rule.  Actually getting this safely
is a bit painful, unless you're willing to rely on
knowing that testing.jam uses <location-prefix>$(target-name).test

local target = [ run test.cpp : : : <dependency>mylib.dll ] ;
local properties = [ $(target).requirements ] ;
local location-prefix = [ $(properties).get <location-prefix> ] ;
make mylib.dll : source-of-mylib : @common.copy :
  <location-prefix>$(location-prefix) ;

In Christ,
Steven Watanabe

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

Re: Copy previous build target into current unit test directory

Boost - Build mailing list
Hi Steven,

I am in a similar situation as the OP. I have a unit-test but don't see an obvious way to copy my lib target's output to the unit-test
directory. I dug back through the archives and found this post as the closest explanation of how to do what I want without making deeper
modifications to Boost.Build.

The lib is a SQLite extension (shared object or DLL), so the unit test needs to know the path to it to load it (and I'd rather avoid the
complexity of changing to a run target and passing the lib target as an input file). This would apply to dynamic plugin systems in general,
too. Where do I put the @common.copy to get the lib copied? Do I have to convert the lib target to a make target, or is the `make mylib.dll`
below supposed to be in addition to an implied `lib mylib` target?

Thanks,
-Matt


On 3/31/2014 2:18 PM, Steven Watanabe wrote:

> AMDG
>
> On 03/31/2014 11:41 AM, tr1gun wrote:
>> i need to load a build com dll with an embedded manifest in a unit test.
>> The manifest loading requires the dll in the same directory as the build
>> unit test exe.
>> Is it possible to copy the build dll and another manifest file into the
>> created unit test directory?
>>
> Copying files is easy.  Just use make with common.copy.
> The problem is knowing the destination directory.
> The easiest way is to use the unit-test rule instead
> of run and use common.copy without an explicit <location>.
> This will create a copy of the file in the build directory.
> To handle run, you need to set <location-prefix> to
> match the run rule.  Actually getting this safely
> is a bit painful, unless you're willing to rely on
> knowing that testing.jam uses <location-prefix>$(target-name).test
>
> local target = [ run test.cpp : : : <dependency>mylib.dll ] ;
> local properties = [ $(target).requirements ] ;
> local location-prefix = [ $(properties).get <location-prefix> ] ;
> make mylib.dll : source-of-mylib : @common.copy :
>    <location-prefix>$(location-prefix) ;
>
> In Christ,
> Steven Watanabe
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
>
>

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

Re: Copy previous build target into current unit test directory

Boost - Build mailing list
AMDG

On 08/01/2017 09:55 AM, Chambers, Matthew via Boost-build wrote:

>
> I am in a similar situation as the OP. I have a unit-test but don't see
> an obvious way to copy my lib target's output to the unit-test
> directory. I dug back through the archives and found this post as the
> closest explanation of how to do what I want without making deeper
> modifications to Boost.Build.
>
> The lib is a SQLite extension (shared object or DLL), so the unit test
> needs to know the path to it to load it (and I'd rather avoid the
> complexity of changing to a run target and passing the lib target as an
> input file). This would apply to dynamic plugin systems in general, too.
> Where do I put the @common.copy to get the lib copied? Do I have to
> convert the lib target to a make target, or is the `make mylib.dll`
> below supposed to be in addition to an implied `lib mylib` target?
>

  If you're using unit-test, then as long as
the lib is in the same project and uses the
same properties as the unit-test, it will be
built in the same directory.

In Christ,
Steven Watanabe

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

Re: Copy previous build target into current unit test directory

Boost - Build mailing list
On 8/1/2017 11:53 AM, Steven Watanabe via Boost-build wrote:

> On 08/01/2017 09:55 AM, Chambers, Matthew via Boost-build wrote:
>> I am in a similar situation as the OP. I have a unit-test but don't see
>> an obvious way to copy my lib target's output to the unit-test
>> directory. I dug back through the archives and found this post as the
>> closest explanation of how to do what I want without making deeper
>> modifications to Boost.Build.
>>
>> The lib is a SQLite extension (shared object or DLL), so the unit test
>> needs to know the path to it to load it (and I'd rather avoid the
>> complexity of changing to a run target and passing the lib target as an
>> input file). This would apply to dynamic plugin systems in general, too.
>> Where do I put the @common.copy to get the lib copied? Do I have to
>> convert the lib target to a make target, or is the `make mylib.dll`
>> below supposed to be in addition to an implied `lib mylib` target?
>>
>    If you're using unit-test, then as long as
> the lib is in the same project and uses the
> same properties as the unit-test, it will be
> built in the same directory.

Thanks for the tip about making sure the properties are the same. My unit-test had a custom <location-prefix> and was <link>static
(inherited from default-build) whereas the extension was of course <link>shared and didn't have a <location-prefix>. After matching those
properties up ("<link>shared <library>extension/<location-prefix>foo" on the unit-test), it worked. However, this feels quite fragile! And
of course as you mentioned it depends on them being in the same project.

Can Boost.Build have a built-in propagated free feature that acts like <dependency> but copies the depended-on target (or simple file) to
the build directory? This would be very helpful on Windows for interacting with .NET, and would be useful for using/testing dynamic plugins
as above. I actually hacked my own msvc.jam a long time ago to support an <assembly> feature which not only copies the file to the output
directory, but also adds it to the compile command (/FU). Along with a few other customizations, this allows my BB to build C++/CLI. But my
implementation was hacky so I haven't contributed it. I didn't know how to do it properly in BB and it seems that dynamic plugins need this
to work for multiple toolsets.

Thanks!
-Matt
_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Copy previous build target into current unit test directory

Boost - Build mailing list
AMDG

On 08/01/2017 02:01 PM, Chambers, Matthew via Boost-build wrote:

> On 8/1/2017 11:53 AM, Steven Watanabe via Boost-build wrote:
>>    If you're using unit-test, then as long as
>> the lib is in the same project and uses the
>> same properties as the unit-test, it will be
>> built in the same directory.
>
> Thanks for the tip about making sure the properties are the same. My
> unit-test had a custom <location-prefix> and was <link>static (inherited
> from default-build) whereas the extension was of course <link>shared and
> didn't have a <location-prefix>. After matching those properties up
> ("<link>shared <library>extension/<location-prefix>foo" on the
> unit-test), it worked. However, this feels quite fragile! And of course
> as you mentioned it depends on them being in the same project.
>

To copy files, you can use:
install copied-library : /other-project//library-target ;

(Normally install is used with a <location>, but if
you leave off the location, it will copy the files
to the regular build directory.)

> Can Boost.Build have a built-in propagated free feature that acts like
> <dependency> but copies the depended-on target (or simple file) to the
> build directory? This would be very helpful on Windows for interacting
> with .NET, and would be useful for using/testing dynamic plugins as
> above. I actually hacked my own msvc.jam a long time ago to support an
> <assembly> feature which not only copies the file to the output
> directory, but also adds it to the compile command (/FU). Along with a
> few other customizations, this allows my BB to build C++/CLI. But my
> implementation was hacky so I haven't contributed it. I didn't know how
> to do it properly in BB and it seems that dynamic plugins need this to
> work for multiple toolsets.
>

In Christ,
Steven Watanabe

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

Re: Copy previous build target into current unit test directory

Boost - Build mailing list
AMDG

On 08/01/2017 02:10 PM, Steven Watanabe wrote:
>
> To copy files, you can use:
> install copied-library : /other-project//library-target ;
>
> (Normally install is used with a <location>, but if
> you leave off the location, it will copy the files
> to the regular build directory.)
>

  Scratch that.  install defaults to using the project's
directory.  You'll need to use common.copy with make
as in my original response.

In Christ,
Steven Watanabe

_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
Loading...