ADD: added new version of protobuf

This commit is contained in:
Henry Winkel
2022-12-20 10:09:28 +01:00
parent 4a79559129
commit 1e2b3dda7b
1513 changed files with 123720 additions and 83381 deletions

View File

@@ -40,8 +40,8 @@ mkdir -p protoc/linux_x86
mkdir -p protoc/linux_x64
# Because of maven unrelated reasonse the linux protoc binaries have a dummy .exe extension.
# For the Google.Protobuf.Tools nuget, we don't want that exception, so we just remove it.
cp ${INPUT_ARTIFACTS_DIR}/kokoro/release/protoc/target/linux/x86_32/protoc.exe protoc/linux_x86/protoc
cp ${INPUT_ARTIFACTS_DIR}/kokoro/release/protoc/target/linux/x86_64/protoc.exe protoc/linux_x64/protoc
cp ${INPUT_ARTIFACTS_DIR}/protoc-artifacts/target/linux/x86_32/protoc.exe protoc/linux_x86/protoc
cp ${INPUT_ARTIFACTS_DIR}/protoc-artifacts/target/linux/x86_64/protoc.exe protoc/linux_x64/protoc
mkdir -p protoc/macosx_x64
cp ${INPUT_ARTIFACTS_DIR}/build64/src/protoc protoc/macosx_x64/protoc

View File

@@ -1,11 +0,0 @@
# Config file for running tests in Kokoro
# Location of the build script in repository
build_file: "protobuf/kokoro/release/csharp/windows/build_nuget.bat"
timeout_mins: 60
action {
define_artifacts {
regex: "**/*.nupkg"
}
}

View File

@@ -1 +1,11 @@
# Keep this file empty! Use common.cfg instead.
# Config file for running tests in Kokoro
# Location of the build script in repository
build_file: "protobuf/kokoro/release/csharp/windows/build_nuget.bat"
timeout_mins: 60
action {
define_artifacts {
regex: "**/*.nupkg"
}
}

View File

@@ -1 +1,11 @@
# Keep this file empty! Use common.cfg instead.
# Config file for running tests in Kokoro
# Location of the build script in repository
build_file: "protobuf/kokoro/release/csharp/windows/build_nuget.bat"
timeout_mins: 60
action {
define_artifacts {
regex: "**/*.nupkg"
}
}

View File

@@ -1,247 +0,0 @@
#!/bin/bash
# Builds protoc executable into target/<OS>/<ARCH>/protoc.exe; optionally builds
# protoc plugins into target/<OS>/<ARCH>/protoc-gen-*.exe
#
# Usage: ./build-protoc.sh <OS> <ARCH> <TARGET>
#
# <TARGET> can be "protoc" or "protoc-gen-javalite". Supported <OS> <ARCH>
# combinations:
# HOST <OS> <ARCH> <COMMENT>
# cygwin windows x86_32 Requires: i686-w64-mingw32-gcc
# cygwin windows x86_64 Requires: x86_64-w64-mingw32-gcc
# linux linux aarch_64 Requires: g++-aarch64-linux-gnu
# linux linux x86_32
# linux linux x86_64
# linux windows x86_32 Requires: i686-w64-mingw32-gcc
# linux windows x86_64 Requires: x86_64-w64-mingw32-gcc
# macos osx x86_32
# macos osx x86_64
# mingw windows x86_32
# mingw windows x86_64
OS=$1
ARCH=$2
BAZEL_TARGET=$3
if [[ $# < 3 ]]; then
echo "Not enough arguments provided."
exit 1
fi
if [[ $BAZEL_TARGET != protoc ]]; then
echo "Target ""$BAZEL_TARGET"" invalid."
exit 1
fi
# 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"
############################################################################
# Helper functions
############################################################################
E_PARAM_ERR=98
E_ASSERT_FAILED=99
# Usage:
fail()
{
echo "ERROR: $1"
echo
exit $E_ASSERT_FAILED
}
# Usage: assertEq VAL1 VAL2 $LINENO
assertEq ()
{
lineno=$3
if [ -z "$lineno" ]; then
echo "lineno not given"
exit $E_PARAM_ERR
fi
if [[ "$1" != "$2" ]]; then
echo "Assertion failed: \"$1\" == \"$2\""
echo "File \"$0\", line $lineno" # Give name of file and line number.
exit $E_ASSERT_FAILED
fi
}
# Checks the artifact is for the expected architecture
# Usage: checkArch <path-to-protoc>
checkArch ()
{
echo
echo "Checking file format ..."
if [[ "$OS" == windows || "$OS" == linux ]]; then
format="$(objdump -f "$1" | grep -o "file format .*$" | grep -o "[^ ]*$")"
echo Format=$format
if [[ "$OS" == linux ]]; then
host_machine="$(uname -m)";
if [[ "$ARCH" == x86_32 ]]; then
assertEq $format "elf32-i386" $LINENO
elif [[ "$ARCH" == x86_64 ]]; then
assertEq $format "elf64-x86-64" $LINENO
elif [[ "$ARCH" == aarch_64 ]]; then
assertEq $format "elf64-little" $LINENO
elif [[ "$ARCH" == s390_64 ]]; then
if [[ $host_machine == s390x ]];then
assertEq $format "elf64-s390" $LINENO
else
assertEq $format "elf64-big" $LINENO
fi
elif [[ "$ARCH" == ppcle_64 ]]; then
if [[ $host_machine == ppc64le ]];then
assertEq $format "elf64-powerpcle" $LINENO
else
assertEq $format "elf64-little" $LINENO
fi
else
fail "Unsupported arch: $ARCH"
fi
else
# $OS == windows
if [[ "$ARCH" == x86_32 ]]; then
assertEq $format "pei-i386" $LINENO
elif [[ "$ARCH" == x86_64 ]]; then
assertEq $format "pei-x86-64" $LINENO
else
fail "Unsupported arch: $ARCH"
fi
fi
elif [[ "$OS" == osx ]]; then
format="$(file -b "$1" | grep -o "[^ ]*$")"
echo Format=$format
if [[ "$ARCH" == x86_32 ]]; then
assertEq $format "i386" $LINENO
elif [[ "$ARCH" == x86_64 ]]; then
assertEq $format "x86_64" $LINENO
else
fail "Unsupported arch: $ARCH"
fi
else
fail "Unsupported system: $OS"
fi
echo
}
# Checks the dependencies of the artifact. Artifacts should only depend on
# system libraries.
# Usage: checkDependencies <path-to-protoc>
checkDependencies ()
{
if [[ "$OS" == windows ]]; then
dump_cmd='objdump -x '"$1"' | fgrep "DLL Name"'
white_list="KERNEL32\.dll\|msvcrt\.dll"
elif [[ "$OS" == linux ]]; then
host_machine="$(uname -m)";
dump_cmd='ldd '"$1"
if [[ "$ARCH" == x86_32 ]]; then
white_list="linux-gate\.so\.1\|libpthread\.so\.0\|libm\.so\.6\|libc\.so\.6\|libgcc_s\.so\.1\|libstdc++\.so\.6\|ld-linux\.so\.2"
elif [[ "$ARCH" == x86_64 ]]; then
white_list="linux-vdso\.so\.1\|libpthread\.so\.0\|libm\.so\.6\|libc\.so\.6\|libgcc_s\.so\.1\|libstdc++\.so\.6\|ld-linux-x86-64\.so\.2"
elif [[ "$ARCH" == s390_64 ]]; then
if [[ $host_machine != s390x ]];then
dump_cmd='objdump -p '"$1"' | grep NEEDED'
fi
white_list="linux-vdso64\.so\.1\|libpthread\.so\.0\|libm\.so\.6\|libc\.so\.6\|libgcc_s\.so\.1\|libstdc++\.so\.6\|libz\.so\.1\|ld64\.so\.1"
elif [[ "$ARCH" == ppcle_64 ]]; then
if [[ $host_machine != ppc64le ]];then
dump_cmd='objdump -p '"$1"' | grep NEEDED'
fi
white_list="linux-vdso64\.so\.1\|libpthread\.so\.0\|libm\.so\.6\|libc\.so\.6\|libgcc_s\.so\.1\|libstdc++\.so\.6\|libz\.so\.1\|ld64\.so\.2"
elif [[ "$ARCH" == aarch_64 ]]; then
dump_cmd='objdump -p '"$1"' | grep NEEDED'
white_list="libpthread\.so\.0\|libm\.so\.6\|libc\.so\.6\|libgcc_s\.so\.1\|libstdc++\.so\.6\|ld-linux-aarch64\.so\.1"
fi
elif [[ "$OS" == osx ]]; then
dump_cmd='otool -L '"$1"' | fgrep dylib'
white_list="libz\.1\.dylib\|libstdc++\.6\.dylib\|libSystem\.B\.dylib"
fi
if [[ -z "$white_list" || -z "$dump_cmd" ]]; then
fail "Unsupported platform $OS-$ARCH."
fi
echo "Checking for expected dependencies ..."
eval $dump_cmd | grep -i "$white_list" || fail "doesn't show any expected dependencies"
echo "Checking for unexpected dependencies ..."
eval $dump_cmd | grep -i -v "$white_list"
ret=$?
if [[ $ret == 0 ]]; then
fail "found unexpected dependencies (listed above)."
elif [[ $ret != 1 ]]; then
fail "Error when checking dependencies."
fi # grep returns 1 when "not found", which is what we expect
echo "Dependencies look good."
echo
}
############################################################################
echo "Building protoc, OS=$OS ARCH=$ARCH TARGET=$BAZEL_TARGET"
BAZEL_ARGS=("--dynamic_mode=off" "--compilation_mode=opt" "--copt=-g0" "--copt=-fpic")
if [[ "$OS" == windows ]]; then
BAZEL_TARGET="${BAZEL_TARGET}.exe"
fi
if [[ "$(uname)" == CYGWIN* ]]; then
assertEq "$OS" windows $LINENO
# Use mingw32 compilers because executables produced by Cygwin compiler
# always have dependency on Cygwin DLL.
if [[ "$ARCH" == x86_64 ]]; then
CONFIGURE_ARGS="$CONFIGURE_ARGS --host=x86_64-w64-mingw32"
elif [[ "$ARCH" == x86_32 ]]; then
CONFIGURE_ARGS="$CONFIGURE_ARGS --host=i686-pc-mingw32"
else
fail "Unsupported arch by CYGWIN: $ARCH"
fi
elif [[ "$(uname)" == MINGW32* ]]; then
assertEq "$OS" windows $LINENO
assertEq "$ARCH" x86_32 $LINENO
elif [[ "$(uname)" == MINGW64* ]]; then
assertEq "$OS" windows $LINENO
assertEq "$ARCH" x86_64 $LINENO
elif [[ "$(uname)" == Linux* ]]; then
if [[ "$OS" == linux ]]; then
BAZEL_ARGS+=("--config=linux-$ARCH")
elif [[ "$OS" == windows ]]; then
# Cross-compilation for Windows
if [[ "$ARCH" == x86_64 ]]; then
BAZEL_ARGS+=("--config=win64")
elif [[ "$ARCH" == x86_32 ]]; then
BAZEL_ARGS+=("--config=win32")
else
fail "Unsupported arch: $ARCH"
fi
else
fail "Cannot build $OS on $(uname)"
fi
elif [[ "$(uname)" == Darwin* ]]; then
assertEq "$OS" osx $LINENO
# Make the binary compatible with OSX 10.7 and later
BAZEL_ARGS+=("--config=osx-$ARCH" "--macos_minimum_os=10.7")
else
fail "Unsupported system: $(uname)"
fi
# Nested double quotes are unintuitive, but it works.
cd "$(dirname "$0")"
WORKING_DIR="$(pwd)"
TARGET_FILE="target/$OS/$ARCH/$BAZEL_TARGET.exe"
DOCKER_IMAGE=gcr.io/protobuf-build/bazel/linux@sha256:2bfd061284eff8234f2fcca16d71d43c69ccf3a22206628b54c204a6a9aac277
tmpfile=$(mktemp -u) &&
docker run --cidfile $tmpfile -v $WORKING_DIR/../../..:/workspace $DOCKER_IMAGE \
build //:$BAZEL_TARGET "${BAZEL_ARGS[@]}" &&
mkdir -p $(dirname $TARGET_FILE) &&
docker cp \
`cat $tmpfile`:/workspace/bazel-bin/$BAZEL_TARGET $TARGET_FILE || exit 1
if [[ "$OS" == osx ]]; then
# Since Mac linker doesn't accept "-s", we need to run strip
strip $TARGET_FILE || exit 1
fi
checkArch $TARGET_FILE && checkDependencies $TARGET_FILE

View File

@@ -1,29 +1,44 @@
#!/bin/bash
# This is not the source of truth for release protoc executables, and will soon
# be deprecated.
set -ex
set -x
# Change to repo root.
cd $(dirname $0)/../../../..
GIT_REPO_ROOT=$(pwd)
# Initialize any submodules.
git submodule update --init --recursive
# Generate the configure script.
./autogen.sh
# Cross-build for aarch64, ppc64le and s390x. Note: we do these builds first to avoid
# file permission issues. The Docker builds will create directories owned by
# root, which causes problems if we try to add new artifacts to those
# directories afterward.
sudo apt install -y g++-aarch64-linux-gnu
protoc-artifacts/build-protoc.sh linux aarch_64 protoc
kokoro/release/protoc/build-protoc.sh linux aarch_64 protoc
sudo apt install -y g++-powerpc64le-linux-gnu
protoc-artifacts/build-protoc.sh linux ppcle_64 protoc
kokoro/release/protoc/build-protoc.sh linux ppcle_64 protoc
sudo apt install -y g++-s390x-linux-gnu
protoc-artifacts/build-protoc.sh linux s390_64 protoc
kokoro/release/protoc/build-protoc.sh linux s390_64 protoc
# Use docker image to build linux artifacts.
DOCKER_IMAGE_NAME=protobuf/protoc_$(sha1sum protoc-artifacts/Dockerfile | cut -f1 -d " ")
docker pull $DOCKER_IMAGE_NAME
kokoro/release/protoc/build-protoc.sh linux x86_64 protoc
docker run -v $(pwd):/var/local/protobuf --rm $DOCKER_IMAGE_NAME \
bash -l /var/local/protobuf/protoc-artifacts/build-protoc.sh \
linux x86_64 protoc || {
echo "Failed to build protoc for linux + x86_64."
exit 1
}
kokoro/release/protoc/build-protoc.sh linux x86_32 protoc
docker run -v $(pwd):/var/local/protobuf --rm $DOCKER_IMAGE_NAME \
bash -l /var/local/protobuf/protoc-artifacts/build-protoc.sh \
linux x86_32 protoc || {
echo "Failed to build protoc for linux + x86_32."
exit 1
}

View File

@@ -4,9 +4,12 @@ set -ex
CXXFLAGS_COMMON="-std=c++14 -DNDEBUG -mmacosx-version-min=10.9"
cd github/protobuf
./autogen.sh
bazel build //:protoc --dynamic_mode=off
mkdir -p build64/src
cp bazel-bin/protoc build64/src/protoc
file bazel-bin/protoc
otool -L bazel-bin/protoc | grep dylib
mkdir build64 && cd build64
export CXXFLAGS="$CXXFLAGS_COMMON -m64"
../configure --disable-shared
make -j4
file src/protoc
otool -L src/protoc | grep dylib
cd ..

View File

@@ -1,13 +1,10 @@
set generator32=Visual Studio 15
set generator64=Visual Studio 15 Win64
set PATH=C:\Program Files (x86)\MSBuild\14.0\bin\;%PATH%
set generator32=Visual Studio 14
set generator64=Visual Studio 14 Win64
set vcplatform32=win32
set vcplatform64=x64
set configuration=Release
:: VS2017 is installed, but will not be selected by default. This command sets
:: up the environment so that CMake will find and use it:
call "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
echo Building protoc
cd github\protobuf
@@ -18,13 +15,13 @@ set ABSL_ROOT_DIR=%cd%\third_party\abseil-cpp
mkdir build32
cd build32
cmake -G "%generator32%" -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_UNICODE=ON ..
cmake -G "%generator32%" -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_UNICODE=ON ../cmake
msbuild protobuf.sln /p:Platform=%vcplatform32% || goto error
cd ..
mkdir build64
cd build64
cmake -G "%generator64%" -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_UNICODE=ON ..
cmake -G "%generator64%" -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_UNICODE=ON ../cmake
msbuild protobuf.sln /p:Platform=%vcplatform64% || goto error
cd ..

View File

@@ -0,0 +1,90 @@
#!/bin/bash
set -ex
# change to repo root
pushd $(dirname $0)/../../../..
# Create stage dir
ORIGINAL_DIR=`pwd`
pushd ..
cp -R $ORIGINAL_DIR stage
export STAGE_DIR="`pwd`/stage"
popd
export REPO_DIR=protobuf
export BUILD_VERSION=`grep -i "version" python/google/protobuf/__init__.py | grep -o "'.*'" | tr -d "'"`
export BUILD_COMMIT=`git rev-parse HEAD`
export PLAT=x86_64
export UNICODE_WIDTH=32
export MACOSX_DEPLOYMENT_TARGET=10.9
rm -rf artifacts/
rm -rf multibuild/
mkdir artifacts
export ARTIFACT_DIR=$(pwd)/artifacts
git clone https://github.com/matthew-brett/multibuild.git
# Pin multibuild scripts at a known commit to avoid potentially unwanted future changes from
# silently creeping in (see https://github.com/protocolbuffers/protobuf/issues/9180).
# IMPORTANT: always pin multibuild at the same commit for:
# - linux/build_artifacts.sh
# - linux/build_artifacts.sh
# - windows/build_artifacts.bat
(cd multibuild; git checkout b89bb903e94308be79abefa4f436bf123ebb1313)
cp kokoro/release/python/linux/config.sh config.sh
build_artifact_version() {
MB_PYTHON_VERSION=$1
cp -R $STAGE_DIR $REPO_DIR
source multibuild/common_utils.sh
source multibuild/travis_steps.sh
before_install
clean_code $REPO_DIR $BUILD_COMMIT
build_wheel $REPO_DIR/python $PLAT
mv wheelhouse/* $ARTIFACT_DIR
# Clean up env
rm -rf venv
sudo rm -rf $REPO_DIR
}
build_x86_64_manylinux1_artifact_version() {
# Explicitly request building manylinux1 wheels, which is no longer the default.
# https://github.com/protocolbuffers/protobuf/issues/9180
MB_ML_VER=1
build_artifact_version $@
}
build_x86_64_manylinux2010_artifact_version() {
# Explicitly request building manylinux2010 wheels
MB_ML_VER=2010
build_artifact_version $@
}
build_crosscompiled_aarch64_manylinux2014_artifact_version() {
# crosscompilation is only supported with the dockcross manylinux2014 image
DOCKER_IMAGE=dockcross/manylinux2014-aarch64:20210706-65bf2dd
MB_ML_VER=2014
PLAT=aarch64
# TODO(jtatermusch): currently when crosscompiling, "auditwheel repair" will be disabled
# since auditwheel doesn't work for crosscomiled wheels.
build_artifact_version $@
}
build_x86_64_manylinux1_artifact_version 3.6
build_x86_64_manylinux1_artifact_version 3.7
build_x86_64_manylinux1_artifact_version 3.8
build_x86_64_manylinux1_artifact_version 3.9
build_x86_64_manylinux2010_artifact_version 3.10
build_crosscompiled_aarch64_manylinux2014_artifact_version 3.7
build_crosscompiled_aarch64_manylinux2014_artifact_version 3.8
build_crosscompiled_aarch64_manylinux2014_artifact_version 3.9
build_crosscompiled_aarch64_manylinux2014_artifact_version 3.10

View File

@@ -0,0 +1,93 @@
# Define custom utilities
# Test for OSX with [ -n "$IS_OSX" ]
function pre_build {
# Any stuff that you need to do before you start building the wheels
# Runs in the root directory of this repository.
pushd protobuf
if [ "$PLAT" == "aarch64" ]
then
local configure_host_flag="--host=aarch64"
fi
# Build protoc and libprotobuf
./autogen.sh
CXXFLAGS="-fPIC -g -O2" ./configure $configure_host_flag
make -j8
if [ "$PLAT" == "aarch64" ]
then
# we are crosscompiling for aarch64 while running on x64
# the simplest way for build_py command to be able to generate
# the protos is by running the protoc process under
# an emulator. That way we don't have to build a x64 version
# of protoc. The qemu-arm emulator is already included
# in the dockcross docker image.
# Running protoc under an emulator is fast as protoc doesn't
# really do much.
# create a simple shell wrapper that runs crosscompiled protoc under qemu
echo '#!/bin/bash' >protoc_qemu_wrapper.sh
echo 'exec qemu-aarch64 "../src/protoc" "$@"' >>protoc_qemu_wrapper.sh
chmod ugo+x protoc_qemu_wrapper.sh
# PROTOC variable is by build_py step that runs under ./python directory
export PROTOC=../protoc_qemu_wrapper.sh
fi
# Generate python dependencies.
pushd python
python setup.py build_py
popd
popd
}
function bdist_wheel_cmd {
# Builds wheel with bdist_wheel, puts into wheelhouse
#
# It may sometimes be useful to use bdist_wheel for the wheel building
# process. For example, versioneer has problems with versions which are
# fixed with bdist_wheel:
# https://github.com/warner/python-versioneer/issues/121
local abs_wheelhouse=$1
# Modify build version
pwd
ls
if [ "$PLAT" == "aarch64" ]
then
# when crosscompiling for aarch64, --plat-name needs to be set explicitly
# to end up with correctly named wheel file
# the value should be manylinuxABC_ARCH and dockcross docker image
# conveniently provides the value in the AUDITWHEEL_PLAT env
local plat_name_flag="--plat-name=$AUDITWHEEL_PLAT"
# override the value of EXT_SUFFIX to make sure the crosscompiled .so files in the wheel have the correct filename suffix
export PROTOCOL_BUFFERS_OVERRIDE_EXT_SUFFIX="$(python -c 'import sysconfig; print(sysconfig.get_config_var("EXT_SUFFIX").replace("-x86_64-linux-gnu.so", "-aarch64-linux-gnu.so"))')"
fi
python setup.py bdist_wheel --cpp_implementation --compile_static_extension $plat_name_flag
cp dist/*.whl $abs_wheelhouse
}
function build_wheel {
build_wheel_cmd "bdist_wheel_cmd" $@
}
function run_tests {
# Runs tests on installed distribution from an empty directory
python --version
python -c "from google.protobuf.pyext import _message;"
}
if [ "$PLAT" == "aarch64" ]
then
# when crosscompiling for aarch64, override the default multibuild's repair_wheelhouse logic
# since "auditwheel repair" doesn't work for crosscompiled wheels
function repair_wheelhouse {
echo "Skipping repair_wheelhouse since auditwheel requires build architecture to match wheel architecture."
}
fi

View File

@@ -0,0 +1,8 @@
# Config file for running tests in Kokoro
build_file: "protobuf/kokoro/release/python/linux/build_artifacts.sh"
action {
define_artifacts {
regex: "github/protobuf/artifacts/**"
}
}

View File

@@ -0,0 +1,8 @@
# Config file for running tests in Kokoro
build_file: "protobuf/kokoro/release/python/linux/build_artifacts.sh"
action {
define_artifacts {
regex: "github/protobuf/artifacts/**"
}
}

View File

@@ -1,5 +1,5 @@
# Configuration for Linux release builds
build_file: "protobuf/kokoro/release/ruby/linux/build_artifacts.sh"
build_file: "protobuf/kokoro/release/python/linux/build_artifacts.sh"
action {
define_artifacts {

View File

@@ -0,0 +1,67 @@
#!/bin/bash
set -ex
# Remove any pre-existing protobuf installation.
brew uninstall -f protobuf
# change to repo root
pushd $(dirname $0)/../../../..
# Create stage dir
ORIGINAL_DIR=`pwd`
pushd ..
cp -R $ORIGINAL_DIR stage
export STAGE_DIR="`pwd`/stage"
popd
export REPO_DIR=protobuf
export BUILD_VERSION=`grep -i "version" python/google/protobuf/__init__.py | grep -o "'.*'" | tr -d "'"`
export BUILD_COMMIT=`git rev-parse HEAD`
export PLAT=x86_64
export UNICODE_WIDTH=32
export MACOSX_DEPLOYMENT_TARGET=10.9
export TRAVIS_OS_NAME="osx"
rm -rf artifacts/
rm -rf multibuild/
mkdir artifacts
export ARTIFACT_DIR=$(pwd)/artifacts
git clone https://github.com/matthew-brett/multibuild.git
# Pin multibuild scripts at a known commit to avoid potentially unwanted future changes from
# silently creeping in (see https://github.com/protocolbuffers/protobuf/issues/9180).
# IMPORTANT: always pin multibuild at the same commit for:
# - linux/build_artifacts.sh
# - linux/build_artifacts.sh
# - windows/build_artifacts.bat
(cd multibuild; git checkout b89bb903e94308be79abefa4f436bf123ebb1313)
cp kokoro/release/python/macos/config.sh config.sh
OLD_PATH=$PATH
build_artifact_version() {
MB_PYTHON_VERSION=$1
# Clean up env
rm -rf venv
sudo rm -rf $REPO_DIR
cp -R $STAGE_DIR $REPO_DIR
export PATH=$OLD_PATH
source multibuild/common_utils.sh
source multibuild/travis_steps.sh
before_install
clean_code $REPO_DIR $BUILD_COMMIT
build_wheel $REPO_DIR/python $PLAT
mv wheelhouse/* $ARTIFACT_DIR
}
export MB_PYTHON_OSX_VER=10.9
build_artifact_version 3.7
build_artifact_version 3.8
build_artifact_version 3.9
build_artifact_version 3.10

View File

@@ -0,0 +1,67 @@
# Define custom utilities
# Test for OSX with [ -n "$IS_OSX" ]
function remove_travis_ve_pip {
# Removing the system virtualenv or pip can be very problematic for
# macOS on Kokoro, so just leave them be.
:;
}
function install_pip {
check_python
PIP_CMD="sudo $PYTHON_EXE -m pip${pip_args:+ $pip_args}"
$PIP_CMD install --upgrade pip
}
function install_virtualenv {
check_python
check_pip
$PIP_CMD install --upgrade virtualenv
VIRTUALENV_CMD="$PYTHON_EXE -m virtualenv"
}
function pre_build {
# Any stuff that you need to do before you start building the wheels
# Runs in the root directory of this repository.
pushd protobuf
# Build protoc and protobuf libraries
bazel build //:protoc
export PROTOC=$PWD/bazel-bin/protoc
mkdir src/.libs
ln -s $PWD/bazel-bin/libprotobuf.a src/.libs/libprotobuf.a
ln -s $PWD/bazel-bin/libprotobuf_lite.a src/.libs/libprotobuf-lite.a
# Generate python dependencies.
pushd python
python setup.py build_py
popd
popd
}
function bdist_wheel_cmd {
# Builds wheel with bdist_wheel, puts into wheelhouse
#
# It may sometimes be useful to use bdist_wheel for the wheel building
# process. For example, versioneer has problems with versions which are
# fixed with bdist_wheel:
# https://github.com/warner/python-versioneer/issues/121
local abs_wheelhouse=$1
# Modify build version
pwd
ls
python setup.py bdist_wheel --cpp_implementation --compile_static_extension
cp dist/*.whl $abs_wheelhouse
}
function build_wheel {
build_wheel_cmd "bdist_wheel_cmd" $@
}
function run_tests {
# Runs tests on installed distribution from an empty directory
python --version
python -c "from google.protobuf.pyext import _message;"
}

View File

@@ -1,5 +1,5 @@
# Configuration for Mac OSX release builds
build_file: "protobuf/kokoro/release/ruby/macos/build_artifacts.sh"
build_file: "protobuf/kokoro/release/python/macos/build_artifacts.sh"
action {
define_artifacts {

View File

@@ -0,0 +1,8 @@
# Configuration for Mac OSX release builds
build_file: "protobuf/kokoro/release/python/macos/build_artifacts.sh"
action {
define_artifacts {
regex: "github/protobuf/artifacts/**"
}
}

View File

@@ -0,0 +1,8 @@
# Configuration for Mac OSX release builds
build_file: "protobuf/kokoro/release/python/macos/build_artifacts.sh"
action {
define_artifacts {
regex: "github/protobuf/artifacts/**"
}
}

View File

@@ -0,0 +1,88 @@
REM Move scripts to root
set REPO_DIR_STAGE=%cd%\github\protobuf-stage
xcopy /S github\protobuf "%REPO_DIR_STAGE%\"
cd github\protobuf
copy kokoro\release\python\windows\build_single_artifact.bat build_single_artifact.bat
REM Set environment variables
set PACKAGE_NAME=protobuf
set REPO_DIR=protobuf
set BUILD_DLL=OFF
set UNICODE=ON
set OTHER_TEST_DEP="setuptools==38.5.1"
set OLD_PATH=C:\Program Files (x86)\MSBuild\14.0\bin\;%PATH%
REM Fetch multibuild
git clone https://github.com/matthew-brett/multibuild.git
REM Pin multibuild scripts at a known commit to avoid potentially unwanted future changes from
REM silently creeping in (see https://github.com/protocolbuffers/protobuf/issues/9180).
REM IMPORTANT: always pin multibuild at the same commit for:
REM - linux/build_artifacts.sh
REM - linux/build_artifacts.sh
REM - windows/build_artifacts.bat
cd multibuild
git checkout b89bb903e94308be79abefa4f436bf123ebb1313
cd ..
REM Install zlib
mkdir zlib
curl -L -o zlib.zip http://www.winimage.com/zLibDll/zlib123dll.zip
curl -L -o zlib-src.zip http://www.winimage.com/zLibDll/zlib123.zip
7z x zlib.zip -ozlib
7z x zlib-src.zip -ozlib\include
SET ZLIB_ROOT=%cd%\zlib
del /Q zlib.zip
del /Q zlib-src.zip
REM Create directory for artifacts
SET ARTIFACT_DIR=%cd%\artifacts
mkdir %ARTIFACT_DIR%
REM Build wheel
SET PYTHON=C:\python37_32bit
SET PYTHON_VERSION=3.7
SET PYTHON_ARCH=32
CALL build_single_artifact.bat || goto :error
SET PYTHON=C:\python37
SET PYTHON_VERSION=3.7
SET PYTHON_ARCH=64
CALL build_single_artifact.bat || goto :error
powershell -File kokoro/release/python/windows/install_python_interpreters.ps1
SET PYTHON=C:\python38_32bit
SET PYTHON_VERSION=3.8
SET PYTHON_ARCH=32
CALL build_single_artifact.bat || goto :error
SET PYTHON=C:\python38
SET PYTHON_VERSION=3.8
SET PYTHON_ARCH=64
CALL build_single_artifact.bat || goto :error
SET PYTHON=C:\python39_32bit
SET PYTHON_VERSION=3.9
SET PYTHON_ARCH=32
CALL build_single_artifact.bat || goto :error
SET PYTHON=C:\python39
SET PYTHON_VERSION=3.9
SET PYTHON_ARCH=64
CALL build_single_artifact.bat || goto :error
SET PYTHON=C:\python310_32bit
SET PYTHON_VERSION=3.10
SET PYTHON_ARCH=32
CALL build_single_artifact.bat || goto :error
SET PYTHON=C:\python310
SET PYTHON_VERSION=3.10
SET PYTHON_ARCH=64
CALL build_single_artifact.bat || goto :error
goto :EOF
:error
exit /b %errorlevel%

View File

@@ -0,0 +1,78 @@
setlocal
if %PYTHON%==C:\python37_32bit set generator=Visual Studio 14
if %PYTHON%==C:\python37_32bit set vcplatform=Win32
if %PYTHON%==C:\python37 set generator=Visual Studio 14 Win64
if %PYTHON%==C:\python37 set vcplatform=x64
if %PYTHON%==C:\python38_32bit set generator=Visual Studio 14
if %PYTHON%==C:\python38_32bit set vcplatform=Win32
if %PYTHON%==C:\python38 set generator=Visual Studio 14 Win64
if %PYTHON%==C:\python38 set vcplatform=x64
if %PYTHON%==C:\python39_32bit set generator=Visual Studio 14
if %PYTHON%==C:\python39_32bit set vcplatform=Win32
if %PYTHON%==C:\python39 set generator=Visual Studio 14 Win64
if %PYTHON%==C:\python39 set vcplatform=x64
if %PYTHON%==C:\python310_32bit set generator=Visual Studio 14
if %PYTHON%==C:\python310_32bit set vcplatform=Win32
if %PYTHON%==C:\python310 set generator=Visual Studio 14 Win64
if %PYTHON%==C:\python310 set vcplatform=x64
REM Prepend newly installed Python to the PATH of this build (this cannot be
REM done from inside the powershell script as it would require to restart
REM the parent CMD process).
SET PATH=C:\Program Files\CMake\bin;%PYTHON%;%PYTHON%\Scripts;%OLD_PATH%
python -m pip install -U pip
pip install wheel
REM Check that we have the expected version and architecture for Python
python --version
python -c "import struct; print(struct.calcsize('P') * 8)"
rmdir /s/q %REPO_DIR%
xcopy /s %REPO_DIR_STAGE% "%REPO_DIR%\"
REM Checkout release commit
cd %REPO_DIR%
REM ======================
REM Build Protobuf Library
REM ======================
mkdir src\.libs
mkdir vcprojects
pushd vcprojects
cmake -G "%generator%" -Dprotobuf_BUILD_SHARED_LIBS=%BUILD_DLL% -Dprotobuf_UNICODE=%UNICODE% -Dprotobuf_BUILD_TESTS=OFF ../cmake || goto :error
msbuild protobuf.sln /p:Platform=%vcplatform% /p:Configuration=Release || goto :error
dir /s /b
popd
copy vcprojects\Release\libprotobuf.lib src\.libs\libprotobuf.a
copy vcprojects\Release\libprotobuf-lite.lib src\.libs\libprotobuf-lite.a
SET PATH=%cd%\vcprojects\Release;%PATH%
dir vcprojects\Release
REM ======================
REM Build python library
REM ======================
cd python
REM sed -i 's/\ extra_compile_args\ =\ \[\]/\ extra_compile_args\ =\ \[\'\/MT\'\]/g' setup.py
python setup.py bdist_wheel --cpp_implementation --compile_static_extension
dir dist
copy dist\* %ARTIFACT_DIR%
dir %ARTIFACT_DIR%
cd ..\..
goto :EOF
:error
exit /b %errorlevel%

View File

@@ -0,0 +1,8 @@
# Configuration for Windows protoc release builds
build_file: "protobuf/kokoro/release/python/windows/build_artifacts.bat"
action {
define_artifacts {
regex: "github/protobuf/artifacts/**"
}
}

View File

@@ -0,0 +1,114 @@
#!/usr/bin/env powershell
# Install Python 3.8 for x64 and x86 in order to build wheels on Windows.
# Originally from grpc/tools/internal_ci/helper_scripts/install_python_interpreters.ps1
Set-StrictMode -Version 2
$ErrorActionPreference = 'Stop'
trap {
$ErrorActionPreference = "Continue"
Write-Error $_
exit 1
}
# Avoid "Could not create SSL/TLS secure channel"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
function Install-Python {
Param(
[string]$PythonVersion,
[string]$PythonInstaller,
[string]$PythonInstallPath,
[string]$PythonInstallerHash
)
$PythonInstallerUrl = "https://www.python.org/ftp/python/$PythonVersion/$PythonInstaller.exe"
$PythonInstallerPath = "C:\tools\$PythonInstaller.exe"
# Downloads installer
Write-Host "Downloading the Python installer: $PythonInstallerUrl => $PythonInstallerPath"
Invoke-WebRequest -Uri $PythonInstallerUrl -OutFile $PythonInstallerPath
# Validates checksum
$HashFromDownload = Get-FileHash -Path $PythonInstallerPath -Algorithm MD5
if ($HashFromDownload.Hash -ne $PythonInstallerHash) {
throw "Invalid Python installer: failed checksum!"
}
Write-Host "Python installer $PythonInstallerPath validated."
# Installs Python
& $PythonInstallerPath /passive InstallAllUsers=1 PrependPath=1 Include_test=0 TargetDir=$PythonInstallPath
if (-Not $?) {
throw "The Python installation exited with error!"
}
# NOTE(lidiz) Even if the install command finishes in the script, that
# doesn't mean the Python installation is finished. If using "ps" to check
# for running processes, you might see ongoing installers at this point.
# So, we needs this "hack" to reliably validate that the Python binary is
# functioning properly.
# Wait for the installer process
Wait-Process -Name $PythonInstaller -Timeout 300
Write-Host "Installation process exits normally."
# Validate Python binary
$PythonBinary = "$PythonInstallPath\python.exe"
& $PythonBinary -c 'print(42)'
Write-Host "Python binary works properly."
# Installs pip
& $PythonBinary -m ensurepip --user
Write-Host "Python $PythonVersion installed by $PythonInstaller at $PythonInstallPath."
}
# Python 3.8
$Python38x86Config = @{
PythonVersion = "3.8.0"
PythonInstaller = "python-3.8.0"
PythonInstallPath = "C:\python38_32bit"
PythonInstallerHash = "412a649d36626d33b8ca5593cf18318c"
}
Install-Python @Python38x86Config
$Python38x64Config = @{
PythonVersion = "3.8.0"
PythonInstaller = "python-3.8.0-amd64"
PythonInstallPath = "C:\python38"
PythonInstallerHash = "29ea87f24c32f5e924b7d63f8a08ee8d"
}
Install-Python @Python38x64Config
# Python 3.9
$Python39x86Config = @{
PythonVersion = "3.9.0"
PythonInstaller = "python-3.9.0"
PythonInstallPath = "C:\python39_32bit"
PythonInstallerHash = "4a2812db8ab9f2e522c96c7728cfcccb"
}
Install-Python @Python39x86Config
$Python39x64Config = @{
PythonVersion = "3.9.0"
PythonInstaller = "python-3.9.0-amd64"
PythonInstallPath = "C:\python39"
PythonInstallerHash = "b61a33dc28f13b561452f3089c87eb63"
}
Install-Python @Python39x64Config
# Python 3.10
$Python310x86Config = @{
PythonVersion = "3.10.0"
PythonInstaller = "python-3.10.0"
PythonInstallPath = "C:\python310_32bit"
PythonInstallerHash = "133aa48145032e341ad2a000cd3bff50"
}
Install-Python @Python310x86Config
$Python310x64Config = @{
PythonVersion = "3.10.0"
PythonInstaller = "python-3.10.0-amd64"
PythonInstallPath = "C:\python310"
PythonInstallerHash = "c3917c08a7fe85db7203da6dcaa99a70"
}
Install-Python @Python310x64Config

View File

@@ -0,0 +1,8 @@
# Configuration for Windows protoc release builds
build_file: "protobuf/kokoro/release/python/windows/build_artifacts.bat"
action {
define_artifacts {
regex: "github/protobuf/artifacts/**"
}
}

View File

@@ -0,0 +1,8 @@
# Configuration for Windows protoc release builds
build_file: "protobuf/kokoro/release/python/windows/build_artifacts.bat"
action {
define_artifacts {
regex: "github/protobuf/artifacts/**"
}
}

View File

@@ -1 +1,8 @@
# Keep this file empty! Use common.cfg instead.
# Configuration for Linux release builds
build_file: "protobuf/kokoro/release/ruby/linux/build_artifacts.sh"
action {
define_artifacts {
regex: "github/protobuf/artifacts/**"
}
}

View File

@@ -1 +1,8 @@
# Keep this file empty! Use common.cfg instead.
# Configuration for Linux release builds
build_file: "protobuf/kokoro/release/ruby/linux/build_artifacts.sh"
action {
define_artifacts {
regex: "github/protobuf/artifacts/**"
}
}

View File

@@ -5,13 +5,8 @@ set -ex
# Build protoc
use_bazel.sh 5.1.1
bazel build //:protoc
# The java build setup expects protoc in the root directory.
cp bazel-bin/protoc .
export PROTOC=$PWD/protoc
# Pull in dependencies.
git submodule update --init --recursive
cp bazel-bin/protoc src/protoc
export PROTOC=$PWD/src/protoc
umask 0022
pushd ruby

View File

@@ -1 +1,8 @@
# Keep this file empty! Use common.cfg instead.
# Configuration for Mac OSX release builds
build_file: "protobuf/kokoro/release/ruby/macos/build_artifacts.sh"
action {
define_artifacts {
regex: "github/protobuf/artifacts/**"
}
}

View File

@@ -1 +1,8 @@
# Keep this file empty! Use common.cfg instead.
# Configuration for Mac OSX release builds
build_file: "protobuf/kokoro/release/ruby/macos/build_artifacts.sh"
action {
define_artifacts {
regex: "github/protobuf/artifacts/**"
}
}

View File

@@ -6,9 +6,6 @@ set -ex
bazel build //:protoc
export PROTOC=$PWD/bazel-bin/protoc
# Pull in dependencies.
git submodule update --init --recursive
umask 0022
pushd ruby
bundle update && bundle exec rake gem:native

View File

@@ -8,9 +8,13 @@ sudo chown -R $(whoami) /Library/Ruby/
set +ex # rvm script is very verbose and exits with errorcode
# Fix permissions
sudo chown -R $(whoami) $HOME/.rvm/
sudo chown -R $(whoami) /Library/Ruby/
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
# Old OpenSSL versions cannot handle the SSL certificate used by
# https://get.rvm.io, so as a workaround we download RVM directly from
# GitHub. See this issue for details: https://github.com/rvm/rvm/issues/5133
curl -sSL https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer | bash -s master --ruby
source $HOME/.rvm/scripts/rvm
set -e # rvm commands are very verbose