mransan / ocaml-protoc

A Protobuf Compiler for OCaml
https://mransan.github.io/ocaml-protoc/
MIT License
178 stars 33 forks source link

Package protobuf standard library within the generator #192

Open Lupus opened 1 year ago

Lupus commented 1 year ago

It seems protobuf tooling assumes that certain files are available to the compiler without being explicitly present in include paths, like google/protobuf/descriptor.proto.

ocaml-protoc is quite relaxed in terms of Proto options, but protoc plugin for Golang requires all options to be properly defined, and all required .proto files to be included in order to extend the options, but if I put the actual file in the include path - protobuf linters get confused about duplicate definitions.

Probably it makes sense to bundle this protobuf stdlib along with ocaml-protoc so that one could include google/protobuf/descriptor.proto without it being present explicitly on the file system. [ppx_blob] can be useful for this to lift the file contents during compilation to strings, and them some building some map out of those - at least that's what I'm going to do with my forked ocaml-protoc binary for now.

c-cube commented 4 months ago

There's no need for ppx_blob, a tiny bit of dune magic can suffice. But overall I think it's fine to do this!