0

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

SubDir TOP ;

exe main : main.cpp ;

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

但是当我尝试使用时SubDirbjam声称该规则是未知的......虽然我看到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文件和一个 simpleJamrules存在于我的玩具项目的顶层。当我省略“ -f Jambase”选项时,bjam会选择内部 Jambase 定义 (+),但会产生相同的结果……SubDir未知。

当我使用选项“ ”启动bjam-d 12时,我看到SubDir来自 的规则Jambase被正确扫描,但不知何故,它没有正确绑定、定义或bjam通常为使方法/规则“可用”所做的任何事情。正如您可能从使用的路径中看到的那样,我只是引导b2,所以boost还没有正确安装。为了调试,我还稍微修补了它的来源,这就是“ Parsing file...”消息的来源。

如何正确“注入”文件中的规则定义,以便在解析sJambase时知道它们?Jamfile

4

1 回答 1

0

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

带有更多背景信息的长答案:

在工作中,我试图在两周内从源代码构建一个旧的软件包(Ingres DBMS 10.1)。它在其树结构中包含JamfileJamrules文件,因此我得出结论,我必须使用bjam / b2 才能使事情顺利进行。事实证明,该项目的文档对这一点不够具体。

我有一个主要问题,Jamfiles会使用“ Jambase”文件中的大量定义,例如“ SubDir” aso 每次我开始构建时,我都会收到错误“ unknown rule”,正如您在问题中看到的那样。

我最终决定试一试较旧的 Jam 版本,瞧:使用 ft-jamv2.5.2,项目编译完美无瑕,没有任何麻烦。耶!

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

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

b2 不是 Perforce Jam 的直接替代品。使用 ft-jam 是正确的选择。

当前的 Jambase 仅用于引导 Boost.Build。较早版本的 b2 具有原始 Jambase 的副本,如果可执行文件的名称不是 b2/bjam,则该副本将被激活。尽管如此,我还是不推荐使用它,因为它完全没有维护。

链接到邮件线程

于 2018-10-05T10:18:56.430 回答