...

Text file src/github.com/openshift/api/hack/update-protobuf.sh

Documentation: github.com/openshift/api/hack

     1#!/bin/bash
     2
     3source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
     4
     5[[ -n "${PROTO_OPTIONAL:-}" ]] && exit 0
     6
     7if [ -z "${GOPATH:-}" ]; then
     8  echo "Generating protobuf requires GOPATH to be set. Please set GOPATH.
     9To skip protobuf generation, set \$PROTO_OPTIONAL."
    10  exit 1
    11fi
    12
    13if [[ "$(protoc --version)" != "libprotoc 3."* ]]; then
    14  echo "Generating protobuf requires protoc 3.0.x. Please download and
    15install the platform appropriate Protobuf package for your OS:
    16
    17  https://github.com/google/protobuf/releases
    18
    19To skip protobuf generation, set \$PROTO_OPTIONAL."
    20  exit 1
    21fi
    22
    23# Build go-to-protobuf when it's not present and not overriden for a specific file.
    24if [ -z "${GO_TO_PROTOBUF:-}" ]; then
    25  ${TOOLS_MAKE} go-to-protobuf
    26  GO_TO_PROTOBUF="${TOOLS_OUTPUT}/go-to-protobuf"
    27fi
    28
    29# Build protoc-gen-gogo when it's not present and not overriden for a specific file.
    30if [ -z "${PROTOC_GEN_GOGO:-}" ]; then
    31  ${TOOLS_MAKE} protoc-gen-gogo
    32  PROTOC_GEN_GOGO="${TOOLS_OUTPUT}/protoc-gen-gogo"
    33fi
    34
    35# We need to make sure that protoc-gen-gogo is on the path for go-to-protobuf to run correctly.
    36protoc_bin_dir=$(dirname "${PROTOC_GEN_GOGO}")
    37
    38PATH="$PATH:${protoc_bin_dir}" "${GO_TO_PROTOBUF}" \
    39  --output-base="${GOPATH}/src" \
    40  --apimachinery-packages='-k8s.io/apimachinery/pkg/util/intstr,-k8s.io/apimachinery/pkg/api/resource,-k8s.io/apimachinery/pkg/runtime/schema,-k8s.io/apimachinery/pkg/runtime,-k8s.io/apimachinery/pkg/apis/meta/v1,-k8s.io/apimachinery/pkg/apis/meta/v1beta1,-k8s.io/api/core/v1,-k8s.io/api/rbac/v1' \
    41  --go-header-file=${SCRIPT_ROOT}/hack/empty.txt \
    42  --proto-import=${SCRIPT_ROOT}/third_party/protobuf \
    43  --proto-import=${SCRIPT_ROOT}/vendor \
    44  --proto-import=${SCRIPT_ROOT}/tools/vendor \
    45  --packages="${API_PACKAGES}"

View as plain text