diff options
Diffstat (limited to 'protoc-artifacts')
-rw-r--r-- | protoc-artifacts/Dockerfile | 4 | ||||
-rw-r--r-- | protoc-artifacts/README.md | 19 | ||||
-rwxr-xr-x | protoc-artifacts/build-protoc.sh | 27 | ||||
-rwxr-xr-x | protoc-artifacts/build-zip.sh | 108 | ||||
-rw-r--r-- | protoc-artifacts/pom.xml | 3 |
5 files changed, 150 insertions, 11 deletions
diff --git a/protoc-artifacts/Dockerfile b/protoc-artifacts/Dockerfile index fd35b89f..5143b028 100644 --- a/protoc-artifacts/Dockerfile +++ b/protoc-artifacts/Dockerfile @@ -21,9 +21,9 @@ ENV JAVA_HOME /var/local/jdk1.8.0_45 ENV PATH $JAVA_HOME/bin:$PATH # Install Maven -RUN wget -q http://apache.cs.utah.edu/maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.tar.gz -O - | \ +RUN wget -q http://apache.cs.utah.edu/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz -O - | \ tar xz -C /var/local -ENV PATH /var/local/apache-maven-3.3.3/bin:$PATH +ENV PATH /var/local/apache-maven-3.3.9/bin:$PATH # Install GCC 4.7 to support -static-libstdc++ RUN wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo -P /etc/yum.repos.d diff --git a/protoc-artifacts/README.md b/protoc-artifacts/README.md index a910fe0d..50629209 100644 --- a/protoc-artifacts/README.md +++ b/protoc-artifacts/README.md @@ -102,6 +102,25 @@ When you have done deployment for all platforms, go to https://oss.sonatype.org/#stagingRepositories, verify that the staging repository has all the binaries, close and release this repository. +## Upload zip packages to github release page. +After uploading protoc artifacts to Maven Central repository, run the +build-zip.sh script to bulid zip packages for these protoc binaries +and upload these zip packages to the download section of the github +release. For example: +``` +$ ./build-zip.sh 3.0.0-beta-4 +``` +The above command will create 5 zip files: +``` +dist/protoc-3.0.0-beta-4-win32.zip +dist/protoc-3.0.0-beta-4-osx-x86_32.zip +dist/protoc-3.0.0-beta-4-osx-x86_64.zip +dist/protoc-3.0.0-beta-4-linux-x86_32.zip +dist/protoc-3.0.0-beta-4-linux-x86_64.zip +``` +Before running the script, make sure the artifacts are accessible from: +http://repo1.maven.org/maven2/com/google/protobuf/protoc/ + ### Tips for deploying on Linux We build on Centos 6.6 to provide a good compatibility for not very new systems. We have provided a ``Dockerfile`` under this directory to build the diff --git a/protoc-artifacts/build-protoc.sh b/protoc-artifacts/build-protoc.sh index 88e6ae50..e31948e9 100755 --- a/protoc-artifacts/build-protoc.sh +++ b/protoc-artifacts/build-protoc.sh @@ -1,17 +1,30 @@ #!/bin/bash -# Builds protoc executable into target/protoc.exe +# Builds protoc executable into target/protoc.exe; optionally build protoc +# plugins into target/protoc-gen-*.exe # To be run from Maven. -# Usage: build-protoc.sh <OS> <ARCH> +# Usage: build-protoc.sh <OS> <ARCH> <TARGET> # <OS> and <ARCH> are ${os.detected.name} and ${os.detected.arch} from os-maven-plugin +# <TARGET> can be "protoc" or "protoc-gen-javalite" OS=$1 ARCH=$2 +MAKE_TARGET=$3 -if [[ $# < 2 ]]; then +if [[ $# < 3 ]]; then echo "No arguments provided. This script is intended to be run from Maven." exit 1 fi +case $MAKE_TARGET in + protoc-gen-javalite) + ;; + protoc) + ;; + *) + echo "Target ""$TARGET"" invalid." + exit 1 +esac + # Under Cygwin, bash doesn't have these in PATH when called from Maven which # runs in Windows version of Java. export PATH="/bin:/usr/bin:$PATH" @@ -126,7 +139,7 @@ checkDependencies () } ############################################################################ -echo "Building protoc, OS=$OS ARCH=$ARCH" +echo "Building protoc, OS=$OS ARCH=$ARCH TARGET=$TARGET" # Nested double quotes are unintuitive, but it works. cd "$(dirname "$0")" @@ -134,7 +147,7 @@ cd "$(dirname "$0")" WORKING_DIR=$(pwd) CONFIGURE_ARGS="--disable-shared" -MAKE_TARGET="protoc" +TARGET_FILE=target/$MAKE_TARGET.exe if [[ "$OS" == windows ]]; then MAKE_TARGET="${MAKE_TARGET}.exe" fi @@ -209,12 +222,10 @@ fi export CXXFLAGS LDFLAGS -TARGET_FILE=target/protoc.exe - cd "$WORKING_DIR"/.. && ./configure $CONFIGURE_ARGS && cd src && make clean && make $MAKE_TARGET && cd "$WORKING_DIR" && mkdir -p target && - (cp ../src/protoc $TARGET_FILE || cp ../src/protoc.exe $TARGET_FILE) || + cp ../src/$MAKE_TARGET $TARGET_FILE || exit 1 if [[ "$OS" == osx ]]; then diff --git a/protoc-artifacts/build-zip.sh b/protoc-artifacts/build-zip.sh new file mode 100755 index 00000000..3c5e887b --- /dev/null +++ b/protoc-artifacts/build-zip.sh @@ -0,0 +1,108 @@ +#!/bin/bash + +if [ $# -ne 2 ]; then + cat <<EOF +Usage: $0 <TARGET> <VERSION_NUMBER> + +TARGET: protoc | protoc-gen-javalite + +Example: + $ $0 protoc 3.0.0 + $ $0 protoc-gen-javalite 3.0.0 + +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 +included. Each invocation will create 5 zip packages: + 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 +EOF + exit 1 +fi + +TARGET=$1 +VERSION_NUMBER=$2 + +# <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 \ +) + +# 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. + +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]} + if [ ${ZIP_NAME:0:3} = "win" ]; then + BINARY="$TARGET.exe" + else + BINARY="$TARGET" + fi + BINARY_NAME=${FILE_NAMES[$(($i+1))]} + BINARY_URL=http://repo1.maven.org/maven2/com/google/protobuf/$TARGET/${VERSION_NUMBER}/$TARGET-${VERSION_NUMBER}-${BINARY_NAME} + if ! wget ${BINARY_URL} -O ${DIR}/bin/$BINARY &> /dev/null; then + echo "[ERROR] Failed to download ${BINARY_URL}" >&2 + echo "[ERROR] Skipped $TARGET-${VERSION_NAME}-${ZIP_NAME}" >&2 + continue + fi + TARGET_ZIP_FILE=`pwd`/dist/$TARGET-${VERSION_NUMBER}-${ZIP_NAME} + pushd $DIR &> /dev/null + chmod +x bin/$BINARY + 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 + rm bin/$BINARY + popd &> /dev/null + echo "[INFO] Successfully created ${TARGET_ZIP_FILE}" +done diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index 50866041..840bc60a 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -10,7 +10,7 @@ </parent> <groupId>com.google.protobuf</groupId> <artifactId>protoc</artifactId> - <version>3.0.0-beta-3</version> + <version>3.0.0</version> <packaging>pom</packaging> <name>Protobuf Compiler</name> <description> @@ -59,6 +59,7 @@ <argument>build-protoc.sh</argument> <argument>${os.detected.name}</argument> <argument>${os.detected.arch}</argument> + <argument>protoc</argument> </arguments> </configuration> </plugin> |