1

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?

Gumgo
  • 526
  • 4
  • 16

1 Answers1

2

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.

GrafikRobot
  • 3,020
  • 1
  • 20
  • 21
  • That seems to have done the trick, thanks! I made one modification, which is that I added projects/codegen//codegen-tool to the make command itself rather than to the Jamroot project, because I would get a target recursion error otherwise since the codegen requirement would get inherited by the codegen subproject itself. – Gumgo Oct 04 '16 at 06:20