Skip to content

Commit

Permalink
multi: migrate protoc to buf
Browse files Browse the repository at this point in the history
  • Loading branch information
shelter2759 committed Feb 8, 2025
1 parent 7bf35d8 commit 98611af
Show file tree
Hide file tree
Showing 9 changed files with 1,018 additions and 1,709 deletions.
7 changes: 4 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
"ghcr.io/devcontainers/features/nix:1": {},
"ghcr.io/devcontainers-contrib/features/direnv:1": {}
},
"postCreateCommand": "echo 'experimental-features = nix-command flakes' | sudo tee -a /etc/nix/nix.conf > /dev/null && nix-env -iA nixpkgs.nixpkgs-fmt && nix-env -iA cachix -f https://cachix.org/api/v1/install", // Configure tool-specific properties.
"postCreateCommand": "echo 'experimental-features = nix-command flakes' | sudo tee -a /etc/nix/nix.conf > /dev/null && nix-env -iA nixpkgs.nixpkgs-fmt && nix-env -iA cachix -f https://cachix.org/api/v1/install && sudo chmod a+w /usr/local/bin/ && GOBIN=/usr/local/bin go install github.com/bufbuild/buf/cmd/buf@v1.50.0", // Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"jnoortheen.nix-ide",
"mkhl.direnv"
"mkhl.direnv",
"bufbuild.vscode-buf"
]
}
},
Expand All @@ -22,4 +23,4 @@
"GOROOT": "",
"CACHIX_AUTH_TOKEN": "eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJmNTg3ZjViZi00ZWJiLTRhYmQtYmYzOC0xYzFlZGE3ZGE4NTQiLCJzY29wZXMiOiJjYWNoZSJ9.pzmsXqBwHFAExdVFhbdrtN1mpc4h3U3JWnej7PC-NAA"
}
}
}
24 changes: 24 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: v2
plugins:
- local: protoc-gen-go
out: peerswaprpc
opt:
- paths=source_relative

- local: protoc-gen-go-grpc
out: peerswaprpc
opt:
- paths=source_relative

- local: protoc-gen-grpc-gateway
out: peerswaprpc
opt:
- logtostderr=true
- paths=source_relative
- grpc_api_configuration=peerswaprpc/peerswap.yaml

- local: protoc-gen-openapiv2
out: peerswaprpc
opt:
- logtostderr=true
- grpc_api_configuration=peerswaprpc/peerswap.yaml
11 changes: 11 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# For details on buf.yaml configuration, visit https://buf.build/docs/configuration/v2/buf-yaml
version: v2
modules:
- path: peerswaprpc

# lint:
# use:
# - STANDARD
# breaking:
# use:
# - FILE
2 changes: 1 addition & 1 deletion peerswaprpc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ RUN cd /tmp \

WORKDIR /build

CMD ["/bin/sh", "/build/peerswaprpc/gen_protos.sh"]
CMD ["buf", "generate"]
31 changes: 6 additions & 25 deletions peerswaprpc/Makefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,17 @@
DIR=peerswaprpc

PROTOC_OPTS= \
-I. \
--go_out=paths=source_relative:. \
--go-grpc_out=paths=source_relative:. \
--grpc-gateway_out=. \
--grpc-gateway_opt logtostderr=true \
--grpc-gateway_opt paths=source_relative \
--grpc-gateway_opt grpc_api_configuration=${DIR}/peerswap.yaml

PROTOC_SWAGGER_OPTS= \
--openapiv2_out=. \
--openapiv2_opt logtostderr=true \
--openapiv2_opt grpc_api_configuration=${DIR}/peerswap.yaml

STUBS= \
${DIR}/peerswaprpc_grpc.pb.go \
${DIR}/peerswaprpc.pb.go \
${DIR}/peerswaprpc.pb.gw.go
${DIR}/peerswaprpc.pb.gw.go \
${DIR}/peerswaprpc.swagger.json

all-rpc: ${STUBS} ${DIR}/peerswaprpc.swagger.json
all-rpc:
buf generate

clean-rpc:
rm -f ${STUBS} ${DIR}/peerswaprpc.swagger.json

${DIR}/peerswaprpc.swagger.json:
protoc ${PROTOC_SWAGGER_OPTS} ${DIR}/peerswaprpc.proto

${DIR}/peerswaprpc_grpc.pb.go ${DIR}/peerswaprpc.pb.go ${DIR}/peerswaprpc.pb.gw.go: ${DIR}/peerswaprpc.proto
protoc ${PROTOC_OPTS} ${DIR}/peerswaprpc.proto
PHONY:
rm -f ${STUBS}

.PHONY: all-rpc-docker
all-rpc-docker:
./gen_protos_docker.sh
${DIR}/gen_protos_docker.sh
Loading

0 comments on commit 98611af

Please sign in to comment.