Boost logo

Boost-Build :

Subject: Re: [Boost-build] [run] parameter containing the build directory - segmentation fault
From: Raffi Enficiaud (raffi.enficiaud_at_[hidden])
Date: 2016-10-18 20:17:33


Le 17/10/16 à 00:17, Steven Watanabe a écrit :
> AMDG
>
> On 10/16/2016 03:00 PM, Raffi Enficiaud wrote:
>> Le 10/10/16 à 16:47, Steven Watanabe a écrit :
>>> <snip>
>>> rule set-sink ( properties * )
>>> {
>>> local ps = [ property-set.create $(properties) ] ;
>>> local path = [ $(ps).target-path ] ;
>>> return <testing.arg>--log-sink=$(path)/smoke-ts-sink.xml
>>> <testing.arg>--log-format=XML ;
>>> }
>>>
>>> Then, you can use <conditional>@set-sink in
>>> the requirements of the test case.
>>>
>>
>>
>> I tested several things, and I am quite not there yet.
>> The value here in path gets expanded to eg. "clang-darwin-4.2.1/debug"
>> while what I need is the same as the "testing.capture-output" line
>> which indicates
>> "../../../bin.v2/libs/test/test/bt-st-txml-0.test/clang-darwin-4.2.1/debug/bt-st-txml-0.run".
>>
>
> Right. You need to prefix it with the
> project's build directory. You can get this with
> local p = [ project.current ] ;
> local build-dir = [ $(p).build-dir ] ;

Unfortunately, this does not work. Now the conditional is like this

rule set-sink ( properties * )
{
   logger = XML ;
   local ps = [ property-set.create $(properties) ] ;
   local path,relative-to-build-dir = [ $(ps).target-path ] ;
   local path = $(path,relative-to-build-dir[1]) ;

   local p = [ project.current ] ;
   local build-dir = [ $(p).build-dir ] ;

   return <testing.arg>--log_sink=$(path)/smoke-ts-sink.$(logger)
          <testing.arg>--log_format=$(logger) ;
}

the run is
[ run smoke-ts-static : : : <conditional>@set-sink : $(test-name-prefix)-0 ]

and I have the error:
error: Reference to the project currently being loaded requested when
there was no project module being loaded. On the top of the file, I have
this:

""""""
project
     : requirements
     ;
""""""

but

""""""
project boost/test-tests
     : requirements
     ;
""""""

gives me the same.
>
> I'm a bit surprised that b2-st-txml.test
> doesn't show up, though. The
> <location-prefix> is set by testing.make-test
> which is called by run, so it should
> be present.

I am trying to discover location-prefix like this inside the set-sink:

   local location-prefix = [ property.select <location-prefix> :
$(properties) ] ;
   ECHO location-prefix $(location-prefix) ;

but it yields an empty string:

"""""""""""""""""
Performing configuration checks

     - 32-bit : no (cached)
     - 64-bit : yes (cached)
     - arm : no (cached)
     - mips1 : no (cached)
     - power : no (cached)
     - sparc : no (cached)
     - x86 : yes (cached)
     - symlinks supported : yes (cached)

location-prefix
location-prefix
"""""""""""""""""

Even more surprising, I have the string only twice, while there are 3
targets with this conditional. So I quite not get it.

>> [snip]
>
> Yes, that's the signature. No, you can't add
> more parameters. The rule is called by Boost.Build
> with a list of properties. If you added more parameters,
> Boost.Build wouldn't know what to do with them.

ok.

>
>> - can I have a rule returning a local rule and can a local rule
>> capture local variables? I tried this
>>
>> rule set-sink-outter ( logger )
>> {
>> rule set-sink-inner ( properties * )
>> {
>> local ps = [ property-set.create $(properties) ] ;
>> local path,relative-to-build-dir = [ $(ps).target-path ] ;
>> return <testing.arg>--log-sink=$(path)/smoke-ts-sink.$(logger)
>> <testing.arg>--log-format=$(logger) ;
>> }
>>
>> return <conditional>@set-sink-inner ;
>> }
>>
>> and called the run like this
>> [ run smoke-ts-static : : : [ set-sink-outter XML ] :
>> $(test-name-prefix)-0 ]
>>
>> but could not make it work. Any suggestion?
>>
>
> Variables in Jam have dynamic scope, not
> lexical scope. If you want to capture
> variables, you'll need to define a class.
> See build/configure.jam for an example of
> using a class with <conditional>.

Works great with class, thanks (especially the example was exactly what
I was looking for)!

I am seeing something strange about the methodology there. I have the
following class:

class bt-conditional-sink
{
     import property-set ;
     import targets ;
     import property ;

     rule __init__ ( logger )
     {
         ECHO instanciating sink with $(logger) ;
         self.logger = $(logger) ;
     }

     rule check ( properties * )
     {
         local ps = [ property-set.create $(properties) ] ;
         local path,relative-to-build-dir = [ $(ps).target-path ] ;
         local path = $(path,relative-to-build-dir[1]) ;

         ECHO LOGGER $(self.logger) ;
         ECHO PROP $(properties) ;

         # does not work
         # local p = [ project.current ] ;

         return <testing.arg>--log_sink=smoke-ts-sink.$(self.logger)
                 <testing.arg>--log_format=$(self.logger) ;
     }
}

In the logs of b2, I can see the following:

''''''''
LOGGER HRF
PROP <abi>sysv <address-model>64 <architecture>x86
<asynch-exceptions>off <binary-format>mach-o
<conditional>@Jamfile</Users/raffi/Personnel/boost_github/libs/test/test>%object(bt-conditional-sink)@2818.check
<conditional>@Jamfile</Users/
raffi/Personnel/boost_github>%Jamfile</Users/raffi/Personnel/boost_github>.handle-static-runtime
<conditional>@Jamfile</Users/raffi/Personnel/boost_github>%boostcpp.deduce-address-model
<conditional>@Jamfile</Users/raffi/Personnel/boost_g
ithub>%boostcpp.deduce-architecture <cxxflags>-stdlib=libc++ -std=c++11
<debug-symbols>on <deduced-address-model>64 <deduced-architecture>x86
<exception-handling>on <extern-c-nothrow>off <hardcode-dll-paths>true
<host-os>darwin <implicit-
dependency>/boost//headers <inlining>off <install-dependencies>off
<link>shared <linkflags>-stdlib=libc++ <optimization>off <os>MACOSX
<pch>on <preserve-test-targets>on <profiling>off <python-debugging>off
<python>2.7 <rtti>on <runtime-de
bugging>on <runtime-link>shared <stdlib>native <strip>off
<suppress-import-lib>false <symlink-location>project-relative
<target-os>darwin <testing.execute>on <threadapi>pthread
<threading>single <toolset-clang:platform>darwin <toolset-cla
ng:version>4.2.1 <toolset>clang <user-interface>console <variant>debug
<vectorize>off <warnings-as-errors>off <warnings>on
LOGGER HRF
PROP <abi>sysv <address-model>64 <architecture>x86
<asynch-exceptions>off <binary-format>mach-o
<conditional>@Jamfile</Users/raffi/Personnel/boost_github/libs/test/test>%object(bt-conditional-sink)@2818.check
<conditional>@Jamfile</Users/
raffi/Personnel/boost_github>%Jamfile</Users/raffi/Personnel/boost_github>.handle-static-runtime
<conditional>@Jamfile</Users/raffi/Personnel/boost_github>%boostcpp.deduce-address-model
<conditional>@Jamfile</Users/raffi/Personnel/boost_g
ithub>%boostcpp.deduce-architecture <cxxflags>-stdlib=libc++ -std=c++11
<debug-symbols>on <deduced-address-model>64 <deduced-architecture>x86
<exception-handling>on <extern-c-nothrow>off <hardcode-dll-paths>true
<host-os>darwin <implicit-
dependency>/boost//headers <inlining>off <install-dependencies>off
<link>shared <linkflags>-stdlib=libc++ <optimization>off <os>MACOSX
<pch>on <preserve-test-targets>on <profiling>off <python-debugging>off
<python.interpreter>/System/Libr
ary/Frameworks/Python.framework/Versions/2.7/bin/python <python>2.7
<rtti>on <runtime-debugging>on <runtime-link>shared <stdlib>native
<strip>off <suppress-import-lib>false <symlink-location>project-relative
<target-os>darwin <testing.arg
>--log_format=HRF <testing.arg>--log_sink=smoke-ts-sink.HRF
<testing.execute>on <threadapi>pthread <threading>single
<toolset-clang:platform>darwin <toolset-clang:version>4.2.1
<toolset>clang <user-interface>console <variant>debug <vector
ize>off <warnings-as-errors>off <warnings>on
''''''''

Sorry, it is verbose, **but** what I want to say is that
- there are 2 calls for the conditional "check"
- those 2 calls are not having the same set of properties as parameter,
especially the "<testing.arg>" that we added are there in the second pass.

Is that normal?

>> - I understand "<conditional>@set-sink" as a "pointer to set-sink
>> function". Is that correct?
>
> Yes.

Thanks! Quick question :) : in

''''''''''''''''''''''''
rule boost.test-smoke-ts-logger ( test-name-prefix : logger ? )
{
     logger ?= HRF ;

     local bt-conditional-sink-instance = [ new bt-conditional-sink
$(logger) ] ;

     return
       [ run smoke-ts-static : : :
<conditional>@$(bt-conditional-sink-instance).check :
$(test-name-prefix)-0 ]
}
''''''''''''''''''''''''

does the <conditional>@$(bt-conditional-sink-instance).check make it
such that the lifetime of the local bt-conditional-sink-instance
outlives the call to the rule? (basically is this all valid code?)

>> - by parsing some other Jam files in boost, I also saw
>> "<conditional>%something". What would the "%" mean?
>>
>
> I think this means to look up "something"
> in the global module. You can put a module
> name before the %. Note: Just to avoid confusion,
> as far as the Jam language itself is concerned,
> it's just a string. The use of % comes from
> the indirect module which is used to represent
> function pointers as strings in a way that is
> (mostly) reliable.
>

thanks,
Raffi


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