Boost logo

Boost-Build :

Subject: Re: [Boost-build] Generating multiple CPP/H targets from a single source
From: Fabien Chêne (fabien.chene_at_[hidden])
Date: 2010-08-06 06:11:17


Hi Vladimir,

2010/8/5 Vladimir Prus <vladimir_at_[hidden]>:
[...]
>> About the OP's example, it looks the same
>> SourceForCodeGeneratorSupport.cpp depends on
>> SourceForCodeGeneratorSupport.h but bjam don't know it when files are
>> not yet generated. Right ?
>
> bjam is supposed to rescan a file right after it is generated, so
> it should pick this dependency. The relevant code is in make1.c,
> afterh the comment that reads:

Ah, I wasn't aware about that, thanks.

>            /* Target has been updated so rescan it for dependencies. */
>
> You might want to start by adding some debug prints in there to make
> sure the .cpp file is actually rescanned, and what headers are found.

I'm currently trying to do it...

But for now, I am also looking for a bug in my generator or in BB, I
find a strange behaviour in the following (quite simplified)
generator:

class omniidl-generator : generator
{
  rule __init__ ( * : * )
  {
    generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7)
: $(8) : $(9) ;
  }

  rule generated-targets ( sources + : property-set : project name ? )
  {
        if ! $(name)
        {
            name = [ determine-output-name $(sources) ] ;
        }

        local src-locat = [ $(property-set).get <idl-src-location> ] ;
        local header-locat = [ $(property-set).get <idl-header-location> ] ;

        local action = [ action-class ] ;
        local a = [ class.new $(action) $(sources) : $(self.rule-name)
: $(property-set) ] ;

        local targets ;

        #### block 1 ####
        local sk-hpp = $(header-locat)/$(name:BS) ;
        sk-hpp = $(sk-hpp:R=$(name:D)) ;
        local target-sk-hpp = [ class.new file-target $(sk-hpp) :
                                HPP : $(project) : $(a) ] ;
        #### end block 1 ###

        #### block 2 ####
        local sk-cpp = $(src-locat)/$(name:BS)SK ;
        sk-cpp = $(sk-cpp:R=$(name:D)) ;
        local target-sk-cpp = [ class.new file-target $(sk-cpp) :
                                CPP : $(project) : $(a) ] ;
        ##### end block 2 ####

        targets += $(target-sk-cpp) ;
        targets += $(target-sk-hpp) ;

        return [ sequence.transform virtual-target.register : $(targets) ] ;
    }
}

generators.register [ new omniidl-generator
omniidl.stub-skeleton-files : IDL : CPP HPP ] ;

With 'Block1' before 'Block2',
bjam outputs the following line:
omniidl.stub-skeleton-files ./test.hh
And it fails with -jN.

With 'Block2' before 'Block1'
bjam outputs the following line:
omniidl.stub-skeleton-files ./testSK.cxx
and it succeeds with -jN

Could you tell me what is going on here ?

Thanks.

-- 
Fabien

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