Skip to content

bazel build rules to use boost in bazel projects

License

Notifications You must be signed in to change notification settings

asa/rules_boost

This branch is 73 commits behind nelhage/rules_boost:master.

Folders and files

NameName
Last commit message
Last commit date
Nov 15, 2023
Dec 23, 2023
Feb 28, 2024
Aug 13, 2022
Dec 23, 2023
Feb 1, 2023
Aug 13, 2022
Sep 25, 2019
Aug 14, 2016
Nov 15, 2023
Aug 13, 2022
Jan 12, 2024
Mar 17, 2023
Nov 9, 2021
Apr 4, 2023
Apr 4, 2023
Apr 4, 2023
Apr 2, 2023
Apr 4, 2023
Apr 4, 2023
Sep 25, 2019
Dec 23, 2023
Feb 5, 2024
Apr 22, 2023
Mar 17, 2023
Jan 13, 2024

Repository files navigation

rules_boost -- Bazel build rules for Boost

Copy this into your Bazel WORKSPACE file to add this repo as an external dependency, making sure to update to the latest commit per the instructions below.

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# Boost
# Famous C++ library that has given rise to many new additions to the C++ Standard Library
# Makes @boost available for use: For example, add `@boost//:algorithm` to your deps.
# For more, see https://github.com/nelhage/rules_boost and https://www.boost.org
http_archive(
    name = "com_github_nelhage_rules_boost",

    # Replace the commit hash in both places (below) with the latest, rather than using the stale one here.
    # Even better, set up Renovate and let it do the work for you (see "Suggestion: Updates" in the README).
    url = "https://github.com/nelhage/rules_boost/archive/96e9b631f104b43a53c21c87b01ac538ad6f3b48.tar.gz",
    strip_prefix = "rules_boost-96e9b631f104b43a53c21c87b01ac538ad6f3b48",
    # When you first run this tool, it'll recommend a sha256 hash to put here with a message like: "DEBUG: Rule 'com_github_nelhage_rules_boost' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = ..."
)
load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps")
boost_deps()

You can now use libraries in deps through the @boost repository, for example @boost//:algorithm.

If you're using the Apple or Android-specific rules...

As with all platform-dependent C/C++ in Bazel, you'll need to use Bazel 7+ (and a similarly recent version of rules_apple) for per-platform configuration to work automatically out of the box. (Please file a PR to delete this section if Bazel 7 is now so old as to be standard.)

Suggestion: Updates

Improvements come frequently to the underlying libraries, including security patches, so we'd recommend keeping up-to-date.

We'd strongly recommend you set up Renovate (or similar) at some point to keep this dependency (and others) up-to-date by default. [We aren't affiliated with Renovate or anything, but we think it's awesome. It watches for new versions and sends you PRs for review or automated testing. It's free and easy to set up. It's been astoundingly useful in our codebase, and we've worked with the wonderful maintainer to make things great for Bazel use. And it's used in official Bazel repositories--and this one!]

If not now, maybe come back to this step later, or watch this repo for updates. [Or hey, maybe give us a quick star, while you're thinking about watching.] Like Abseil, we live at head; the latest commit to the main branch is the commit you want. So don't rely on release notifications; use Renovate or poll manually for new commits.

Configuration of Sub-Libraries

ASIO

SSL Support

These rules implement support for Boost ASIO's SSL support. To use ASIO-SSL, you must depend on the "@boost//:asio_ssl" target, instead of "@boost//:asio". ASIO-SSL depends on OpenSSL; By default, rules_boost will download and build the latest BoringSSL commit; To use a different OpenSSL implementation, create a remote named openssl before calling boost_deps. This remote must make available OpenSSL's libssl at @openssl//:ssl.

io_uring support

To enable io_uring for asio, use --@boost//:asio_has_io_uring. Optionally, pass--@boost//:asio_disable_epoll to use io_uring for all operations.

Beast

Boost Beast uses beast::string_view for things like request/response headers, which by default is a type alias of boost::string_view. If you're using a C++17 compiler that supports std::string_view you can use --@boost//:beast_use_std_string_view to make beast::string_view instead be a type alias of std::string_view.


Based in part on rules from https://github.com/mzhaom/trunk.

About

bazel build rules to use boost in bazel projects

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 71.0%
  • C++ 18.8%
  • Starlark 9.0%
  • Shell 1.2%