2017-07-06 20:38:40 +08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# Generate all protobuf bindings.
|
|
|
|
# Run from repository root.
|
|
|
|
set -e
|
|
|
|
set -u
|
|
|
|
|
|
|
|
if ! [[ "$0" =~ "scripts/genproto.sh" ]]; then
|
|
|
|
echo "must be run from repository root"
|
|
|
|
exit 255
|
|
|
|
fi
|
|
|
|
|
2025-03-20 05:19:08 +08:00
|
|
|
pushd "internal/tools"
|
|
|
|
INSTALL_PKGS="github.com/bufbuild/buf/cmd/buf github.com/gogo/protobuf/protoc-gen-gogofast github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 golang.org/x/tools/cmd/goimports"
|
2019-01-15 22:32:05 +08:00
|
|
|
for pkg in ${INSTALL_PKGS}; do
|
2020-10-08 15:38:28 +08:00
|
|
|
GO111MODULE=on go install "$pkg"
|
2019-01-15 22:32:05 +08:00
|
|
|
done
|
2025-03-20 05:19:08 +08:00
|
|
|
popd
|
2017-07-06 20:38:40 +08:00
|
|
|
|
|
|
|
DIRS="prompb"
|
|
|
|
|
2019-01-15 22:32:05 +08:00
|
|
|
echo "generating code"
|
2017-07-06 20:38:40 +08:00
|
|
|
for dir in ${DIRS}; do
|
|
|
|
pushd ${dir}
|
2025-03-20 05:19:08 +08:00
|
|
|
buf generate
|
2024-02-06 16:34:03 +08:00
|
|
|
sed -i.bak -E 's/import _ \"github.com\/gogo\/protobuf\/gogoproto\"//g' *.pb.go
|
|
|
|
sed -i.bak -E 's/import _ \"google\/protobuf\"//g' *.pb.go
|
|
|
|
sed -i.bak -E 's/\t_ \"google\/protobuf\"//g' *.pb.go
|
|
|
|
sed -i.bak -E 's/golang\/protobuf\/descriptor/gogo\/protobuf\/protoc-gen-gogo\/descriptor/g' *.go
|
|
|
|
sed -i.bak -E 's/golang\/protobuf/gogo\/protobuf/g' *.go
|
2019-01-15 22:32:05 +08:00
|
|
|
rm -f -- *.bak
|
2021-06-28 18:16:06 +08:00
|
|
|
goimports -w ./*.go ./io/prometheus/client/*.go
|
2017-07-06 20:38:40 +08:00
|
|
|
popd
|
|
|
|
done
|