Skip to content

Commit f9348d1

Browse files
Merge pull request #350 from shelter2759/use-buf
multi: migrate protoc to buf
2 parents 7bf35d8 + 711843e commit f9348d1

File tree

9 files changed

+471
-450
lines changed

9 files changed

+471
-450
lines changed

.devcontainer/devcontainer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
"ghcr.io/devcontainers/features/nix:1": {},
88
"ghcr.io/devcontainers-contrib/features/direnv:1": {}
99
},
10-
"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.
10+
"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.
1111
"customizations": {
1212
"vscode": {
1313
"extensions": [
1414
"jnoortheen.nix-ide",
15-
"mkhl.direnv"
15+
"mkhl.direnv",
16+
"bufbuild.vscode-buf"
1617
]
1718
}
1819
},
@@ -22,4 +23,4 @@
2223
"GOROOT": "",
2324
"CACHIX_AUTH_TOKEN": "eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJmNTg3ZjViZi00ZWJiLTRhYmQtYmYzOC0xYzFlZGE3ZGE4NTQiLCJzY29wZXMiOiJjYWNoZSJ9.pzmsXqBwHFAExdVFhbdrtN1mpc4h3U3JWnej7PC-NAA"
2425
}
25-
}
26+
}

buf.gen.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: v2
2+
plugins:
3+
- local: protoc-gen-go
4+
out: peerswaprpc
5+
opt:
6+
- paths=source_relative
7+
8+
- local: protoc-gen-go-grpc
9+
out: peerswaprpc
10+
opt:
11+
- paths=source_relative
12+
13+
- local: protoc-gen-grpc-gateway
14+
out: peerswaprpc
15+
opt:
16+
- logtostderr=true
17+
- paths=source_relative
18+
- grpc_api_configuration=peerswaprpc/peerswap.yaml
19+
20+
- local: protoc-gen-openapiv2
21+
out: peerswaprpc
22+
opt:
23+
- logtostderr=true
24+
- grpc_api_configuration=peerswaprpc/peerswap.yaml

buf.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# For details on buf.yaml configuration, visit https://buf.build/docs/configuration/v2/buf-yaml
2+
version: v2
3+
modules:
4+
- path: peerswaprpc
5+
6+
# lint:
7+
# use:
8+
# - STANDARD
9+
# breaking:
10+
# use:
11+
# - FILE

peerswaprpc/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ RUN cd /tmp \
2121
&& go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@${PROTOC_GEN_GO_GRPC_VERSION} \
2222
&& go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@${GRPC_GATEWAY_VERSION} \
2323
&& go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@${GRPC_GATEWAY_VERSION} \
24+
&& GOBIN=/usr/local/bin go install github.com/bufbuild/buf/cmd/buf@v1.50.0 \
2425
&& chmod -R 777 /tmp/build/
2526

2627
WORKDIR /build
2728

28-
CMD ["/bin/sh", "/build/peerswaprpc/gen_protos.sh"]
29+
ENV BUF_CACHE_DIR=/tmp/.cache
30+
31+
CMD ["sh", "-c", "buf generate"]

peerswaprpc/Makefile

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,18 @@
11
DIR=peerswaprpc
22

3-
PROTOC_OPTS= \
4-
-I. \
5-
--go_out=paths=source_relative:. \
6-
--go-grpc_out=paths=source_relative:. \
7-
--grpc-gateway_out=. \
8-
--grpc-gateway_opt logtostderr=true \
9-
--grpc-gateway_opt paths=source_relative \
10-
--grpc-gateway_opt grpc_api_configuration=${DIR}/peerswap.yaml
11-
12-
PROTOC_SWAGGER_OPTS= \
13-
--openapiv2_out=. \
14-
--openapiv2_opt logtostderr=true \
15-
--openapiv2_opt grpc_api_configuration=${DIR}/peerswap.yaml
16-
173
STUBS= \
184
${DIR}/peerswaprpc_grpc.pb.go \
195
${DIR}/peerswaprpc.pb.go \
20-
${DIR}/peerswaprpc.pb.gw.go
6+
${DIR}/peerswaprpc.pb.gw.go \
7+
${DIR}/peerswaprpc.swagger.json
218

22-
all-rpc: ${STUBS} ${DIR}/peerswaprpc.swagger.json
9+
all-rpc:
10+
buf generate
2311

2412
clean-rpc:
25-
rm -f ${STUBS} ${DIR}/peerswaprpc.swagger.json
26-
27-
${DIR}/peerswaprpc.swagger.json:
28-
protoc ${PROTOC_SWAGGER_OPTS} ${DIR}/peerswaprpc.proto
29-
30-
${DIR}/peerswaprpc_grpc.pb.go ${DIR}/peerswaprpc.pb.go ${DIR}/peerswaprpc.pb.gw.go: ${DIR}/peerswaprpc.proto
31-
protoc ${PROTOC_OPTS} ${DIR}/peerswaprpc.proto
32-
PHONY:
13+
rm -f ${STUBS}
3314

3415
.PHONY: all-rpc-docker
3516
all-rpc-docker:
36-
./gen_protos_docker.sh
17+
./gen_protos_docker.sh
18+

0 commit comments

Comments
 (0)