The OBazl Toolsuite 3.0.0.beta.1 is now available.
The OBazl Toolsuite is a collection of rules & tools that support OCaml development using Bazel. To get started:
$ git clone https://github.com/obazl/demo_hello.git
$ cd demo_hello
$ bazel run bin:greetings
$ bazel test test
$ bazel run @utop
etc.
See The OBazl Book for more guidance.
Tested on MacOS and Linux (Ubuntu).
This version contains many improvements:
- Improved toolchain support. Select a compiler by passing e.g.
--tc=ocamlc
. - Seamless opam dependencies. The previous version required a preprocessing step (running
bazel run @coswitch
); this is no longer necessary. - Fine-grained dependencies. Depend directly on any module, whether it is in a library or not, and whether it is namespaced (``wrapped’') or not.
- Context-sensitive archiving. Archives are for distribution; internal dependencies do not need them. The
ocaml_library
rule will only construct an archive on demand. By default, an internal dependency on anocaml_library
target will not request archiving. This can be overridden. - Several examples of OBazl extensions: rules_ppx, rules_cppo, rules_ctypes, rules_menhir. These demonstrate the relative ease with which tools can be integrated into the Bazel environment.
- A new tool,
bazel run @obazl//new
that generates a project from a template. - Direct support for the tools in the standard SDK (ocamldebug, ocamlobjinfo, etc.) and for a subset of the OCaml Platform tools. For example:
$ bazel run @opam -- list
$ bazel run @ocaml
$ bazel run @utop
$ bazel run @dbg --@dbg//pgm=src:greetings
OBazl ensures that these commands will be invoked under the
correct switch, with correct paths (CAML_LD_LIBRARY_PATH etc.), insulated from environment variables.
Other tools are invoked by passing an option to an ordinary build command. For example:
$ bazel build lib/hello:Hello --config=modinfo
# runs ocamlobjinfo on the .cmo/.cmx output$ bazel build lib/hello:Hello --config=siginfo
# runs ocamlobjinfo on the .cmi output$ bazel build lib/hello:libFoo --config=archinfo
# runs ocamlobjinfo on the .cma/.cmxa output$ bazel build lib/hello:Hello --config=gensig
# runsocamlopt -i
on the .ml file to generate inteface code.
The documentation at The OBazl Book has been updated. It remains far from complete but it should be useful. In particular the OBazl Guide and the rules_ocaml
Reference Manual.
What’s missing?
- Support for opam publishing. I have successfully published an OBazl (Bazel) project to an opam switch, and used it in a dune-only project, but the code is still under development so I don’t have a demo.
- Support for
odoc
,ocamlformat
, and linting. Currently under development. - Windows support. The code is designed for portability but it will probably be a while before I can get to Windows.
- Automatic generation of BUILD.bazel files. I have a tool for this but it is outdated. Bringing it up-to-date is a high priority.
Support:
Cheers!
Gregg