All questions, suggestions and corrections are welcome, also for Meta’s OCaml scrips.
Why Buck 2 and not Bazel?
First: I have never tried Bazel (or the OCaml support), so I cannot say anything about it.
I’ve chosen Buck 2 because OCaml support is included by Facebook itself, the Prelude contains all language rules of Buck 2, there are no “build in” and “external” languages as with Bazel. Buck 2 is written in Rust (which I use, so no extra tooling needed to build it), Bazel in Java. And Bazel is by Google.
But I would just look at the support of each for the languages you want to/need to/must use.
Yes, this is a good idea.
The official OCaml examples (which do not use Opam packages/the ocaml-scripts) which this talk is about are located in the Buck 2 repository, in the examples subdirectory OCaml examples.
If you are just building OCaml locally: not much, you mainly lose the hidden magic Dune does (for example with modules, PPX, inline test runners, …) - if this is an advantage or disadvantage of Buck 2, you must decide for yourself ;). And if you do not use Dune, you need a .merlin file for your project’s sources, for Merlin and/or the OCaml LSP: Project configuration · ocaml/merlin Wiki · GitHub
The main advantages of Buck 2: support for many (not as much out of the box yet as Bazel) languages and distributed builds. I’m (officially mainly a C and C++ developer, and have used Makefiles (POSIX, BSD, GNU, NMake), Autoconf/Automake, IMake, CMake, QMake and some others I’ve forgotten about. I also have a bit of Typescript for some Websites and Rust and Python to build.
All supported languages (everybody can add language support there) are in the Buck 2 Prelude
That’s not a stupid question at all. You can combine them all in a single BUCK file (using the correct relative paths), I’ve spread them over the directories to make it easier to see what each file does.
There is also no need to separate the programming languages, you can build more than one language in a single BUCK file.
@Release-Candidate I tried to create the third party switch in basic-example repo (I imported all the scripts from ocaml-scripts) and initially I got a list of warnings
Running script /home/sk/ocaml-projects/boring_script/OCaml-Buck-2-Examples/basic_example/rules.py...
WARNING:root:Could not find file: /home/sk/ocaml-projects/boring_script/OCaml-Buck-2-Examples/basic_example/third-party/_opam/lib/ocaml/compiler-libs/libcomprmarsh.a
WARNING:root:Could not find file: /home/sk/ocaml-projects/boring_script/OCaml-Buck-2-Examples/basic_example/third-party/_opam/lib/ocaml/compiler-libs/libzstd.a
WARNING:root:Could not find file: /home/sk/ocaml-projects/boring_script/OCaml-Buck-2-Examples/basic_example/third-party/_opam/lib/ocaml/runtime_events/libcamlruntime_eventsnat.a
WARNING:root:Could not find file: /home/sk/ocaml-projects/boring_script/OCaml-Buck-2-Examples/basic_example/third-party/_opam/lib/ocaml/runtime_events/libcamlruntime_eventsbyt.a
WARNING:root:Could not find file: /home/sk/ocaml-projects/boring_script/OCaml-Buck-2-Examples/basic_example/third-party/_opam/lib/ocaml/str/libcamlstrnat.a
WARNING:root:Could not find file: /home/sk/ocaml-projects/boring_script/OCaml-Buck-2-Examples/basic_example/third-party/_opam/lib/ocaml/str/libcamlstrbyt.a
WARNING:root:Could not find file: /home/sk/ocaml-projects/boring_script/OCaml-Buck-2-Examples/basic_example/third-party/_opam/lib/ocaml/threads/libthreadsnat.a
WARNING:root:Could not find file: /home/sk/ocaml-projects/boring_script/OCaml-Buck-2-Examples/basic_example/third-party/_opam/lib/ocaml/threads/libthreads.a
WARNING:root:Could not find file: /home/sk/ocaml-projects/boring_script/OCaml-Buck-2-Examples/basic_example/third-party/_opam/lib/ocaml/unix/libunixnat.a
WARNING:root:Could not find file: /home/sk/ocaml-projects/boring_script/OCaml-Buck-2-Examples/basic_example/third-party/_opam/lib/ocaml/unix/libunixbyt.a