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

I have the print functions into a separate print.ml file. How do I get Dune to build a .cmo from that? This is what my Dune file looks like now.

(alias
 (name default)
 (deps phoebe.bc)
)

(executable
 (name phoebe)
 (libraries unix)
 (modules utility error ast symbol verilog parse grammar lex phoebe)
 (modes (byte exe))
)

(menhir
 (modules grammar)
)
  
(ocamllex lex)

(install
 (section bin)
 (files (phoebe.bc as phoebe))
)
1 Like