| 
									
										
										
										
											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" | 
					
						
							| 
									
										
										
										
											2025-03-22 23:46:13 +08:00
										 |  |  | INSTALL_PKGS="github.com/bufbuild/buf/cmd/buf github.com/daixiang0/gci 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" | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											2025-03-22 23:46:13 +08:00
										 |  |  | 		gci write -s standard -s default -s "prefix(github.com/prometheus/prometheus)" . | 
					
						
							| 
									
										
										
										
											2017-07-06 20:38:40 +08:00
										 |  |  | 	popd | 
					
						
							|  |  |  | done | 
					
						
							| 
									
										
										
										
											2025-03-22 23:46:13 +08:00
										 |  |  | 
 |