Skip to content

Commit

Permalink
Merge pull request #15 from make-files/apple-silicon
Browse files Browse the repository at this point in the history
Use x86_64 builds on Apple Silicon.
  • Loading branch information
jmalloc authored Aug 18, 2021
2 parents 2d669eb + bed622c commit 8a9a7ca
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions bin/install-protoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,30 @@ case "$(uname -s)" in
OS="linux";;
esac

ARCH="$(uname -m)"

# Use x86_64 on Apple Silicon, as there is no official arm64 support.
#
# See https://github.com/protocolbuffers/protobuf/issues/8062.
# See https://github.com/protocolbuffers/protobuf/issues/8428.
if [[ "$OS" == "osx" && "$ARCH" == "arm64" ]]; then
softwareupdate --install-rosetta --agree-to-license
ARCH="x86_64"
fi

VERSION="$(curl --head --silent https://github.com/protocolbuffers/protobuf/releases/latest | grep -i '^Location:' | egrep -o '[0-9]+.[0-9]+.[0-9]+')"

if [[ -f "${PROTOC_ROOT}/bin/protoc" ]]; then
LOCAL_VERSION="$(${PROTOC_ROOT}/bin/protoc --version | sed -e 's/.* //')"
[[ "${VERSION}" == "${LOCAL_VERSION}" ]] && exit 0
fi

ARCHIVE="protoc-${VERSION}-${OS}-$(uname -m).zip"
ARCHIVE="protoc-${VERSION}-${OS}-${ARCH}.zip"
URL="https://github.com/protocolbuffers/protobuf/releases/download/v${VERSION}/${ARCHIVE}"

mkdir -p "${PROTOC_ROOT}"
pushd "${PROTOC_ROOT}"
curl --location --silent --output "${ARCHIVE}" "${URL}"
curl --fail --silent --show-error --location --output "${ARCHIVE}" "${URL}"
unzip -o "${ARCHIVE}"
chmod +x bin/protoc
find include/google -type d -exec chmod 755 {} \;
Expand Down

0 comments on commit 8a9a7ca

Please sign in to comment.