What Dune stanzas let me create a .cmo?

How do I use Dune to create the .cmo of a print function for ocamldebug that I can load with load_printer? What stanzas do I need?

If your printers are defined as part of your program, they should be built somewhere inside _build. I’ve done something like that in the past:

load_printer "_build/install/default/lib/foo.cma"

A mechanism similar to findlib’s #require would be useful but I don’t think it exists.

If your printers are defined in a separate library, something like that should build them:

dune build _build/install/default/lib/foo.cma