github.com/lastbackend/toolkit@v0.0.0-20241020043710-cafa37b95aad/examples/http/scripts/generate.sh (about) 1 #!/bin/bash -e 2 3 SOURCE_PACKAGE=github.com/lastbackend/toolkit/examples/http 4 ROOT_DIR=$GOPATH/src/$SOURCE_PACKAGE 5 PROTO_DIR=$ROOT_DIR/apis 6 7 find $ROOT_DIR -type f \( -name '*.pb.go' -o -name '*.pb.*.go' \) -delete 8 9 mkdir -p $PROTO_DIR/google/api 10 mkdir -p $PROTO_DIR/validate 11 12 curl -s -f -o $PROTO_DIR/google/api/annotations.proto -L https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/annotations.proto || { echo "Error: Request failed"; exit 1; } 13 curl -s -f -o $PROTO_DIR/google/api/http.proto -L https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/http.proto || { echo "Error: Request failed"; exit 1; } 14 curl -s -f -o $PROTO_DIR/validate/validate.proto -L https://raw.githubusercontent.com/envoyproxy/protoc-gen-validate/main/validate/validate.proto || { echo "Error: Request failed"; exit 1; } 15 16 PROTOS=$(find $PROTO_DIR -type f -name '*.proto' | grep -v $PROTO_DIR/google/api | grep -v $PROTO_DIR/router/options) 17 18 # Generate for toolkit service 19 for PROTO in $PROTOS; do 20 protoc \ 21 -I. \ 22 -I$GOPATH/src \ 23 -I$PROTO_DIR \ 24 -I$(dirname $PROTO) \ 25 --validate_out=lang=go:$GOPATH/src \ 26 --go_out=:$GOPATH/src \ 27 --go-grpc_out=require_unimplemented_servers=false:$GOPATH/src \ 28 --toolkit_out=$GOPATH/src \ 29 $PROTO 30 done 31 32 rm -r $PROTO_DIR/google 33 rm -r $PROTO_DIR/validate 34 35 echo "Generation is ok"