boost-buildbjamjamb2

How can I include the Jambase file to my build?


I'm trying to setup a simple bjam build example, where I use the SubDir rule in my top-level Jamroot.jam file:

SubDir TOP ;

exe main : main.cpp ;

I'm using boost_1_58_0 and when I leave out the SubDir directive, the build works fine.

But when I try to use SubDir, bjam claims that the rule is unknown...although I see that the Jambase file gets parsed:

dirkb@wks91:bjam_try$ BOOST_BUILD_ROOT=/home/dirkb/snaps/git/boost_1_58_0 BOOST_ROOT=/home/dirkb/snaps/git/boost_1_58_0 /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/engine/bin.linuxx86_64/b2 -f Jambase --debug-loading --debug-configuration
Parsing file: Jambase
notice: found boost-build.jam at /home/dirkb/snaps/git/boost_1_58_0/boost-build.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/boost-build.jam
notice: loading Boost.Build from /home/dirkb/snaps/git/boost_1_58_0/tools/build/src
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/bootstrap.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/kernel/bootstrap.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/kernel/modules.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/kernel/modules.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/option.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build-system.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/build-request.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/kernel/class.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/numbers.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/kernel/errors.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/sequence.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/assert.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/set.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/regex.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/feature.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/indirect.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/utility.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/property.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/path.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/string.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/container.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/builtin.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/alias.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/project.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/print.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/scanner.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/property-set.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/virtual-target.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/type.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/generators.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/os.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/common.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/toolset.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util/order.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/targets.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/stage.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/types/register.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/types/asm.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/types/cpp.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/types/exe.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/types/html.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/types/lib.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/types/obj.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/types/objc.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/types/preprocessed.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/types/qt.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/types/rsp.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/symlink.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/message.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/convert.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/generate.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/configure.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/config-cache.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools/make.jam
Parsing file: /home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/version.jam
Initializing project 'test-config'
Assigned project target object(project-target)@62 to 'test-config'
Initializing project 'site-config'
Assigned project target object(project-target)@64 to 'site-config'
notice: Searching '/etc' '/home/dirkb' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src' '/usr/share/boost-build' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/kernel' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/contrib' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/.' for site-config configuration file 'site-config.jam'.
notice: Configuration file 'site-config.jam' not found in '/etc' '/home/dirkb' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src' '/usr/share/boost-build' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/kernel' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/contrib' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/.'.
Initializing project 'user-config'
Assigned project target object(project-target)@66 to 'user-config'
notice: Searching '/home/dirkb' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src' '/usr/share/boost-build' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/kernel' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/contrib' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/.' for user-config configuration file 'user-config.jam'.
notice: Configuration file 'user-config.jam' not found in '/home/dirkb' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src' '/usr/share/boost-build' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/kernel' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/util' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/tools' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/contrib' '/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/.'.
Loading Jamfile at '.'
Initializing project 'Jamfile</disk2/stuff/dirkb/snaps/git/bjam_try>'
Assigned project target object(project-target)@68 to 'Jamfile</disk2/stuff/dirkb/snaps/git/bjam_try>'
Parsing file: Jamroot.jam
Jamroot.jam:1: in modules.load
ERROR: rule "SubDir" unknown in module "Jamfile</disk2/stuff/dirkb/snaps/git/bjam_try>".
/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/project.jam:325: in load-jamfile
/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/project.jam:64: in load
/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build/project.jam:145: in project.find
/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/build-system.jam:535: in load
/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/kernel/modules.jam:289: in import
/home/dirkb/snaps/git/boost_1_58_0/tools/build/src/kernel/bootstrap.jam:139: in boost-build
/home/dirkb/snaps/git/boost_1_58_0/boost-build.jam:17: in module scope
dirkb@wks91:bjam_try$

The Jambase file, and a simple Jamrules, exist at the top-level of my toy project. When I leave out the "-f Jambase" option, bjam picks the internal Jambase definition (+) but yields the same result...SubDir is unknown.

When I start bjam with the option "-d 12" I see that the SubDir rule from the Jambase gets properly scanned, but somehow it's not correctly bound, defined or whatever bjam usually does to make methods/rules "usable". As you can probably see from the used paths, I have only bootstrapped b2 so boost isn't properly installed yet. For debugging, I also patched its sources a little bit, that's where the "Parsing file..." messages come from.

How can I properly "inject" the rule definitions from the Jambase file, such that they are known while parsing Jamfiles?


Solution

  • TL;DR: If your project contains Jamfiles that refer to definitions like SubDir from the Jambase file, don't bother trying to use bjam/b2. Use ft-jam instead!

    Long answer with some more background info:

    At work I tried to build an old software package (Ingres DBMS 10.1) from source over two weeks. It contained Jamfile and Jamrules files in its tree structure, so I concluded that I would have to use bjam/b2 to get things going. The project's documentation wasn't specific enough about this point as it turned out.

    I had one major problem, the Jamfiles would use a lot of definitions from the "Jambase" file, like "SubDir" a.s.o. Everytime I started the build, I would get the error "unknown rule", as you can also see in the question.

    I finally decided to give an older Jam version a try, and voila: with ft-jam v2.5.2 the project compiled flawlessly without any further ado. Yay!

    So, basically everything was fine now and I could use ft-jam for my purposes. But I still wondered whether I could also use bjam/b2 for the compile. What is the purpose of the internal Jambase definition ("+" file) and the "-f" option in bjam? Is it only for bootstrapping b2 itself, or can I use it while running b2? If yes, how do I activate it?

    In the end, I wrote to the boost-build mailing list and got the following answer:

    b2 is not a drop-in replacement for Perforce Jam. Using ft-jam is the correct option.

    The current Jambase is only used for bootstrapping Boost.Build. Older versions of b2 had a copy of the original Jambase which would be activated if the executable was named something other than b2/bjam. Even so, I don't recommend using it as it was completely unmaintained.

    Link to mail thread