2021-03-12 16:54:14 +00:00
|
|
|
""" Rule for building Boost from sources. """
|
|
|
|
|
|
|
|
load("//foreign_cc/private:detect_root.bzl", "detect_root")
|
|
|
|
load(
|
|
|
|
"//foreign_cc/private:framework.bzl",
|
|
|
|
"CC_EXTERNAL_RULE_ATTRIBUTES",
|
|
|
|
"CC_EXTERNAL_RULE_FRAGMENTS",
|
|
|
|
"cc_external_rule_impl",
|
|
|
|
"create_attrs",
|
|
|
|
)
|
|
|
|
|
2021-03-17 13:42:44 +00:00
|
|
|
def _boost_build_impl(ctx):
|
2021-03-12 16:54:14 +00:00
|
|
|
attrs = create_attrs(
|
|
|
|
ctx.attr,
|
2021-03-17 13:42:44 +00:00
|
|
|
configure_name = "BoostBuild",
|
2021-03-12 16:54:14 +00:00
|
|
|
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)
|
|
|
|
|
2021-03-17 21:50:25 +00:00
|
|
|
return [
|
2021-03-12 16:54:14 +00:00
|
|
|
"cd $INSTALLDIR",
|
|
|
|
"##copy_dir_contents_to_dir## $$EXT_BUILD_ROOT$$/{}/. .".format(root),
|
2021-06-02 19:39:25 +00:00
|
|
|
"chmod -R +w .",
|
2021-03-12 16:54:14 +00:00
|
|
|
"./bootstrap.sh {}".format(" ".join(ctx.attr.bootstrap_options)),
|
2021-03-17 21:50:25 +00:00
|
|
|
]
|
2021-03-12 16:54:14 +00:00
|
|
|
|
|
|
|
def _attrs():
|
|
|
|
attrs = dict(CC_EXTERNAL_RULE_ATTRIBUTES)
|
2021-03-17 13:42:44 +00:00
|
|
|
attrs.pop("targets")
|
|
|
|
attrs.pop("make_commands")
|
2021-03-12 16:54:14 +00:00
|
|
|
attrs.update({
|
|
|
|
"bootstrap_options": attr.string_list(
|
|
|
|
doc = "any additional flags to pass to bootstrap.sh",
|
|
|
|
mandatory = False,
|
|
|
|
),
|
|
|
|
"user_options": attr.string_list(
|
|
|
|
doc = "any additional flags to pass to b2",
|
|
|
|
mandatory = False,
|
|
|
|
),
|
|
|
|
})
|
|
|
|
return attrs
|
|
|
|
|
|
|
|
boost_build = rule(
|
|
|
|
doc = "Rule for building Boost. Invokes bootstrap.sh and then b2 install.",
|
|
|
|
attrs = _attrs(),
|
|
|
|
fragments = CC_EXTERNAL_RULE_FRAGMENTS,
|
|
|
|
output_to_genfiles = True,
|
2021-03-17 13:42:44 +00:00
|
|
|
implementation = _boost_build_impl,
|
2021-03-12 16:54:14 +00:00
|
|
|
toolchains = [
|
2021-04-30 16:03:32 +00:00
|
|
|
"@rules_foreign_cc//foreign_cc/private/framework:shell_toolchain",
|
2021-03-12 16:54:14 +00:00
|
|
|
"@bazel_tools//tools/cpp:toolchain_type",
|
|
|
|
],
|
2021-04-19 15:01:50 +00:00
|
|
|
# TODO: Remove once https://github.com/bazelbuild/bazel/issues/11584 is closed and the min supported
|
|
|
|
# version is updated to a release of Bazel containing the new default for this setting.
|
|
|
|
incompatible_use_toolchain_transition = True,
|
2021-03-12 16:54:14 +00:00
|
|
|
)
|