2
0
Fork 0
mirror of https://github.com/bazel-contrib/rules_foreign_cc synced 2024-12-04 08:02:31 +00:00
rules_foreign_cc/tools/build_defs/boost_build.bzl
irengrig b08610b154
Improve the boost rule including user_options attribute. (#177)
* Improve the boost rule including user_options attribute.

Then --with-<library> parameter can be passed to build only that library
Modify examples to demonstrate how to use it.
However, building examples takes too long time, so do not include them into the tests.
2018-12-07 14:30:41 +01:00

48 lines
1.3 KiB
Python

""" Rule for building Boost from sources. """
load(
"//tools/build_defs:framework.bzl",
"CC_EXTERNAL_RULE_ATTRIBUTES",
"cc_external_rule_impl",
"create_attrs",
)
load("//tools/build_defs:detect_root.bzl", "detect_root")
def _boost_build(ctx):
attrs = create_attrs(
ctx.attr,
configure_name = "BuildBoost",
create_configure_script = _create_configure_script,
make_commands = ["./b2 install {} --prefix=.".format(" ".join(ctx.attr.user_options))],
)
return cc_external_rule_impl(ctx, attrs)
def _create_configure_script(configureParameters):
ctx = configureParameters.ctx
root = detect_root(ctx.attr.lib_source)
return "\n".join([
"cd $INSTALLDIR",
"cp -R $EXT_BUILD_ROOT/{}/. .".format(root),
"./bootstrap.sh",
])
def _attrs():
attrs = dict(CC_EXTERNAL_RULE_ATTRIBUTES)
attrs.update({
# any additional flags to pass to b2
"user_options": attr.string_list(mandatory = False),
})
return attrs
""" Rule for building Boost. Invokes bootstrap.sh and then b2 install.
Attributes:
boost_srcs - target with the boost sources
"""
boost_build = rule(
attrs = _attrs(),
fragments = ["cpp"],
output_to_genfiles = True,
implementation = _boost_build,
)