Skip to content

Commit fbd8c3b

Browse files
committed
Add support for Windows and MacOs, including ARM architecture in generateProto.sh
1 parent f6c4778 commit fbd8c3b

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

tools/generateProto.sh

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,33 @@ mkdir -p "${LOCAL_DIR}"
1515

1616
# install a specific version of protoc
1717
export PATH="${LOCAL_DIR}/bin:$PATH"
18-
if ! protoc --version | grep "${PB_VERSION}" >/dev/null; then
18+
if ! protoc --version | grep "${PB_VERSION}" &>/dev/null; then
1919
if [[ -d "${LOCAL_DIR}" ]]; then
2020
rm -rf "${LOCAL_DIR}"
2121
fi
22-
curl -sLO "https://github.com/protocolbuffers/protobuf/releases/download/v${PB_VERSION}/protoc-${PB_VERSION}-linux-x86_64.zip"
23-
unzip "protoc-${PB_VERSION}-linux-x86_64.zip" -d "${LOCAL_DIR}"
24-
rm "protoc-${PB_VERSION}-linux-x86_64.zip"
22+
23+
if [[ "${OSTYPE}" == "win"* ]] || [[ "${OSTYPE}" == "msys" ]]; then
24+
readonly qualifier="win64"
25+
elif [[ "${OSTYPE}" == "linux-gnu"* ]]; then
26+
if [[ "$(arch)" == "arm64" ]] || [[ "$(arch)" == "aarch64" ]]; then
27+
readonly qualifier="linux-aarch_64"
28+
else
29+
readonly qualifier="linux-x86_64"
30+
fi
31+
elif [[ "${OSTYPE}" == "darwin"* ]]; then
32+
if [[ "$(arch)" == "arm64" ]] || [[ "$(arch)" == "aarch64" ]]; then
33+
readonly qualifier="osx-aarch_64"
34+
else
35+
readonly qualifier="osx-x86_64"
36+
fi
37+
else
38+
echo "Unknown OS ${OSTYPE}" >&2
39+
exit 1
40+
fi
41+
42+
curl -sLO "https://github.com/protocolbuffers/protobuf/releases/download/v${PB_VERSION}/protoc-${PB_VERSION}-${qualifier}.zip"
43+
unzip "protoc-${PB_VERSION}-${qualifier}.zip" -d "${LOCAL_DIR}"
44+
rm "protoc-${PB_VERSION}-${qualifier}.zip"
2545
fi
2646

2747
# install a specific version of protoc-gen-go

0 commit comments

Comments
 (0)