Conan build helper for projects that use Boost.Build
Add the necessary conan remote:
$ conan remote add grisumbras https://api.bintray.com/conan/grisumbras/conanInside 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 builderIf 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 notargetswere specified, builds default targets, but only ifconanfile.should_build == True. -
def install(self, force=False)Builds targetinstallifconanfile.should_install == Trueor ifforce == True. -
def test(self, force=False)Builds targettestifconanfile.should_test == Trueand if environment variableCONAN_RUN_TESTSis either not defined or is equalsTrue, or ifforce == True.
-
source_folderpath to folder that contains jamroot file. -
build_folderpath to folder that will contain build artifacts. -
package_folderpath to folder that will contain install artifacts. -
project_configpath to created project configuration file. -
executableBoost.Build executable that will be used. -
propertiesproperty set that will be used in build request. -
optionsa collection of CLI options.
Dmitry Arkhipov <grisumbras@gmail.com>
BSL-1.0 © 2018-2019 Dmitry Arkhipov