如何将 Jambase 文件包含到我的构建中?

How can I include the Jambase file to my build?

我正在尝试设置一个简单的 bjam 构建示例,我在顶级 Jamroot.jam 文件中使用 SubDir 规则:

SubDir TOP ;

exe main : main.cpp ;

我正在使用 boost_1_58_0,当我省略 SubDir 指令时,构建工作正常。

但是当我尝试使用 SubDir 时,bjam 声称该规则未知...尽管我看到 Jambase 文件已被解析:

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$

Jambase 文件和一个简单的 Jamrules,存在于我的玩具项目的顶层。当我省略“-f Jambase”选项时,bjam 选择内部 Jambase 定义 (+) 但产生相同的结果...SubDir 未知。

当我使用选项“-d 12”启动 bjam 时,我看到 Jambase 中的 SubDir 规则被正确扫描,但不知何故,它没有正确绑定、定义或 bjam 通常用来制作 methods/rules "usable" 的任何东西。 正如您可能从使用的路径中看到的那样,我只引导了 b2,因此 boost 尚未正确安装。为了调试,我还稍微修补了它的源代码,这就是“Parsing file...”消息的来源。

我如何正确地 "inject" 来自 Jambase 文件的规则定义,以便在解析 Jamfile 时知道它们?

TL;DR:如果您的项目包含引用 Jambase 文件中的 SubDir 等定义的 Jamfile,请不要尝试使用bjam/b2。请改用 ft-jam

长答案 以及更多背景信息:

在工作中,我尝试构建一个旧软件包 (Ingres DBMS 10.1) 来源超过两周。它包含 JamfileJamrules 个文件 在它的树结构中,所以我得出结论,我必须使用 bjam/b2 让事情顺利进行。该项目的文档不够具体 关于这一点,事实证明。

我有一个主要问题,Jamfiles 会使用很多定义 来自“Jambase”文件,如“SubDir”a.s.o。每次我开始 构建,我会收到错误“unknown rule”,正如您在 问题。

我最终决定尝试使用较旧的 Jam 版本,瞧:有了 ft-jam v2.5.2 项目编译完美,事不宜迟。耶!

所以,现在基本上一切都很好,我可以使用 ft-jam 作为我的 目的。但我仍然想知道我是否也可以使用 bjam/b2 作为 编译。内部 Jambase 定义(“+” 文件)和 bjam 中的“-f”选项?它仅用于引导 b2 本身,或者我可以在 运行 b2 时使用它吗?如果是,我该如何激活它?

最后,我写信给 boost-build 邮件列表并得到以下答复:

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