Gabriel Devillers
Gabriel Devillers

Reputation: 4032

No builtin modules when calling b2 on a file with -f

Given the file test.jam:

import path ;

Running it with b2 -f test.jam gives:

test.jam:1: in module scope
ERROR: rule "import" unknown in root module.

even though path is one of the builtin modules.

How can I import builtin modules when calling b2 with -f ?

b2 --help-options says (extract):

-fx; Read 'x' as the Jamfile for building instead of searching for the B2 system.

I know that -f is not the standard way to call b2, but I want to write a tool that fetches b2 variables values and would like to avoid having to create a specific file tree for that (the tool should be able to run in a directory that already has a jamfile).

Upvotes: 0

Views: 42

Answers (1)

Gabriel Devillers
Gabriel Devillers

Reputation: 4032

It seems that -f does not bootstrap and that you have to explicitely bootstrap.

Change test.jam to:

# Manually bootstrap to get access to builtin modules
# apparently this is needed to use this file with `b2 -f <file>`
.bootstrap-file = "$(BOOST_ROOT)/tools/build/src/bootstrap.jam" ;
include "$(.bootstrap-file)" ;

import path ;

Upvotes: 0

Related Questions