github.com/livekit/protocol@v1.16.1-0.20240517185851-47e4c6bba773/bootstrap.sh (about)

     1  #!/bin/bash
     2  # Copyright 2023 LiveKit, Inc.
     3  #
     4  # Licensed under the Apache License, Version 2.0 (the "License");
     5  # you may not use this file except in compliance with the License.
     6  # You may obtain a copy of the License at
     7  #
     8  #     http://www.apache.org/licenses/LICENSE-2.0
     9  #
    10  # Unless required by applicable law or agreed to in writing, software
    11  # distributed under the License is distributed on an "AS IS" BASIS,
    12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  # See the License for the specific language governing permissions and
    14  # limitations under the License.
    15  
    16  
    17  if ! command -v protoc &> /dev/null
    18  then
    19    echo "protoc is required and not found. please install"
    20    exit 1
    21  fi
    22  
    23  if ! command -v mage &> /dev/null
    24  then
    25    pushd /tmp
    26    git clone https://github.com/magefile/mage
    27    cd mage
    28    go run bootstrap.go
    29    rm -rf /tmp/mage
    30    popd
    31  fi
    32  
    33  if ! command -v mage &> /dev/null
    34  then
    35    echo "Ensure `go env GOPATH`/bin is in your \$PATH"
    36    exit 1
    37  fi
    38  
    39  go mod download
    40  
    41  GO_VERSION=`go version | { read _ _ v _; echo ${v#go}; }`
    42  GO_TARGET_VERSION=1.17
    43  
    44  function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
    45  
    46  if [ $(version $GO_VERSION) -ge $(version $GO_TARGET_VERSION) ];
    47    then
    48      go install github.com/twitchtv/twirp/protoc-gen-twirp@v8.1.3
    49      go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31.0
    50      go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3
    51      go install github.com/livekit/psrpc/protoc-gen-psrpc@v0.5.1
    52    else
    53      go get -u github.com/twitchtv/twirp/protoc-gen-twirp@v8.1.3
    54      go get -u google.golang.org/protobuf/cmd/protoc-gen-go@v1.30.0
    55      go get -u google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
    56      go get -u github.com/livekit/psrpc/protoc-gen-psrpc@v0.3.1
    57  fi