How is macros or metaprogramming or anything that fills a similar role?

Not great, not terrible; the language supports annotations which mean nothing to the compiler but which pre-processors can take advantage of, and there is a framework called ppx which you can use to write your own preprocessor. There exist many pre-processors to do things like add inline tests, generate getter/setter/pretty-printing functions, and so on. Here is an example:

https://github.com/ocaml-ppx/ppx_deriving