2016-02-19 04:10:23 +00:00
|
|
|
#!/bin/bash
|
2016-03-04 22:21:18 +00:00
|
|
|
#
|
|
|
|
# Build and runs tests for the protobuf project. The tests as written here are
|
|
|
|
# used by both Jenkins and Travis, though some specialized logic is required to
|
|
|
|
# handle the differences between them.
|
2015-06-09 17:35:41 +00:00
|
|
|
|
2016-02-19 17:11:38 +00:00
|
|
|
on_travis() {
|
|
|
|
if [ "$TRAVIS" == "true" ]; then
|
|
|
|
"$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-07-15 18:05:10 +00:00
|
|
|
# For when some other test needs the C++ main build, including protoc and
|
|
|
|
# libprotobuf.
|
|
|
|
internal_build_cpp() {
|
2016-02-19 04:10:23 +00:00
|
|
|
if [ -f src/protoc ]; then
|
|
|
|
# Already built.
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2016-02-19 03:13:07 +00:00
|
|
|
if [[ $(uname -s) == "Linux" && "$TRAVIS" == "true" ]]; then
|
2015-12-21 11:34:28 +00:00
|
|
|
# Install GCC 4.8 to replace the default GCC 4.6. We need 4.8 for more
|
|
|
|
# decent C++ 11 support in order to compile conformance tests.
|
|
|
|
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
|
|
|
|
sudo apt-get update -qq
|
|
|
|
sudo apt-get install -qq g++-4.8
|
|
|
|
export CXX="g++-4.8" CC="gcc-4.8"
|
|
|
|
fi
|
2015-12-18 23:16:07 +00:00
|
|
|
|
2015-05-13 23:43:48 +00:00
|
|
|
./autogen.sh
|
|
|
|
./configure
|
2016-03-04 22:21:18 +00:00
|
|
|
make -j2
|
2015-07-15 18:05:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
build_cpp() {
|
|
|
|
internal_build_cpp
|
2016-03-04 22:21:18 +00:00
|
|
|
make check -j2
|
2015-05-13 23:43:48 +00:00
|
|
|
cd conformance && make test_cpp && cd ..
|
2016-04-29 16:52:20 +00:00
|
|
|
|
|
|
|
# Verify benchmarking code can build successfully.
|
2016-04-29 17:19:03 +00:00
|
|
|
cd benchmarks && make && ./generate-datasets && cd ..
|
2015-05-13 23:43:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
build_cpp_distcheck() {
|
|
|
|
./autogen.sh
|
|
|
|
./configure
|
2016-03-04 22:21:18 +00:00
|
|
|
make distcheck -j2
|
2015-05-13 23:43:48 +00:00
|
|
|
}
|
|
|
|
|
2015-05-19 00:34:02 +00:00
|
|
|
build_csharp() {
|
2015-08-04 09:01:40 +00:00
|
|
|
# Just for the conformance tests. We don't currently
|
|
|
|
# need to really build protoc, but it's simplest to keep with the
|
|
|
|
# conventions of the other builds.
|
|
|
|
internal_build_cpp
|
2016-02-22 23:39:29 +00:00
|
|
|
NUGET=/usr/local/bin/nuget.exe
|
2015-08-04 09:01:40 +00:00
|
|
|
|
2016-02-22 23:39:29 +00:00
|
|
|
if [ "$TRAVIS" == "true" ]; then
|
|
|
|
# Install latest version of Mono
|
|
|
|
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
|
|
|
|
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
|
|
|
|
echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list
|
|
|
|
sudo apt-get update -qq
|
|
|
|
sudo apt-get install -qq mono-devel referenceassemblies-pcl nunit
|
|
|
|
wget www.nuget.org/NuGet.exe -O nuget.exe
|
|
|
|
NUGET=../../nuget.exe
|
|
|
|
fi
|
2015-05-19 00:34:02 +00:00
|
|
|
|
2016-02-22 23:39:29 +00:00
|
|
|
(cd csharp/src; mono $NUGET restore)
|
2015-05-19 00:34:02 +00:00
|
|
|
csharp/buildall.sh
|
2015-12-31 00:03:49 +00:00
|
|
|
cd conformance && make test_csharp && cd ..
|
2015-05-19 00:34:02 +00:00
|
|
|
}
|
|
|
|
|
2015-11-20 23:32:53 +00:00
|
|
|
build_golang() {
|
|
|
|
# Go build needs `protoc`.
|
|
|
|
internal_build_cpp
|
|
|
|
# Add protoc to the path so that the examples build finds it.
|
|
|
|
export PATH="`pwd`/src:$PATH"
|
|
|
|
|
|
|
|
# Install Go and the Go protobuf compiler plugin.
|
|
|
|
sudo apt-get update -qq
|
|
|
|
sudo apt-get install -qq golang
|
|
|
|
export GOPATH="$HOME/gocode"
|
|
|
|
mkdir -p "$GOPATH/src/github.com/google"
|
|
|
|
ln -s "`pwd`" "$GOPATH/src/github.com/google/protobuf"
|
|
|
|
export PATH="$GOPATH/bin:$PATH"
|
|
|
|
go get github.com/golang/protobuf/protoc-gen-go
|
|
|
|
|
|
|
|
cd examples && make gotest && cd ..
|
|
|
|
}
|
|
|
|
|
2015-05-13 23:43:48 +00:00
|
|
|
use_java() {
|
|
|
|
version=$1
|
|
|
|
case "$version" in
|
|
|
|
jdk6)
|
2016-02-19 17:11:38 +00:00
|
|
|
on_travis sudo apt-get install openjdk-6-jdk
|
2015-05-13 23:43:48 +00:00
|
|
|
export PATH=/usr/lib/jvm/java-6-openjdk-amd64/bin:$PATH
|
|
|
|
;;
|
|
|
|
jdk7)
|
2016-02-19 17:11:38 +00:00
|
|
|
on_travis sudo apt-get install openjdk-7-jdk
|
2015-05-13 23:43:48 +00:00
|
|
|
export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
|
|
|
|
;;
|
|
|
|
oracle7)
|
2016-02-22 23:39:29 +00:00
|
|
|
if [ "$TRAVIS" == "true" ]; then
|
|
|
|
sudo apt-get install python-software-properties # for apt-add-repository
|
|
|
|
echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select true" | \
|
|
|
|
sudo debconf-set-selections
|
|
|
|
yes | sudo apt-add-repository ppa:webupd8team/java
|
|
|
|
yes | sudo apt-get install oracle-java7-installer
|
|
|
|
fi;
|
2015-05-13 23:43:48 +00:00
|
|
|
export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2016-03-04 00:02:55 +00:00
|
|
|
if [ "$TRAVIS" != "true" ]; then
|
|
|
|
MAVEN_LOCAL_REPOSITORY=/var/maven_local_repository
|
|
|
|
MVN="$MVN -e -X --offline -Dmaven.repo.local=$MAVEN_LOCAL_REPOSITORY"
|
|
|
|
fi;
|
|
|
|
|
2015-05-13 23:43:48 +00:00
|
|
|
which java
|
|
|
|
java -version
|
|
|
|
}
|
|
|
|
|
2016-02-20 20:03:39 +00:00
|
|
|
# --batch-mode supresses download progress output that spams the logs.
|
2016-02-20 20:17:10 +00:00
|
|
|
MVN="mvn --batch-mode"
|
2016-02-20 20:03:39 +00:00
|
|
|
|
2015-05-13 23:43:48 +00:00
|
|
|
build_java() {
|
2016-03-01 23:37:17 +00:00
|
|
|
version=$1
|
|
|
|
dir=java_$version
|
2015-12-21 19:08:18 +00:00
|
|
|
# Java build needs `protoc`.
|
|
|
|
internal_build_cpp
|
2016-03-01 23:37:17 +00:00
|
|
|
cp -r java $dir
|
|
|
|
cd $dir && $MVN clean && $MVN test
|
2015-12-21 19:08:18 +00:00
|
|
|
cd ../..
|
|
|
|
}
|
|
|
|
|
2016-03-01 23:37:17 +00:00
|
|
|
# The conformance tests are hard-coded to work with the $ROOT/java directory.
|
|
|
|
# So this can't run in parallel with two different sets of tests.
|
2015-12-21 19:08:18 +00:00
|
|
|
build_java_with_conformance_tests() {
|
2015-05-13 23:43:48 +00:00
|
|
|
# Java build needs `protoc`.
|
2015-07-15 18:05:10 +00:00
|
|
|
internal_build_cpp
|
2016-02-20 20:03:39 +00:00
|
|
|
cd java && $MVN test && $MVN install
|
2016-03-01 23:37:17 +00:00
|
|
|
cd util && $MVN package assembly:single
|
2015-12-21 11:25:59 +00:00
|
|
|
cd ../..
|
2015-05-13 23:43:48 +00:00
|
|
|
cd conformance && make test_java && cd ..
|
|
|
|
}
|
|
|
|
|
|
|
|
build_javanano() {
|
|
|
|
# Java build needs `protoc`.
|
2015-07-15 18:05:10 +00:00
|
|
|
internal_build_cpp
|
2016-02-20 20:17:10 +00:00
|
|
|
cd javanano && $MVN test && cd ..
|
2015-05-13 23:43:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
build_java_jdk6() {
|
|
|
|
use_java jdk6
|
2016-03-01 23:37:17 +00:00
|
|
|
build_java jdk6
|
2015-05-13 23:43:48 +00:00
|
|
|
}
|
|
|
|
build_java_jdk7() {
|
|
|
|
use_java jdk7
|
2015-12-21 19:08:18 +00:00
|
|
|
build_java_with_conformance_tests
|
2015-05-13 23:43:48 +00:00
|
|
|
}
|
|
|
|
build_java_oracle7() {
|
|
|
|
use_java oracle7
|
2016-03-01 23:37:17 +00:00
|
|
|
build_java oracle7
|
2015-05-13 23:43:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
build_javanano_jdk6() {
|
|
|
|
use_java jdk6
|
|
|
|
build_javanano
|
|
|
|
}
|
|
|
|
build_javanano_jdk7() {
|
|
|
|
use_java jdk7
|
|
|
|
build_javanano
|
|
|
|
}
|
|
|
|
build_javanano_oracle7() {
|
|
|
|
use_java oracle7
|
|
|
|
build_javanano
|
|
|
|
}
|
|
|
|
|
2015-08-20 22:19:56 +00:00
|
|
|
internal_install_python_deps() {
|
2016-02-19 20:48:33 +00:00
|
|
|
if [ "$TRAVIS" != "true" ]; then
|
|
|
|
return;
|
|
|
|
fi
|
2015-06-10 21:21:23 +00:00
|
|
|
# Install tox (OS X doesn't have pip).
|
|
|
|
if [ $(uname -s) == "Darwin" ]; then
|
|
|
|
sudo easy_install tox
|
|
|
|
else
|
|
|
|
sudo pip install tox
|
|
|
|
fi
|
2015-08-27 00:30:41 +00:00
|
|
|
# Only install Python2.6/3.x on Linux.
|
2015-08-21 22:51:47 +00:00
|
|
|
if [ $(uname -s) == "Linux" ]; then
|
|
|
|
sudo apt-get install -y python-software-properties # for apt-add-repository
|
|
|
|
sudo apt-add-repository -y ppa:fkrull/deadsnakes
|
|
|
|
sudo apt-get update -qq
|
|
|
|
sudo apt-get install -y python2.6 python2.6-dev
|
2015-08-27 00:30:41 +00:00
|
|
|
sudo apt-get install -y python3.3 python3.3-dev
|
|
|
|
sudo apt-get install -y python3.4 python3.4-dev
|
2015-08-21 22:51:47 +00:00
|
|
|
fi
|
2015-08-20 22:19:56 +00:00
|
|
|
}
|
|
|
|
|
2016-05-24 15:27:33 +00:00
|
|
|
build_objectivec_ios() {
|
2015-11-09 19:21:51 +00:00
|
|
|
# Reused the build script that takes care of configuring and ensuring things
|
2016-05-24 15:27:33 +00:00
|
|
|
# are up to date. The OS X test runs the objc conformance test, so skip it
|
|
|
|
# here.
|
|
|
|
# Note: travis has xctool installed, and we've looked at using it in the past
|
|
|
|
# but it has ended up proving unreliable (bugs), an they are removing build
|
|
|
|
# support in favor of xcbuild (or just xcodebuild).
|
2015-11-17 15:18:49 +00:00
|
|
|
objectivec/DevTools/full_mac_build.sh \
|
2016-05-24 15:27:33 +00:00
|
|
|
--core-only --skip-xcode-osx --skip-objc-conformance "$@"
|
2015-11-09 19:21:51 +00:00
|
|
|
}
|
|
|
|
|
2016-05-24 15:27:33 +00:00
|
|
|
build_objectivec_ios_debug() {
|
|
|
|
build_objectivec_ios --skip-xcode-release
|
2015-06-10 21:21:23 +00:00
|
|
|
}
|
|
|
|
|
2016-05-24 15:27:33 +00:00
|
|
|
build_objectivec_ios_release() {
|
|
|
|
build_objectivec_ios --skip-xcode-debug
|
2015-06-10 21:21:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
build_objectivec_osx() {
|
2016-05-24 15:27:33 +00:00
|
|
|
# Reused the build script that takes care of configuring and ensuring things
|
|
|
|
# are up to date.
|
|
|
|
objectivec/DevTools/full_mac_build.sh \
|
|
|
|
--core-only --skip-xcode-ios
|
2015-06-10 21:21:23 +00:00
|
|
|
}
|
2015-08-20 22:19:56 +00:00
|
|
|
|
2015-05-13 23:43:48 +00:00
|
|
|
build_python() {
|
2015-07-15 18:05:10 +00:00
|
|
|
internal_build_cpp
|
2015-08-20 22:19:56 +00:00
|
|
|
internal_install_python_deps
|
2015-05-13 23:43:48 +00:00
|
|
|
cd python
|
2015-08-27 00:30:41 +00:00
|
|
|
# Only test Python 2.6/3.x on Linux
|
2015-08-21 22:51:47 +00:00
|
|
|
if [ $(uname -s) == "Linux" ]; then
|
2015-10-10 00:07:03 +00:00
|
|
|
envlist=py\{26,27,33,34\}-python
|
2015-08-21 22:51:47 +00:00
|
|
|
else
|
|
|
|
envlist=py27-python
|
|
|
|
fi
|
|
|
|
tox -e $envlist
|
2015-05-13 23:43:48 +00:00
|
|
|
cd ..
|
|
|
|
}
|
|
|
|
|
|
|
|
build_python_cpp() {
|
2015-07-15 18:05:10 +00:00
|
|
|
internal_build_cpp
|
2015-08-20 22:19:56 +00:00
|
|
|
internal_install_python_deps
|
|
|
|
export LD_LIBRARY_PATH=../src/.libs # for Linux
|
2015-05-15 01:32:39 +00:00
|
|
|
export DYLD_LIBRARY_PATH=../src/.libs # for OS X
|
2015-05-13 23:43:48 +00:00
|
|
|
cd python
|
2015-08-27 00:30:41 +00:00
|
|
|
# Only test Python 2.6/3.x on Linux
|
2015-08-21 22:51:47 +00:00
|
|
|
if [ $(uname -s) == "Linux" ]; then
|
2015-10-06 17:48:57 +00:00
|
|
|
# py26 is currently disabled due to json_format
|
|
|
|
envlist=py\{27,33,34\}-cpp
|
2015-08-21 22:51:47 +00:00
|
|
|
else
|
|
|
|
envlist=py27-cpp
|
|
|
|
fi
|
|
|
|
tox -e $envlist
|
2015-05-13 23:43:48 +00:00
|
|
|
cd ..
|
|
|
|
}
|
|
|
|
|
|
|
|
build_ruby19() {
|
2015-07-15 18:05:10 +00:00
|
|
|
internal_build_cpp # For conformance tests.
|
2015-05-13 23:43:48 +00:00
|
|
|
cd ruby && bash travis-test.sh ruby-1.9 && cd ..
|
|
|
|
}
|
|
|
|
build_ruby20() {
|
2015-07-15 18:05:10 +00:00
|
|
|
internal_build_cpp # For conformance tests.
|
2015-05-13 23:43:48 +00:00
|
|
|
cd ruby && bash travis-test.sh ruby-2.0 && cd ..
|
|
|
|
}
|
|
|
|
build_ruby21() {
|
2015-07-15 18:05:10 +00:00
|
|
|
internal_build_cpp # For conformance tests.
|
2015-05-13 23:43:48 +00:00
|
|
|
cd ruby && bash travis-test.sh ruby-2.1 && cd ..
|
|
|
|
}
|
|
|
|
build_ruby22() {
|
2015-07-15 18:05:10 +00:00
|
|
|
internal_build_cpp # For conformance tests.
|
2015-05-13 23:43:48 +00:00
|
|
|
cd ruby && bash travis-test.sh ruby-2.2 && cd ..
|
|
|
|
}
|
|
|
|
build_jruby() {
|
2015-07-15 18:05:10 +00:00
|
|
|
internal_build_cpp # For conformance tests.
|
2015-05-13 23:43:48 +00:00
|
|
|
cd ruby && bash travis-test.sh jruby && cd ..
|
|
|
|
}
|
|
|
|
|
2015-12-21 23:18:17 +00:00
|
|
|
build_javascript() {
|
|
|
|
internal_build_cpp
|
2015-12-28 14:43:42 +00:00
|
|
|
cd js && npm install && npm test && cd ..
|
2015-12-21 23:18:17 +00:00
|
|
|
}
|
|
|
|
|
2016-02-19 04:10:23 +00:00
|
|
|
# Note: travis currently does not support testing more than one language so the
|
|
|
|
# .travis.yml cheats and claims to only be cpp. If they add multiple language
|
|
|
|
# support, this should probably get updated to install steps and/or
|
|
|
|
# rvm/gemfile/jdk/etc. entries rather than manually doing the work.
|
|
|
|
|
|
|
|
# .travis.yml uses matrix.exclude to block the cases where app-get can't be
|
|
|
|
# use to install things.
|
|
|
|
|
|
|
|
# -------- main --------
|
|
|
|
|
|
|
|
if [ "$#" -ne 1 ]; then
|
|
|
|
echo "
|
|
|
|
Usage: $0 { cpp |
|
|
|
|
csharp |
|
|
|
|
java_jdk6 |
|
|
|
|
java_jdk7 |
|
|
|
|
java_oracle7 |
|
|
|
|
javanano_jdk6 |
|
|
|
|
javanano_jdk7 |
|
|
|
|
javanano_oracle7 |
|
|
|
|
objectivec_ios |
|
2016-05-24 15:27:33 +00:00
|
|
|
objectivec_ios_debug |
|
|
|
|
objectivec_ios_release |
|
2016-02-19 04:10:23 +00:00
|
|
|
objectivec_osx |
|
|
|
|
python |
|
|
|
|
python_cpp |
|
2016-02-22 23:39:29 +00:00
|
|
|
ruby19 |
|
|
|
|
ruby20 |
|
|
|
|
ruby21 |
|
|
|
|
ruby22 |
|
2016-02-19 04:10:23 +00:00
|
|
|
jruby }
|
|
|
|
"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -e # exit immediately on error
|
|
|
|
set -x # display all commands
|
|
|
|
eval "build_$1"
|