2016-07-25 21:55:36 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-07-28 21:24:05 +00:00
|
|
|
if [ $# -ne 2 ]; then
|
2016-07-25 21:55:36 +00:00
|
|
|
cat <<EOF
|
2016-07-28 21:24:05 +00:00
|
|
|
Usage: $0 <TARGET> <VERSION_NUMBER>
|
|
|
|
|
|
|
|
TARGET: protoc | protoc-gen-javalite
|
2016-07-25 21:55:36 +00:00
|
|
|
|
|
|
|
Example:
|
2016-07-28 21:24:05 +00:00
|
|
|
$ $0 protoc 3.0.0
|
|
|
|
$ $0 protoc-gen-javalite 3.0.0
|
2016-07-25 21:55:36 +00:00
|
|
|
|
2016-07-28 21:24:05 +00:00
|
|
|
This script will download pre-built protoc or protoc plugin binaries from maven
|
|
|
|
repository and create .zip packages suitable to be included in the github
|
|
|
|
release page. If the target is protoc, well-known type .proto files will also be
|
2017-11-10 01:16:42 +00:00
|
|
|
included. Each invocation will create 6 zip packages:
|
2016-07-28 21:24:05 +00:00
|
|
|
dist/<TARGET>-<VERSION_NUMBER>-win32.zip
|
|
|
|
dist/<TARGET>-<VERSION_NUMBER>-osx-x86_32.zip
|
|
|
|
dist/<TARGET>-<VERSION_NUMBER>-osx-x86_64.zip
|
|
|
|
dist/<TARGET>-<VERSION_NUMBER>-linux-x86_32.zip
|
|
|
|
dist/<TARGET>-<VERSION_NUMBER>-linux-x86_64.zip
|
2017-11-10 01:22:03 +00:00
|
|
|
dist/<TARGET>-<VERSION_NUMBER>-linux-aarch_64.zip
|
2016-07-25 21:55:36 +00:00
|
|
|
EOF
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-07-28 21:24:05 +00:00
|
|
|
TARGET=$1
|
|
|
|
VERSION_NUMBER=$2
|
2016-07-25 21:55:36 +00:00
|
|
|
|
|
|
|
# <zip file name> <binary file name> pairs.
|
|
|
|
declare -a FILE_NAMES=( \
|
|
|
|
win32.zip windows-x86_32.exe \
|
|
|
|
osx-x86_32.zip osx-x86_32.exe \
|
|
|
|
osx-x86_64.zip osx-x86_64.exe \
|
|
|
|
linux-x86_32.zip linux-x86_32.exe \
|
|
|
|
linux-x86_64.zip linux-x86_64.exe \
|
2017-11-10 01:22:03 +00:00
|
|
|
linux-aarch_64.zip linux-aarch_64.exe \
|
2016-07-25 21:55:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# List of all well-known types to be included.
|
|
|
|
declare -a WELL_KNOWN_TYPES=( \
|
|
|
|
google/protobuf/descriptor.proto \
|
|
|
|
google/protobuf/any.proto \
|
|
|
|
google/protobuf/api.proto \
|
|
|
|
google/protobuf/duration.proto \
|
|
|
|
google/protobuf/empty.proto \
|
|
|
|
google/protobuf/field_mask.proto \
|
|
|
|
google/protobuf/source_context.proto \
|
|
|
|
google/protobuf/struct.proto \
|
|
|
|
google/protobuf/timestamp.proto \
|
|
|
|
google/protobuf/type.proto \
|
|
|
|
google/protobuf/wrappers.proto \
|
|
|
|
google/protobuf/compiler/plugin.proto \
|
|
|
|
)
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# A temporary working directory to put all files.
|
|
|
|
DIR=$(mktemp -d)
|
|
|
|
|
|
|
|
# Copy over well-known types.
|
|
|
|
mkdir -p ${DIR}/include/google/protobuf/compiler
|
|
|
|
for PROTO in ${WELL_KNOWN_TYPES[@]}; do
|
|
|
|
cp -f ../src/${PROTO} ${DIR}/include/${PROTO}
|
|
|
|
done
|
|
|
|
|
|
|
|
# Create a readme file.
|
|
|
|
cat <<EOF > ${DIR}/readme.txt
|
|
|
|
Protocol Buffers - Google's data interchange format
|
|
|
|
Copyright 2008 Google Inc.
|
|
|
|
https://developers.google.com/protocol-buffers/
|
|
|
|
|
|
|
|
This package contains a precompiled binary version of the protocol buffer
|
|
|
|
compiler (protoc). This binary is intended for users who want to use Protocol
|
|
|
|
Buffers in languages other than C++ but do not want to compile protoc
|
|
|
|
themselves. To install, simply place this binary somewhere in your PATH.
|
|
|
|
|
2017-07-18 16:05:00 +00:00
|
|
|
If you intend to use the included well known types then don't forget to
|
|
|
|
copy the contents of the 'include' directory somewhere as well, for example
|
|
|
|
into '/usr/local/include/'.
|
|
|
|
|
2016-07-25 21:55:36 +00:00
|
|
|
Please refer to our official github site for more installation instructions:
|
|
|
|
https://github.com/google/protobuf
|
|
|
|
EOF
|
|
|
|
|
|
|
|
mkdir -p dist
|
|
|
|
mkdir -p ${DIR}/bin
|
|
|
|
# Create a zip file for each binary.
|
|
|
|
for((i=0;i<${#FILE_NAMES[@]};i+=2));do
|
|
|
|
ZIP_NAME=${FILE_NAMES[$i]}
|
2016-07-29 18:44:05 +00:00
|
|
|
if [ ${ZIP_NAME:0:3} = "win" ]; then
|
|
|
|
BINARY="$TARGET.exe"
|
|
|
|
else
|
|
|
|
BINARY="$TARGET"
|
|
|
|
fi
|
2016-07-25 21:55:36 +00:00
|
|
|
BINARY_NAME=${FILE_NAMES[$(($i+1))]}
|
2016-07-28 21:24:05 +00:00
|
|
|
BINARY_URL=http://repo1.maven.org/maven2/com/google/protobuf/$TARGET/${VERSION_NUMBER}/$TARGET-${VERSION_NUMBER}-${BINARY_NAME}
|
2016-07-29 18:44:05 +00:00
|
|
|
if ! wget ${BINARY_URL} -O ${DIR}/bin/$BINARY &> /dev/null; then
|
2016-07-25 21:55:36 +00:00
|
|
|
echo "[ERROR] Failed to download ${BINARY_URL}" >&2
|
2016-07-28 21:24:05 +00:00
|
|
|
echo "[ERROR] Skipped $TARGET-${VERSION_NAME}-${ZIP_NAME}" >&2
|
2016-07-25 21:55:36 +00:00
|
|
|
continue
|
|
|
|
fi
|
2016-07-28 21:24:05 +00:00
|
|
|
TARGET_ZIP_FILE=`pwd`/dist/$TARGET-${VERSION_NUMBER}-${ZIP_NAME}
|
2016-07-25 21:55:36 +00:00
|
|
|
pushd $DIR &> /dev/null
|
2016-07-29 18:44:05 +00:00
|
|
|
chmod +x bin/$BINARY
|
2016-07-28 21:24:05 +00:00
|
|
|
if [ "$TARGET" = "protoc" ]; then
|
|
|
|
zip -r ${TARGET_ZIP_FILE} include bin readme.txt &> /dev/null
|
|
|
|
else
|
|
|
|
zip -r ${TARGET_ZIP_FILE} bin &> /dev/null
|
|
|
|
fi
|
2016-07-29 18:44:05 +00:00
|
|
|
rm bin/$BINARY
|
2016-07-25 21:55:36 +00:00
|
|
|
popd &> /dev/null
|
|
|
|
echo "[INFO] Successfully created ${TARGET_ZIP_FILE}"
|
|
|
|
done
|