Skip to content

Commit

Permalink
Resolved comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aranjans committed Apr 10, 2024
1 parent 6a7183c commit 075201a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 35 deletions.
28 changes: 10 additions & 18 deletions scripts/protoc_installer.sh
Original file line number Diff line number Diff line change
@@ -1,40 +1,32 @@
#!/bin/bash
# Install protoc
echo "Installing protoc"
PROTOC_VERSION="25.2"
echo "Protobuf version: ${PROTOC_VERSION}"

# Function to download pre-built binaries for Linux
download_binary() {
echo "Attempting to download pre-built libprotoc ${PROTOC_VERSION} binary."

# Download URL (adjust if a newer release is available)
DOWNLOAD_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-$2-$1.zip"
echo "Download URL: ${DOWNLOAD_URL}"

# Download and unzip
curl -LO "$DOWNLOAD_URL"
echo "Downloaded"
INSTALL_DIR="${3:-/home/runner/go}"
INSTALL_DIR="${3:-${GOBIN:-${GOPATH:-$HOME/go}/bin}}"
unzip "protoc-${PROTOC_VERSION}-$2-$1.zip" -d $INSTALL_DIR
rm "protoc-${PROTOC_VERSION}-$2-$1.zip"
}

download_protoc() {
# Determine architecture
if [[ $(uname -m) == "x86_64" ]]; then
ARCH="x86_64"
elif [[ $(uname -m) == "aarch64" ]] || [[ $(uname -m) == "arm64" ]] ; then
ARCH="aarch_64"
else
echo "Unsupported architecture. Please consider manual installation."
return
fi
if [[ $(uname -m) == "x86_64" ]]; then
ARCH="x86_64"
elif [[ $(uname -m) == "aarch64" ]] || [[ $(uname -m) == "arm64" ]] ; then
ARCH="aarch_64"
else
die "Unsupported architecture. Please consider manual installation."
fi
# Detect the Operating System
OS=$(uname -s)
case "$OS" in
"Darwin") download_binary $ARCH "osx" "${WORKDIR:-.}";;
"Darwin") download_binary $ARCH "osx" "$1";;
"Linux") download_binary $ARCH "linux" $1;;
*) echo "Unsupported operating system. Please consider manual installation." ;;
*) echo "Unsupported operating system. Please consider manual installation." ;;
esac
}
12 changes: 1 addition & 11 deletions scripts/regenerate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@ curl --silent https://raw.githubusercontent.com/googleapis/googleapis/master/goo
source ./scripts/protoc_installer.sh
download_protoc $WORKDIR

export PATH="$PATH:$GOBIN"

PROTOC_PATH="/usr/local/bin"
if [[ ":$PATH:" != *":$PROTOC_PATH:"* ]]; then
export PATH="$PATH:$PROTOC_PATH"
echo "protoc added to your PATH. You might need to open a new terminal"
else
echo "protoc already appears to be on your PATH"
fi

mkdir -p "${WORKDIR}/out"

# Generates sources without the embed requirement
Expand All @@ -76,7 +66,7 @@ LEGACY_SOURCES=(

# Generates only the new gRPC Service symbols
SOURCES=(
$(git ls-files --exclude-standard --cached --others "*.proto" | grep -v '^\(profiling/proto/service.proto\|reflection/grpc_reflection_v1alpha/reflection.proto\)$')
$(git ls-files --exclude-standard --cached --others "*.proto" | grep -v '^profiling/proto/service.proto$')
"${WORKDIR}/grpc-proto/grpc/gcp/altscontext.proto"
"${WORKDIR}/grpc-proto/grpc/gcp/handshaker.proto"
"${WORKDIR}/grpc-proto/grpc/gcp/transport_security_common.proto"
Expand Down
6 changes: 5 additions & 1 deletion scripts/vet-proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ if [[ "$1" = "-install" ]]; then
unzip ${PROTOC_FILENAME}
protoc --version # Check that the binary works.
popd
else
elif [[ -z "${VET_SKIP_PROTO}" ]]; then
source ./scripts/protoc_installer.sh
download_protoc
protoc --version
else
# TODO: replace with install protoc when https://github.com/grpc/grpc-go/pull/7064 is merged.
die "-install currently intended for use in CI only."
fi
Expand Down
5 changes: 0 additions & 5 deletions scripts/vet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ if [[ "$1" = "-install" ]]; then
honnef.co/go/tools/cmd/staticcheck \
github.com/client9/misspell/cmd/misspell
popd
if [[ -z "${VET_SKIP_PROTO}" ]]; then
source ./scripts/protoc_installer.sh
download_protoc
protoc --version
fi
exit 0
elif [[ "$#" -ne 0 ]]; then
die "Unknown argument(s): $*"
Expand Down

0 comments on commit 075201a

Please sign in to comment.