github.com/bakjos/protoreflect@v1.9.2/internal/testprotos/make_protos.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  set -e
     4  
     5  cd $(dirname $0)
     6  
     7  PROTOC_VERSION="3.12.0"
     8  PROTOC_OS="$(uname -s)"
     9  PROTOC_ARCH="$(uname -m)"
    10  case "${PROTOC_OS}" in
    11    Darwin) PROTOC_OS="osx" ;;
    12    Linux) PROTOC_OS="linux" ;;
    13    *)
    14      echo "Invalid value for uname -s: ${PROTOC_OS}" >&2
    15      exit 1
    16  esac
    17  
    18  PROTOC="./protoc/bin/protoc"
    19  
    20  if [[ "$(${PROTOC} --version 2>/dev/null)" != "libprotoc ${PROTOC_VERSION}" ]]; then
    21    rm -rf ./protoc
    22    mkdir -p protoc
    23    curl -L "https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-${PROTOC_OS}-${PROTOC_ARCH}.zip" > protoc/protoc.zip
    24    cd ./protoc && unzip protoc.zip && cd ..
    25  fi
    26  
    27  go install github.com/golang/protobuf/protoc-gen-go 
    28  
    29  # Output directory will effectively be GOPATH/src.
    30  outdir="../../../../.."
    31  ${PROTOC} "--go_out=plugins=grpc:$outdir" -I. *.proto
    32  ${PROTOC} "--go_out=plugins=grpc:$outdir" -I. nopkg/*.proto
    33  ${PROTOC} "--go_out=plugins=grpc:$outdir" -I. pkg/*.proto
    34  ${PROTOC} "--go_out=plugins=grpc:$outdir" -I. grpc/*.proto
    35  
    36  # And make descriptor set (with source info) for several files
    37  ${PROTOC} --descriptor_set_out=./desc_test1.protoset --include_source_info --include_imports -I. desc_test1.proto
    38  ${PROTOC} --descriptor_set_out=./desc_test_comments.protoset --include_source_info --include_imports -I. desc_test_comments.proto
    39  ${PROTOC} --descriptor_set_out=./desc_test_complex.protoset -I. desc_test_complex.proto
    40  ${PROTOC} --descriptor_set_out=./desc_test_complex_source_info.protoset --include_source_info --include_imports -I. desc_test_complex.proto
    41  ${PROTOC} --descriptor_set_out=./descriptor.protoset --include_source_info --include_imports -I./protoc/include/ google/protobuf/descriptor.proto
    42  ${PROTOC} --descriptor_set_out=./duration.protoset -I./protoc/include/ google/protobuf/duration.proto
    43  
    44  # We are currently pinning an earlier version of Go protobuf runtime, and thus of protoc-gen-go.
    45  # So it doesn't support proto3 optional fields yet. So we only create a descriptor for these, just
    46  # for testing proto3 optional support in the desc and desc/protoparse packages.
    47  ${PROTOC} --descriptor_set_out=./proto3_optional/desc_test_proto3_optional.protoset --include_source_info --include_imports -I. proto3_optional/desc_test_proto3_optional.proto
    48