Skip to content

Commit

Permalink
[new release] ocaml-protoc (4 packages) (3.0.0)
Browse files Browse the repository at this point in the history
CHANGES:

Major version that breaks code for every user. Sorry!

### Breaking

- Generated code now always fits into 2 files: code
    for `foo.proto` is produced in `foo.ml` and `foo.mli`.
    This follows a fairly large internal refactor that enables
    a plugin architecture internally (which facilitated codegen for
    services).
    All encoder/decoder functions also have a new name now,
    so that they don't collide inside the same file.
- CLI flags now use `--this-style` rather than `-this-style`
- Bump minimal OCaml version to 4.08

### Performance

- encode probotufs backward, which means we can write directly
    into a single buffer (which is not possible in a forward mode
    because sub-messages require an unknown amount of prefix space
    to write their size as a varint)
- add C stubs for pbrt
- use Bytes functions to read/write fixed size integers
- inlining annotations
- more benchmarks, helping optimization overall
- reduce allocations drastically, by having the generated code
    create fewer closures

### Services

- add `pbrt_services` runtime library
- generate code for `service` statements. This is a big feature
    for users who want to implement RPC systems using protobuf.
    The generated code is agnostic to whatever RPC implementation
    will use it, it only packs together RPC method names and path
    with the relevant encoders/decoders. Services require
    both JSON and binary encoders/decoders to be present.

### JSON

- migrate `pbrt_yojson` into the main ocaml-protoc repo
- JSON runtime support for empty messages
- Add support for bytes in JSON encoding
- Add support for encoding and decoding maps in JSON

### Other features and fixes

- add `--make` flag to generate `make` functions that take fewer
    optional arguments. This helps preventing the user from
    forgetting important arguments when they're encoding to protobuf.
    Arguments actually marked as `optional` in the .proto file
    are still optional.
- Support maps/lists in options
- add Pbrt.Decoder.of_substring
- Allow options to be named like `(validate.rules).message.required`
- support code generation for empty messages
- Empty proto file is a valid proto as well

### Testing

- expect-style tests for parser
- Tests for option parsing
- Test demonstrating parse error printing
  • Loading branch information
c-cube committed Nov 30, 2023
1 parent aa99833 commit 70bda27
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 0 deletions.
40 changes: 40 additions & 0 deletions packages/ocaml-protoc/ocaml-protoc.3.0.0/opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
opam-version: "2.0"
synopsis: "Pure OCaml compiler for .proto files"
maintainer: ["Maxime Ransan <maxime.ransan@gmail.com>" "Simon Cruanes"]
authors: ["Maxime Ransan <maxime.ransan@gmail.com>" "Simon Cruanes"]
license: "MIT"
tags: ["protoc" "protobuf" "codegen"]
homepage: "https://github.com/mransan/ocaml-protoc"
bug-reports: "https://github.com/mransan/ocaml-protoc/issues"
depends: [
"dune" {>= "2.0"}
"odoc" {with-doc}
"pbrt" {= version}
"pbrt_yojson" {= version & with-test}
"pbrt_services" {= version & with-test}
"ocaml" {>= "4.08"}
]
build: [
["dune" "subst"] {pinned}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
dev-repo: "git+https://github.com/mransan/ocaml-protoc.git"
url {
src:
"https://github.com/mransan/ocaml-protoc/releases/download/v3.0.0/ocaml-protoc-3.0.0.tbz"
checksum: [
"sha256=33dbbca37c474fe7e6e15fc10fdd86df6c7b09bb4d4a319c93c22d77ef56ea8e"
"sha512=ba661523c7de71a641fff827c0b58a12a4aaf4842e59dbec6111d536ecf469a560e131615fea31998aab3b8cf8a026bfea1409bef9e91da37df97a74fa236093"
]
}
x-commit-hash: "ea2cfd55bece1ca76c01c571add06fa7db458627"
38 changes: 38 additions & 0 deletions packages/pbrt/pbrt.3.0.0/opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
opam-version: "2.0"
synopsis: "Runtime library for Protobuf tooling"
maintainer: ["Maxime Ransan <maxime.ransan@gmail.com>" "Simon Cruanes"]
authors: ["Maxime Ransan <maxime.ransan@gmail.com>" "Simon Cruanes"]
license: "MIT"
tags: ["protobuf" "encode" "decode"]
homepage: "https://github.com/mransan/ocaml-protoc"
bug-reports: "https://github.com/mransan/ocaml-protoc/issues"
depends: [
"dune" {>= "2.0"}
"stdlib-shims"
"odoc" {with-doc}
"ocaml" {>= "4.08"}
]
build: [
["dune" "subst"] {pinned}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
dev-repo: "git+https://github.com/mransan/ocaml-protoc.git"
url {
src:
"https://github.com/mransan/ocaml-protoc/releases/download/v3.0.0/ocaml-protoc-3.0.0.tbz"
checksum: [
"sha256=33dbbca37c474fe7e6e15fc10fdd86df6c7b09bb4d4a319c93c22d77ef56ea8e"
"sha512=ba661523c7de71a641fff827c0b58a12a4aaf4842e59dbec6111d536ecf469a560e131615fea31998aab3b8cf8a026bfea1409bef9e91da37df97a74fa236093"
]
}
x-commit-hash: "ea2cfd55bece1ca76c01c571add06fa7db458627"
38 changes: 38 additions & 0 deletions packages/pbrt_services/pbrt_services.3.0.0/opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
opam-version: "2.0"
synopsis: "Runtime library for ocaml-protoc to support RPC services"
maintainer: ["Maxime Ransan <maxime.ransan@gmail.com>" "Simon Cruanes"]
authors: ["Maxime Ransan <maxime.ransan@gmail.com>" "Simon Cruanes"]
license: "MIT"
tags: ["protobuf" "encode" "decode" "services" "rpc"]
homepage: "https://github.com/mransan/ocaml-protoc"
bug-reports: "https://github.com/mransan/ocaml-protoc/issues"
depends: [
"dune" {>= "2.0"}
"ocaml" {>= "4.08"}
"pbrt" {= version}
"pbrt_yojson" {= version}
]
build: [
["dune" "subst"] {pinned}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
dev-repo: "git+https://github.com/mransan/ocaml-protoc.git"
url {
src:
"https://github.com/mransan/ocaml-protoc/releases/download/v3.0.0/ocaml-protoc-3.0.0.tbz"
checksum: [
"sha256=33dbbca37c474fe7e6e15fc10fdd86df6c7b09bb4d4a319c93c22d77ef56ea8e"
"sha512=ba661523c7de71a641fff827c0b58a12a4aaf4842e59dbec6111d536ecf469a560e131615fea31998aab3b8cf8a026bfea1409bef9e91da37df97a74fa236093"
]
}
x-commit-hash: "ea2cfd55bece1ca76c01c571add06fa7db458627"
40 changes: 40 additions & 0 deletions packages/pbrt_yojson/pbrt_yojson.3.0.0/opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
opam-version: "2.0"
synopsis:
"Runtime library for ocaml-protoc to support JSON encoding/decoding"
maintainer: ["Maxime Ransan <maxime.ransan@gmail.com>" "Simon Cruanes"]
authors: ["Maxime Ransan <maxime.ransan@gmail.com>" "Simon Cruanes"]
license: "MIT"
tags: ["protobuf" "encode" "decode"]
homepage: "https://github.com/mransan/ocaml-protoc"
bug-reports: "https://github.com/mransan/ocaml-protoc/issues"
depends: [
"dune" {>= "2.0"}
"ocaml" {>= "4.08"}
"odoc" {with-doc}
"yojson" {>= "1.6"}
"base64" {>= "2.0"}
]
build: [
["dune" "subst"] {pinned}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
dev-repo: "git+https://github.com/mransan/ocaml-protoc.git"
url {
src:
"https://github.com/mransan/ocaml-protoc/releases/download/v3.0.0/ocaml-protoc-3.0.0.tbz"
checksum: [
"sha256=33dbbca37c474fe7e6e15fc10fdd86df6c7b09bb4d4a319c93c22d77ef56ea8e"
"sha512=ba661523c7de71a641fff827c0b58a12a4aaf4842e59dbec6111d536ecf469a560e131615fea31998aab3b8cf8a026bfea1409bef9e91da37df97a74fa236093"
]
}
x-commit-hash: "ea2cfd55bece1ca76c01c571add06fa7db458627"

0 comments on commit 70bda27

Please # to comment.