2018-09-05 20:24:41 +00:00
|
|
|
""" 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",
|
2018-10-19 16:49:30 +00:00
|
|
|
create_configure_script = _create_configure_script,
|
2018-12-07 13:30:41 +00:00
|
|
|
make_commands = ["./b2 install {} --prefix=.".format(" ".join(ctx.attr.user_options))],
|
2018-09-05 20:24:41 +00:00
|
|
|
)
|
|
|
|
return cc_external_rule_impl(ctx, attrs)
|
|
|
|
|
2018-10-19 16:49:30 +00:00
|
|
|
def _create_configure_script(configureParameters):
|
|
|
|
ctx = configureParameters.ctx
|
2018-09-17 12:27:35 +00:00
|
|
|
root = detect_root(ctx.attr.lib_source)
|
|
|
|
|
|
|
|
return "\n".join([
|
|
|
|
"cd $INSTALLDIR",
|
2019-01-19 16:37:57 +00:00
|
|
|
"##copy_dir_contents_to_dir## $$EXT_BUILD_ROOT$$/{}/. .".format(root),
|
2019-05-06 08:30:14 +00:00
|
|
|
"./bootstrap.sh {}".format(" ".join(ctx.attr.bootstrap_options)),
|
2018-09-17 12:27:35 +00:00
|
|
|
])
|
|
|
|
|
2018-12-07 13:30:41 +00:00
|
|
|
def _attrs():
|
|
|
|
attrs = dict(CC_EXTERNAL_RULE_ATTRIBUTES)
|
|
|
|
attrs.update({
|
2019-02-14 10:05:10 +00:00
|
|
|
# any additional flags to pass to bootstrap.sh
|
|
|
|
"bootstrap_options": attr.string_list(mandatory = False),
|
2018-12-07 13:30:41 +00:00
|
|
|
# any additional flags to pass to b2
|
|
|
|
"user_options": attr.string_list(mandatory = False),
|
|
|
|
})
|
|
|
|
return attrs
|
|
|
|
|
2018-09-05 20:24:41 +00:00
|
|
|
""" Rule for building Boost. Invokes bootstrap.sh and then b2 install.
|
|
|
|
Attributes:
|
|
|
|
boost_srcs - target with the boost sources
|
|
|
|
"""
|
|
|
|
boost_build = rule(
|
2018-12-07 13:30:41 +00:00
|
|
|
attrs = _attrs(),
|
2018-09-05 20:24:41 +00:00
|
|
|
fragments = ["cpp"],
|
|
|
|
output_to_genfiles = True,
|
|
|
|
implementation = _boost_build,
|
2019-01-19 16:37:57 +00:00
|
|
|
toolchains = [
|
|
|
|
"@rules_foreign_cc//tools/build_defs/shell_toolchain/toolchains:shell_commands",
|
2019-05-15 12:43:13 +00:00
|
|
|
"@bazel_tools//tools/cpp:toolchain_type",
|
2019-01-19 16:37:57 +00:00
|
|
|
],
|
2018-09-05 20:24:41 +00:00
|
|
|
)
|