Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to set custom boost defines #227

Open
eklitzke opened this issue Oct 19, 2021 · 1 comment
Open

Provide a way to set custom boost defines #227

eklitzke opened this issue Oct 19, 2021 · 1 comment

Comments

@eklitzke
Copy link
Contributor

I want to have BOOST_ASIO_HAS_STD_INVOKE_RESULT and BOOST_BEAST_USE_STD_STRING_VIEW defined for asio/beast in my project, but this isn't suitable for everyone. Right now I just have a fork of this repo that defines these for those rules, but I would prefer if there was a way for me to define these for my project without maintaining a fork.

I was thinking about something like a new macro named boost_default_defines() that would mutate the default_defines in boost.bzl. However I think that in order for this to work it would require evaluating all the boost_library rules currently defined in BUILD.boost via a new macro call, since these rules are currently expanded eagerly before it's possible to change the default_defines. Or perhaps the new macro call would take a list of default defines, which is equivalent.

Mechanically this change is not too difficult but the diff would change most lines in BUILD.boost and also change how this repo is used, i.e. users would have to make a new macro call in order to define all the boost library rules. I'm far from a Bazel expert so perhaps there's a more clever way of accomplishing this goal without making such an invasive change.

@wijagels
Copy link
Contributor

wijagels commented Jan 5, 2022

A common practice is to check in a patch in your project. This should eliminate any need for a fork, but I do still think it's a little suboptimal. Mutating state in other bzl files is not possible, so any configurability would need to be done with something like this.

Here's an example of how you might implement the patch solution.

# rules_boost.patch
diff --git a/BUILD.boost b/BUILD.boost
index f927eec..0621f3a 100644
--- a/BUILD.boost
+++ b/BUILD.boost
@@ -496,6 +496,7 @@ boost_library(
     ],
     defines = [
         "BOOST_BEAST_SEPARATE_COMPILATION",
+        "BOOST_BEAST_USE_STD_STRING_VIEW",
     ],
     deps = [
         ":asio",
# WORKSPACE
http_archive(
    name = "com_github_nelhage_rules_boost",
    patch_args = ["-p1"],
    patches = ["//:rules_boost.patch"],
    # ...
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants