Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
65 changes: 65 additions & 0 deletions cmd/protoc-gen-pony/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# 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

v1 supports singular implicit-presence proto3 scalars (bool, int32/64,
uint32/64, sint32/64, fixed32/64, sfixed32/64, float, double, string,
bytes). Repeated fields, `optional` explicit presence, oneofs, maps,
embedded messages, and enums emit a `// TODO protoc-gen-pony` comment
until the corresponding codegen lands. Services (gRPC) are out of scope.

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