mirror of https://github.com/grpc/grpc-java.git
buildscripts: build macos artifacts in kokoro (#4066)
This commit is contained in:
parent
8925921805
commit
fbc079d631
|
|
@ -3,3 +3,10 @@
|
||||||
# Location of the continuous shell script in repository.
|
# Location of the continuous shell script in repository.
|
||||||
build_file: "grpc-java/buildscripts/kokoro/unix.sh"
|
build_file: "grpc-java/buildscripts/kokoro/unix.sh"
|
||||||
timeout_mins: 45
|
timeout_mins: 45
|
||||||
|
|
||||||
|
# We always build artifacts, but we only copy them here when MVN_ARTIFACTS is set in unix.sh
|
||||||
|
action {
|
||||||
|
define_artifacts {
|
||||||
|
regex: ["**/mvn-artifacts/**"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,72 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# This file is used for both Linux and MacOS builds.
|
# This file is used for both Linux and MacOS builds.
|
||||||
# TODO(zpencer): test this script for Linux
|
# To run locally:
|
||||||
|
# ./buildscripts/kokoro/unix.sh
|
||||||
|
# Optionally set MVN_ARTIFACTS=true to retain artifacts
|
||||||
|
|
||||||
# This script assumes `set -e`. Removing it may lead to undefined behavior.
|
# This script assumes `set -e`. Removing it may lead to undefined behavior.
|
||||||
set -exu -o pipefail
|
set -exu -o pipefail
|
||||||
cat /VERSION
|
|
||||||
|
|
||||||
export GRADLE_OPTS=-Xmx512m
|
if [[ -f /VERSION ]]; then
|
||||||
export PROTOBUF_VERSION=3.5.1
|
cat /VERSION
|
||||||
export LDFLAGS=-L/tmp/protobuf/lib
|
fi
|
||||||
export CXXFLAGS=-I/tmp/protobuf/include
|
|
||||||
export LD_LIBRARY_PATH=/tmp/protobuf/lib
|
|
||||||
export OS_NAME=$(uname)
|
|
||||||
|
|
||||||
cd ./github/grpc-java
|
# cd to the root dir of grpc-java
|
||||||
|
cd $(dirname $0)/../..
|
||||||
|
|
||||||
# TODO(zpencer): always make sure we are using Oracle jdk8
|
# TODO(zpencer): always make sure we are using Oracle jdk8
|
||||||
|
|
||||||
# Proto deps
|
# Proto deps
|
||||||
buildscripts/make_dependencies.sh
|
export PROTOBUF_VERSION=3.5.1
|
||||||
ln -s "/tmp/protobuf-${PROTOBUF_VERSION}/$(uname -s)-$(uname -p)" /tmp/protobuf
|
|
||||||
|
|
||||||
# Gradle build config
|
# TODO(zpencer): if linux builds use this script, then also repeat this process for 32bit (-m32)
|
||||||
mkdir -p $HOME/.gradle
|
# Today, only macos uses this script and macos targets 64bit only
|
||||||
echo "checkstyle.ignoreFailures=false" >> $HOME/.gradle/gradle.properties
|
|
||||||
echo "failOnWarnings=true" >> $HOME/.gradle/gradle.properties
|
CXX_FLAGS="-m64" LDFLAGS="" LD_LIBRARY_PATH="" buildscripts/make_dependencies.sh
|
||||||
echo "errorProne=true" >> $HOME/.gradle/gradle.properties
|
|
||||||
|
# the install dir is hardcoded in make_dependencies.sh
|
||||||
|
PROTO_INSTALL_DIR="/tmp/protobuf-${PROTOBUF_VERSION}/$(uname -s)-$(uname -p)"
|
||||||
|
|
||||||
|
if [[ ! -e /tmp/protobuf ]]; then
|
||||||
|
ln -s $PROTO_INSTALL_DIR /tmp/protobuf;
|
||||||
|
fi
|
||||||
|
|
||||||
|
# It's better to use 'readlink -f' but it's not available on macos
|
||||||
|
if [[ "$(readlink /tmp/protobuf)" != "$PROTO_INSTALL_DIR" ]]; then
|
||||||
|
echo "/tmp/protobuf already exists but is not a symlink to $PROTO_INSTALL_DIR"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set properties via flags, do not pollute gradle.properties
|
||||||
|
GRADLE_FLAGS="${GRADLE_FLAGS:-}"
|
||||||
|
GRADLE_FLAGS+=" -Pcheckstyle.ignoreFailures=false"
|
||||||
|
GRADLE_FLAGS+=" -PfailOnWarnings=true"
|
||||||
|
GRADLE_FLAGS+=" -PerrorProne=true"
|
||||||
|
export GRADLE_OPTS="-Xmx512m"
|
||||||
|
|
||||||
|
# Make protobuf discoverable by :grpc-compiler
|
||||||
|
export LD_LIBRARY_PATH=/tmp/protobuf/lib
|
||||||
|
export LDFLAGS=-L/tmp/protobuf/lib
|
||||||
|
export CXXFLAGS="-I/tmp/protobuf/include"
|
||||||
|
|
||||||
# Run tests
|
# Run tests
|
||||||
./gradlew assemble generateTestProto install
|
./gradlew assemble generateTestProto install $GRADLE_FLAGS
|
||||||
pushd examples
|
pushd examples
|
||||||
./gradlew build
|
./gradlew build $GRADLE_FLAGS
|
||||||
# --batch-mode reduces log spam
|
# --batch-mode reduces log spam
|
||||||
mvn verify --batch-mode
|
mvn verify --batch-mode
|
||||||
popd
|
popd
|
||||||
# TODO(zpencer): also build the GAE examples
|
# TODO(zpencer): also build the GAE examples
|
||||||
|
|
||||||
|
LOCAL_MVN_TEMP=$(mktemp -d)
|
||||||
|
./gradlew clean grpc-compiler:build grpc-compiler:uploadArchives -PtargetArch=x86_64 \
|
||||||
|
-Dorg.gradle.parallel=false -PrepositoryDir=$LOCAL_MVN_TEMP $GRADLE_FLAGS
|
||||||
|
|
||||||
|
if [[ -z "${MVN_ARTIFACTS:-}" ]]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
MVN_ARTIFACT_DIR="$PWD/mvn-artifacts"
|
||||||
|
mkdir $MVN_ARTIFACT_DIR
|
||||||
|
mv $LOCAL_MVN_TEMP/* $MVN_ARTIFACT_DIR
|
||||||
|
rmdir $LOCAL_MVN_TEMP
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ else
|
||||||
pushd $DOWNLOAD_DIR/protobuf-${PROTOBUF_VERSION}
|
pushd $DOWNLOAD_DIR/protobuf-${PROTOBUF_VERSION}
|
||||||
./autogen.sh
|
./autogen.sh
|
||||||
# install here so we don't need sudo
|
# install here so we don't need sudo
|
||||||
./configure --prefix="$INSTALL_DIR"
|
./configure --disable-shared --prefix="$INSTALL_DIR"
|
||||||
make -j$NUM_CPU
|
make -j$NUM_CPU
|
||||||
make install
|
make install
|
||||||
popd
|
popd
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue