targetboost-buildjamb2

Boost-build - dependency on subproject target


I have a jamfile-based project where one of the build steps compiles a custom tool (called 'codegen') which I want to use in a later build step. The codegen tool is built in projects/codegen/Jamfile.jam relative to the root, and the executable target is ultimately declared with the line:

install codegen-tool : $(full-exe-target) : <location>$(install-dir) ;

In Jamroot.jam, I have the following:

rule codegen ( target : source : properties * )
{
    COMMAND on $(target) = projects/codegen//codegen-tool ;
    DEPENDS $(target) : projects/codegen//codegen-tool ;
}

actions codegen bind COMMAND
{
    $(COMMAND) $(<) $(>)
}

project.load projects/codegen//codegen-tool ;
local codegen-input = <blah> ;
local codegen-output = <blah> ;

make $(codegen-output) : $(codegen-input) : @codegen ;
alias codegen-output : $(codegen-output) ;

When I run the command "b2 codegen-output", I get the error:

don't know how to make project projects/codegen//codegen-tool

But running the command "b2 projects/codegen//codegen-tool" is successful. How come I'm not able to reference the codegen-tool target from Jamroot.jam?


Solution

  • The key problem you are having is that the codegen rule of the tool:

    rule codegen ( target : source : properties * )
    {
        COMMAND on $(target) = projects/codegen//codegen-tool ;
        DEPENDS $(target) : projects/codegen//codegen-tool ;
    }
    

    Are to the meta-target instead of a real target (aka a file-target) generated from building the codegen-tool meta-target. The "easy" way to get such tool dependencies to work is to use a feature on your make target to inform it of what the built full path to the tool is. And the feature you use for that is a "dependency" feature. For example you would add in your jamroot something like:

    import feature ;
    
    feature.feature codegen : : dependency free ;
    

    And set and use that feature to refer to the codegent-tool:

    project : requirements <codegen>projects/codegen//codegen-tool ;
    

    There's not enough information in your question to answer with a full example.. But you should consult the fully working built_tool example for how to get the details of how using the dependency feature works for the use case of custom built tools.