Version 2 of OBazl, a Bazel ruleset for building OCaml code, will soon be available. I’m letting you know early because I’ll be giving a presentation about the OBazl Toolsuite for the Bazel Exchange conference next Wed, 22 June, at 3:00 pm UDT (10:00 am CDT). It’s a virtual conference so you can tune in from anywhere. The talk will focus on some of the quirks of the OCaml build discipline and how I addressed them for the OBazl ruleset.
The tools are usable now, they’re just not yet properly documented and packaged, and in a few places there’s a little more work to be done on the code. Nonetheless there is quite a bit of documentation (CAVEAT: some of it is outdated), with more on the way soon, and there are lots of demos available. So if you’re interested in using Bazel to build your OCaml code I welcome you to take a look:
The OBazl Book
Twitter handle is @obazldev
I can see how a general-purpose build system with wide language support is attractive. Though, we’re not shopping for a build system, since we’ve just migrated from OMake to dune, but it’s an interesting topic.
Does OBazl handle the
-opaque flag, which allows not to rebuild dependencies when mli files did not change? For example, for our particular OMake build it was a challenge, and dune handles it transparently.
PS. The conference organizers have provided this discount token: BAZEL-GR-20
It should be good for 20% off, registration is at https://events.skillsmatter.com/bazelx2022
Yes, OBazl gives you pretty much complete control over that kind of stuff. I don’t have a test case where -opaque makes a difference, though; can you describe how you need to use it, or provide sample code? Is there a case where you want the build tool to infer that it is needed based on some criteria?
Regarding migration: in most cases it won’t be an either/or choice. OBazl and Dune can coexist, and before long I’ll have tooling to automatically convert dunefiles to bazel files. So I can imagine a situation where you write dunefiles for your OCaml code but use Bazel for all foreign code, and use OBazl to integrate. In other words, use Dune as a high-level language that you “transpile” to Starlark.
I took a closer look at -opaque and realized that I had not fully understood its implications. So I added support for it. Also wrote up some documentation for it at https://obazl.github.io/docs_obazl/rules-ocaml/user-guide/optimization . Feedback welcome.
Oh wow, I’ve been wishing for this (and not having the time to learn Bazel well enough to do it)) for a long, long, long, long time.
I’ll have to get it and try it!
I’m really excited to see this!
I’m hoping to use OCaml at Google one day, this is big step towards making that feasible.
I wished I could have used OCaml at Google… Is it looking even remotely possible now?