rules_ocaml icon indicating copy to clipboard operation
rules_ocaml copied to clipboard

depend on cmi of singleton module

Open mobileink opened this issue 4 years ago • 1 comments

Use case: target depends on a cmi only (Tezos does this). If we have the mli file then we just use ocaml_signature. If we have a singleton (only the ml file), then we have two options:

a. compile the ml file and depend on the resulting cmi b. extract the mli from the ml and compile it.

Does it ever make sense to do b and not a? If so, we need to either enhance ocaml_signature to support this use case, or use a genrule to run ocamlc -i, or create a new rule. For now, assume option a will suffice.

mobileink avatar Nov 21 '21 13:11 mobileink

Either way, we need a way to express this dependency in the language. We can express a dependency on a module, but the ocaml_module rule always delivers both a cmi file and a .cmo (or .cmx, .o)

Scenario: some kind of processing tool takes .cmi files as input. To use it with a module dependency, we would need an intermediate step to extract the .cmi from the module output.

The brute force way would be to write a genrule and then use $(locations) to get the module output and write some shell code to find the cmi. Or something like that.

mobileink avatar Jul 01 '22 15:07 mobileink