go.ligato.io/vpp-agent/v3@v3.5.0/scripts/protoc_gen_go.sh (about) 1 #!/usr/bin/env bash 2 3 set -eo pipefail 4 5 fail() { 6 echo "$@" >&2 7 exit 1 8 } 9 10 if [ -z "${1}" ] || [ -z "${2}" ]; then 11 fail "usage: ${0} <proto_path> <protoc_gen_go_out> [protoc_gen_go_parameter]" 12 fi 13 14 protoc --version 15 16 PROTO_PATH="${1}" 17 PROTOC_GEN_GO_OUT="${2}" 18 PROTOC_GEN_GO_PARAMETER="${3}" 19 20 PROTOC_GEN_GO_ARGS="${PROTOC_GEN_GO_OUT}" 21 if [ -n "${PROTOC_GEN_GO_PARAMETER}" ]; then 22 PROTOC_GEN_GO_ARGS="${PROTOC_GEN_GO_PARAMETER}:${PROTOC_GEN_GO_ARGS}" 23 fi 24 25 mkdir -p "${PROTOC_GEN_GO_OUT}" 26 27 # all directories with proto files 28 protodirs=$(find "${PROTO_PATH}" -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq) 29 for dir in $protodirs; do 30 protofiles=$(find "${dir}" -maxdepth 1 -name '*.proto') 31 echo "$protofiles" 32 33 protoc --proto_path="${PROTO_PATH}" \ 34 --go_out="${PROTOC_GEN_GO_ARGS}" $protofiles \ 35 --go-grpc_out="${PROTOC_GEN_GO_ARGS}" $protofiles 36 done