nelhage / rules_boost

bazel build rules to use boost in bazel projects
Apache License 2.0
288 stars 232 forks source link

feat: port project to bzlmod. #553

Closed finn-ball closed 5 months ago

finn-ball commented 7 months ago

Ported to bzlmod: https://github.com/nelhage/rules_boost/issues/546

It is now possible to depend on this project with:

bazel_dep(name = "com_github_nelhage_rules_boost")
finn-ball commented 7 months ago

UPDATE: Solved.

Attempt3035 commented 5 months ago

Had an old go at this before, ditched as I was trying to add boost to bzlmod directly but ran out of time for the project. Reinstated in #562 as it might help! I also noted build errors with lzma on my machine, so using LZMA straight from bcr in the PR, but I have no idea if that will be backwards compatible with workspace (or if bazel just lets users use both alongside, if so, this should work fine as it stands!), if you have the time available @finn-ball to test then that PR should be good to go, even though I fully believe boost build rules should be natively rewritten for BCR in the long run, see here for work in progress

I'm using this on a mac with bazel 7 and bzlmod which is now default. I haven't tried with workspace or on many other systems just yet, testing needed! Let me know if there's anything further I can help with!

Attempt3035 commented 5 months ago

Ohhh I may have misunderstood your PR @finn-ball, you just upgraded the deps to BCR modules, rather than making this whole project bzlmod compatible? I like the dep upgrade, would be great if this PR could get finished off, would go nicely with #562 anyway!

finn-ball commented 5 months ago

I updated some dependencies to use bazel modules but also the changes were compatible for this to be used with BCR. I had some of my own internal bazel projects depend on this as a bazel module.

You can also see I updated the tests to use:

bazel_dep(name = "com_github_nelhage_rules_boost")
local_path_override(
    module_name = "com_github_nelhage_rules_boost",
    path = "..",
)

non_module_boost_repositories = use_extension("@com_github_nelhage_rules_boost//:boost/repositories.bzl", "non_module_dependencies")
use_repo(
    non_module_boost_repositories,
    "boost",
)

I couldn't reproduce the error in CI, so couldn't solve the error and no one else showed interest.

finn-ball commented 5 months ago

Rebased and updated. To be clear this port will be necessary as WORKSPACE becomes deprecated in favour of MODULE files @nelhage

finn-ball commented 5 months ago

Using the bazel_dep of zlib generates this error in CI which I could not reproduce locally:

external/com_github_nelhage_rules_boost~~non_module_dependencies~boost/libs/iostreams/src/zlib.cpp:20:10: error: use of private header from outside its module: 'zlib.h' [-Wprivate-header]
#include "zlib.h"   // Jean-loup Gailly's and Mark Adler's "zlib.h" header.
         ^
1 error generated.

If this is merged, an issue needs to be created to resolve this. I have commented out the use of the BCR zlib for now.

finn-ball commented 5 months ago

@nelhage - this now passes CI. Please feel free to merge.

Attempt3035 commented 5 months ago

Looks great, good job @finn-ball!🙌

finn-ball commented 5 months ago

Any thoughts @Vertexwahn ?

Vertexwahn commented 5 months ago

@finn-ball Once we merge this this the old approach of using WORKSPACEfiles will not working anymore - personally for me no problem ;) - @cpsauer Are you fine with moving over to Bzlmod and dropping the WORKSPACE approach?

finn-ball commented 5 months ago

You'll be forced to use bzlmod eventually as the WORKSPACE will be depreciated in the next major release iirc. With bazel 7, bzlmod is on by default.

Vertexwahn commented 5 months ago

@finn-ball Thanks for your contribution!