Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/.release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
},
"cmd/protoc-gen-elixir-grpc": {
"component": "protoc-gen-elixir-grpc"
},
"cmd/protoc-gen-pony": {
"component": "protoc-gen-pony"
}
},
"plugins": [
Expand Down
3 changes: 2 additions & 1 deletion .github/.release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"cmd/protoc-gen-connect-go-servicestruct": "0.2.0",
"cmd/protoc-gen-elixir-grpc": "0.4.2"
"cmd/protoc-gen-elixir-grpc": "0.4.2",
"cmd/protoc-gen-pony": "0.0.1"
}
19 changes: 19 additions & 0 deletions .github/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@ builds:
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}

- id: protoc-gen-pony
main: ./cmd/protoc-gen-pony
binary: protoc-gen-pony
skip: '{{ ne .Env.BUILD_COMPONENT "protoc-gen-pony" }}'
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
goarch:
- amd64
- arm64
ldflags:
- -s -w
- -X main.version={{.Version}}
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}

archives:
- id: default
name_template: >-
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ jobs:

# Validate component is known
case "$COMPONENT" in
protoc-gen-elixir-grpc|protoc-gen-connect-go-servicestruct)
protoc-gen-elixir-grpc|protoc-gen-connect-go-servicestruct|protoc-gen-pony)
echo "Valid component: ${COMPONENT}"
;;
*)
echo "ERROR: Unknown component: ${COMPONENT}"
echo "Valid components: protoc-gen-elixir-grpc, protoc-gen-connect-go-servicestruct"
echo "Valid components: protoc-gen-elixir-grpc, protoc-gen-connect-go-servicestruct, protoc-gen-pony"
exit 1
;;
esac
Expand Down
11 changes: 7 additions & 4 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ tasks:

build-plugin:
desc: Build all protoc plugin binaries
cmds:
- echo "Building protoc plugin binaries..."
- go build -o protoc-gen-connect-go-servicestruct ./cmd/protoc-gen-connect-go-servicestruct
- go build -o protoc-gen-elixir-grpc ./cmd/protoc-gen-elixir-grpc
deps: [build-plugin-go, build-plugin-elixir, build-plugin-pony]

build-plugin-go:
desc: Build the Go Connect protoc plugin binary
Expand All @@ -77,6 +74,12 @@ tasks:
- echo "Building Elixir gRPC protoc plugin binary..."
- go build -o protoc-gen-elixir-grpc ./cmd/protoc-gen-elixir-grpc

build-plugin-pony:
desc: Build the Pony protoc plugin binary
cmds:
- echo "Building Pony protoc plugin binary..."
- go build -o protoc-gen-pony ./cmd/protoc-gen-pony

clean:
desc: Clean build artifacts and coverage files
cmds:
Expand Down
22 changes: 22 additions & 0 deletions cmd/protoc-gen-pony/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Changelog

## Unreleased

### Features

- All proto3 scalar types (bool, int32/64, uint32/64, sint32/64, fixed32/64, sfixed32/64, float, double, string, bytes)
- Enums: primitive per value, type alias union, `FromValue` dispatcher, `Raw` class for unknown values
- Singular and repeated embedded messages; sub-codec decode/encode
- Repeated scalar and enum fields (packed wire format)
- proto3 `optional` explicit presence (`(T | None)` type, match-on-None encode)
- Real `oneof` fields: wrapper class per member, union type alias, full decode/encode
- `map<K, V>` fields: scalar, enum, and message values; `use "collections"` auto-emitted
- Cross-directory `use` directives (relative paths, deduplicated per directory)
- Well-known types (`google/protobuf/timestamp.proto`, `duration.proto`, `any.proto`, `wrappers.proto`, `field_mask.proto`, `empty.proto`, etc.) generate as regular proto3 messages
- Generated file header includes minimum required `protobuf-pony` runtime version

### Known limitations

- `google/protobuf/struct.proto`, `type.proto`, `api.proto`, `descriptor.proto` emit `TODO` comments — circular or JSON-only semantics
- JSON-specific WKT encoding (Timestamp as RFC 3339, etc.) is out of scope
- Services (gRPC stubs) are not generated
79 changes: 79 additions & 0 deletions cmd/protoc-gen-pony/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# protoc-gen-pony

A Protobuf compiler plugin that generates Pony source code — `class val`
records plus sister `Codec` primitives that decode and encode against the
[`protobuf` Pony runtime library][runtime].

## Install

```bash
go install github.com/TrogonStack/protoc-gen/cmd/protoc-gen-pony@latest
```

## Usage

With `protoc`:

```bash
protoc --pony_out=gen path/to/file.proto
```

With [buf]:

```yaml
# buf.gen.yaml
version: v2
plugins:
- local: protoc-gen-pony
out: gen
```

## Output

For a `User` message in `acme/v1/user.proto`:

```protobuf
syntax = "proto3";
package acme.v1;

message User {
int32 id = 1;
string name = 2;
bool active = 3;
}
```

The plugin writes `gen/acme/v1/user.pony` with a `class val User` record and a
`primitive UserCodec` exposing `decode(reader: WireReader ref): (User val |
WireError)` and `encode(writer: WireWriter ref, msg: User val)`.

## Runtime requirement

Generated code calls into the Pony `protobuf` package — `WireReader`,
`WireWriter`, `Tag`, `Scalar`, `WireType`, `WireError`. See [the runtime
sources][runtime].

## Coverage

Supported (no `TODO` comments emitted):

- All proto3 scalar types — bool, int32/64, uint32/64, sint32/64,
fixed32/64, sfixed32/64, float, double, string, bytes
- Enums (primitives + type alias + `FromValue` dispatcher + `Raw` fallback)
- Singular and repeated embedded messages
- proto3 `optional` explicit presence (`(T | None)` type)
- Real `oneof` fields (wrapper class per member, union type alias)
- `map<K, V>` where V is a scalar, enum, or non-blocked message
- Cross-directory `use` directives (relative path, auto-deduped)
- Well-known types: Timestamp, Duration, Any, FieldMask, wrappers, Empty, etc.
generate as regular proto3 messages with no special treatment

**Known limitations:**

- `google/protobuf/struct.proto`, `type.proto`, `api.proto`, `descriptor.proto`
stay as `TODO` — circular or JSON-only types not representable in plain proto3
- JSON-specific WKT encoding (Timestamp as RFC 3339, etc.) is out of scope
- Services (gRPC stubs) are not generated

[buf]: https://buf.build
[runtime]: https://github.com/TrogonStack/protobuf-pony
Loading
Loading