Conan build helper for projects that use Boost.Build
Add the necessary conan remote:
$ conan remote add grisumbras https://api.bintray.com/conan/grisumbras/conan
Inside your conanfile.py
use python_requires
to install and import the
package:
class MyConan(ConanFile):
python_requires = "b2-helper/[>=0.8.0]@grisumbras/stable"
The simplest way to use the package is via the mixin class:
class MyConan(ConanFile):
python_requires = "b2-helper/[>=0.8.0]@grisumbras/stable"
python_requires_extend = "b2-helper.Mixin"
The mixin provides default implementations for methods build
, package
and test
. In order for it to work without any customization, project’s
jamroot file should be in conanfile.source_folder
and the project should
require no configuration beyond toolset initialization. If customization is
required, the ConanFile
subclass should override method b2_setup_builder
:
class MyConan(ConanFile):
python_requires_extend = "b2-helper.Mixin"
def b2_setup_builder(self, builder):
builder.source_folder = "src"
builder.build_folder = "build"
builder.options.debug_building = True
builder.properties.runtime_link = "static"
return builder
If you need to build specific targets, you can sepcify them via
b2_build_targets
. The value of the variable can be any collection or string
(in case you want to only build one target):
class MyConan1(ConanFile):
python_requires_extend = "b2-helper.Mixin"
b2_build_targets = "foo"
class MyConan2(ConanFile):
python_requires_extend = "b2-helper.Mixin"
b2_build_targets = "foo", "bar"
The helper can be used by itself pretty much the same way as standard build helpers.
class MyConan(ConanFile):
def build(self):
builder = b2.B2(self)
builder.source_folder = "src"
builder.build_folder = "build"
builder.options.debug_building = True
builder.properties.runtime_link = "static"
builder.configure()
builder.build()
builder.test()
builder.install()
By default the helper creates a project-config.jam
which initializes modules
and loads files created by generator. Some projects prefer to create that file
themselves via a bootstrap script. In order to support such use cases the
helper provides mutable property project_config
and an attribute include
that holds a list of jamfiles to be included by configuration module.
class MyConan(ConanFile):
def b2_setup_builder(self, builder)
builder.project_config = os.path.join(self.build_folder, "helper.jam")
builder.include.append(self.bootstrap())
return builder
-
def init(self, conanfile, no_defaults=False)
Constructor. Ifno_defaults == True
, does not fill default property set with default properties. -
def using(self, name, *args, **kw)
Initializes a toolset module.self.using(("a", "b"), "c", {"d": "e"})
is equivalent to puttingusing a : b : c : <d>"e" ;
in Boost.Build configuration. -
def configure(self)
Creates project configuration file inself.project_config
. -
def build(self, *targets)
Builds targetstargets
. If notargets
were specified, builds default targets, but only ifconanfile.should_build == True
. -
def install(self, force=False)
Builds targetinstall
ifconanfile.should_install == True
or ifforce == True
. -
def test(self, force=False)
Builds targettest
ifconanfile.should_test == True
and if environment variableCONAN_RUN_TESTS
is either not defined or is equalsTrue
, or ifforce == True
.
-
source_folder
path to folder that contains jamroot file. -
build_folder
path to folder that will contain build artifacts. -
package_folder
path to folder that will contain install artifacts. -
project_config
path to created project configuration file. -
executable
Boost.Build executable that will be used. -
properties
property set that will be used in build request. -
options
a collection of CLI options.
Dmitry Arkhipov <grisumbras@gmail.com>
BSL-1.0 © 2018-2019 Dmitry Arkhipov