1ffe3c632Sopenharmony_ci#!/usr/bin/env bash 2ffe3c632Sopenharmony_ci 3ffe3c632Sopenharmony_ci# DO NOT use this script manually! Called by docker. 4ffe3c632Sopenharmony_ci 5ffe3c632Sopenharmony_ciset -ex 6ffe3c632Sopenharmony_ci 7ffe3c632Sopenharmony_ci# Print usage and fail. 8ffe3c632Sopenharmony_cifunction usage() { 9ffe3c632Sopenharmony_ci echo "Usage: protobuf_optimized_pip.sh PROTOBUF_VERSION" >&2 10ffe3c632Sopenharmony_ci exit 1 # Causes caller to exit because we use -e. 11ffe3c632Sopenharmony_ci} 12ffe3c632Sopenharmony_ci 13ffe3c632Sopenharmony_ci# Build wheel 14ffe3c632Sopenharmony_cifunction build_wheel() { 15ffe3c632Sopenharmony_ci PYTHON_VERSION=$1 16ffe3c632Sopenharmony_ci PYTHON_BIN=/opt/python/${PYTHON_VERSION}/bin/python 17ffe3c632Sopenharmony_ci 18ffe3c632Sopenharmony_ci $PYTHON_BIN setup.py bdist_wheel --cpp_implementation --compile_static_extension 19ffe3c632Sopenharmony_ci auditwheel repair dist/protobuf-${PROTOBUF_VERSION}-${PYTHON_VERSION}-linux_x86_64.whl 20ffe3c632Sopenharmony_ci} 21ffe3c632Sopenharmony_ci 22ffe3c632Sopenharmony_ci# Validate arguments. 23ffe3c632Sopenharmony_ciif [ $0 != ./protobuf_optimized_pip.sh ]; then 24ffe3c632Sopenharmony_ci echo "Please run this script from the directory in which it is located." >&2 25ffe3c632Sopenharmony_ci exit 1 26ffe3c632Sopenharmony_cifi 27ffe3c632Sopenharmony_ci 28ffe3c632Sopenharmony_ciif [ $# -lt 1 ]; then 29ffe3c632Sopenharmony_ci usage 30ffe3c632Sopenharmony_ci exit 1 31ffe3c632Sopenharmony_cifi 32ffe3c632Sopenharmony_ci 33ffe3c632Sopenharmony_ciPROTOBUF_VERSION=$1 34ffe3c632Sopenharmony_ciPYPI_USERNAME=$2 35ffe3c632Sopenharmony_ciPYPI_PASSWORD=$3 36ffe3c632Sopenharmony_ci 37ffe3c632Sopenharmony_ciDIR=${PWD}/'protobuf-python-build' 38ffe3c632Sopenharmony_ciPYTHON_VERSIONS=('cp27-cp27mu' 'cp33-cp33m' 'cp34-cp34m' 'cp35-cp35m' 'cp36-cp36m') 39ffe3c632Sopenharmony_ci 40ffe3c632Sopenharmony_cimkdir -p ${DIR} 41ffe3c632Sopenharmony_cicd ${DIR} 42ffe3c632Sopenharmony_cicurl -SsL -O https://github.com/protocolbuffers/protobuf/archive/v${PROTOBUF_VERSION}.tar.gz 43ffe3c632Sopenharmony_citar xzf v${PROTOBUF_VERSION}.tar.gz 44ffe3c632Sopenharmony_cicd $DIR/protobuf-${PROTOBUF_VERSION} 45ffe3c632Sopenharmony_ci 46ffe3c632Sopenharmony_ci# Autoconf on centos 5.11 cannot recognize AC_PROG_OBJC. 47ffe3c632Sopenharmony_cised -i '/AC_PROG_OBJC/d' configure.ac 48ffe3c632Sopenharmony_cised -i 's/conformance\/Makefile//g' configure.ac 49ffe3c632Sopenharmony_ci 50ffe3c632Sopenharmony_ci# Use the /usr/bin/autoconf and related tools to pick the correct aclocal macros 51ffe3c632Sopenharmony_ciexport PATH="/usr/bin:$PATH" 52ffe3c632Sopenharmony_ci 53ffe3c632Sopenharmony_ci# Build protoc 54ffe3c632Sopenharmony_ci./autogen.sh 55ffe3c632Sopenharmony_ciCXXFLAGS="-fPIC -g -O2" ./configure 56ffe3c632Sopenharmony_cimake -j8 57ffe3c632Sopenharmony_ciexport PROTOC=$DIR/src/protoc 58ffe3c632Sopenharmony_ci 59ffe3c632Sopenharmony_cicd python 60ffe3c632Sopenharmony_ci 61ffe3c632Sopenharmony_cifor PYTHON_VERSION in "${PYTHON_VERSIONS[@]}" 62ffe3c632Sopenharmony_cido 63ffe3c632Sopenharmony_ci build_wheel $PYTHON_VERSION 64ffe3c632Sopenharmony_cidone 65ffe3c632Sopenharmony_ci 66ffe3c632Sopenharmony_ci/opt/python/cp27-cp27mu/bin/twine upload wheelhouse/* 67