github.com/tickoalcantara12/micro/v3@v3.0.0-20221007104245-9d75b9bcbab9/scripts/protoc.sh (about) 1 #!/bin/bash 2 3 set -e 4 5 function trap_handler { 6 MYSELF="$0" # equals to my script name 7 LASTLINE="$1" # argument 1: last line of error occurence 8 LASTERR="$2" # argument 2: error code of last command 9 echo "Error: line ${LASTLINE} - exit status of last command: ${LASTERR}" 10 exit $2 11 } 12 trap 'trap_handler ${LINENO} ${$?}' ERR 13 14 echo "Checking dependencies..." 15 which protoc 16 which protoc-gen-go 17 18 MOD=Mgithub.com/micro/go-micro/api/proto/api.proto=github.com/tickoalcantara12/micro/v3/proto/api 19 20 # modify the proto paths 21 function modify_paths() { 22 while read line; do 23 while read path; do 24 m=`echo $path | sed -e 's@go-micro/@go-micro/v2/@g' -e 's@/[a-z]*\.proto$@@g'` 25 MOD="${MOD},M${path}=$m" 26 done < <(grep "github.com/micro/go-micro/.*\.proto" $line | sed -e 's/^import //g' -e 's/;$//g' -e 's/"//g') 27 done < <(find . -name "*.proto") 28 } 29 30 modify_paths 31 echo Modifiers used: $MOD 32 ##Mgithub.com/micro/go-micro/api/proto/api.proto=github.com/tickoalcantara12/micro/v3/proto/api 33 34 echo "Building protobuf code..." 35 DIR=`pwd` 36 SRCDIR=$GOPATH/src 37 38 echo "DIR $DIR" 39 echo "SRCDIR $SRCDIR" 40 find $DIR/proto -name '*.pb.go' -exec rm {} \; 41 find $DIR/proto -name '*.micro.go' -exec rm {} \; 42 find $DIR/proto -name '*.proto' -exec echo {} \; 43 find $DIR/proto -name '*.proto' -exec protoc --proto_path=$SRCDIR --micro_out=${MOD}:${SRCDIR} --go_out=${MOD}:${SRCDIR} {} \; 44 #find $DIR/proto -name '*.proto' -exec protoc --proto_path=$SRCDIR --micro_out=${SRCDIR} --go_out=${SRCDIR} {} \; 45 #find $DIR/proto -name '*.proto' -exec protoc --proto_path=$SRCDIR --micro_out=${SRCDIR}:${MOD} --go_out=plugins=grpc:${SRCDIR} {} \; 46 47 echo "Complete"