I'm trying to use ocamlbuild to automatically invoke piqi to generate ocaml modules from protobuf definitions. This is a 2 step process where I have to go from a %.protobuf
file to a %.proto.piqi
and finally to %_piqi.ml
.
My rule for the first step looks as follows:
rule "piqi: .proto -> .piqi"
~dep:"%.proto"
~prod:"%.proto.piqi"
begin fun env build ->
Cmd (S [ A piqi ; A "of-proto"
; A "-I"; P protobuf_include
; P (env "%.proto") ]
)
end;
But this doesn't work because the %.proto.piqi
target is actually dependent on all the "*.proto" files in my source directory because the individual .proto
files import each other in the source. However, I'm not sure how to express this dependency between them in ocamlbuild. It would be enough if all of the proto files where copied over to _build
rather than just the one in ~dep