Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 1 | #!/bin/bash |
Josh Haberman | 67c727c | 2016-03-04 14:21:18 -0800 | [diff] [blame] | 2 | # |
| 3 | # Build and runs tests for the protobuf project. The tests as written here are |
| 4 | # used by both Jenkins and Travis, though some specialized logic is required to |
| 5 | # handle the differences between them. |
Thomas Van Lenten | c4d3638 | 2015-06-09 13:35:41 -0400 | [diff] [blame] | 6 | |
Josh Haberman | 0f8c25d | 2016-02-19 09:11:38 -0800 | [diff] [blame] | 7 | on_travis() { |
| 8 | if [ "$TRAVIS" == "true" ]; then |
| 9 | "$@" |
| 10 | fi |
| 11 | } |
| 12 | |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 13 | # For when some other test needs the C++ main build, including protoc and |
| 14 | # libprotobuf. |
| 15 | internal_build_cpp() { |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 16 | if [ -f src/protoc ]; then |
| 17 | # Already built. |
| 18 | return |
| 19 | fi |
| 20 | |
Josh Haberman | d33e93b | 2016-02-18 19:13:07 -0800 | [diff] [blame] | 21 | if [[ $(uname -s) == "Linux" && "$TRAVIS" == "true" ]]; then |
Feng Xiao | 9125863 | 2015-12-21 03:34:28 -0800 | [diff] [blame] | 22 | # Install GCC 4.8 to replace the default GCC 4.6. We need 4.8 for more |
| 23 | # decent C++ 11 support in order to compile conformance tests. |
| 24 | sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y |
| 25 | sudo apt-get update -qq |
| 26 | sudo apt-get install -qq g++-4.8 |
| 27 | export CXX="g++-4.8" CC="gcc-4.8" |
| 28 | fi |
Feng Xiao | 1e2fece | 2015-12-18 15:16:07 -0800 | [diff] [blame] | 29 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 30 | ./autogen.sh |
Paul Yang | daba665 | 2016-10-07 16:09:26 -0700 | [diff] [blame] | 31 | ./configure CXXFLAGS="-fPIC" # -fPIC is needed for python cpp test. |
| 32 | # See python/setup.py for more details |
Josh Haberman | 67c727c | 2016-03-04 14:21:18 -0800 | [diff] [blame] | 33 | make -j2 |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | build_cpp() { |
| 37 | internal_build_cpp |
Josh Haberman | 67c727c | 2016-03-04 14:21:18 -0800 | [diff] [blame] | 38 | make check -j2 |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 39 | cd conformance && make test_cpp && cd .. |
Josh Haberman | cb36bde | 2016-04-29 09:52:20 -0700 | [diff] [blame] | 40 | |
| 41 | # Verify benchmarking code can build successfully. |
Joshua Haberman | a289d43 | 2016-09-23 11:07:45 -0700 | [diff] [blame] | 42 | git submodule init |
| 43 | git submodule update |
| 44 | cd third_party/benchmark && cmake -DCMAKE_BUILD_TYPE=Release && make && cd ../.. |
Josh Haberman | 49a8918 | 2016-04-29 10:19:03 -0700 | [diff] [blame] | 45 | cd benchmarks && make && ./generate-datasets && cd .. |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | build_cpp_distcheck() { |
| 49 | ./autogen.sh |
| 50 | ./configure |
Feng Xiao | a4f68b1 | 2016-07-19 17:20:31 -0700 | [diff] [blame] | 51 | make dist |
| 52 | |
| 53 | # List all files that should be included in the distribution package. |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 54 | git ls-files | grep "^\(java\|python\|objectivec\|csharp\|js\|ruby\|cmake\|examples\)" |\ |
Feng Xiao | a4f68b1 | 2016-07-19 17:20:31 -0700 | [diff] [blame] | 55 | grep -v ".gitignore" | grep -v "java/compatibility_tests" > dist.lst |
| 56 | # Unzip the dist tar file. |
| 57 | DIST=`ls *.tar.gz` |
| 58 | tar -xf $DIST |
| 59 | cd ${DIST//.tar.gz} |
| 60 | # Check if every file exists in the dist tar file. |
| 61 | FILES_MISSING="" |
| 62 | for FILE in $(<../dist.lst); do |
| 63 | if ! file $FILE &>/dev/null; then |
| 64 | echo "$FILE is not found!" |
| 65 | FILES_MISSING="$FILE $FILES_MISSING" |
| 66 | fi |
| 67 | done |
| 68 | cd .. |
| 69 | if [ ! -z "$FILES_MISSING" ]; then |
| 70 | echo "Missing files in EXTRA_DIST: $FILES_MISSING" |
| 71 | exit 1 |
| 72 | fi |
| 73 | |
| 74 | # Do the regular dist-check for C++. |
Josh Haberman | 67c727c | 2016-03-04 14:21:18 -0800 | [diff] [blame] | 75 | make distcheck -j2 |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 76 | } |
| 77 | |
Jan Tattermusch | ddb36ef | 2015-05-18 17:34:02 -0700 | [diff] [blame] | 78 | build_csharp() { |
Jon Skeet | b6defa7 | 2015-08-04 10:01:40 +0100 | [diff] [blame] | 79 | # Just for the conformance tests. We don't currently |
| 80 | # need to really build protoc, but it's simplest to keep with the |
| 81 | # conventions of the other builds. |
| 82 | internal_build_cpp |
Josh Haberman | ffc8118 | 2016-02-22 15:39:29 -0800 | [diff] [blame] | 83 | NUGET=/usr/local/bin/nuget.exe |
Jon Skeet | b6defa7 | 2015-08-04 10:01:40 +0100 | [diff] [blame] | 84 | |
Josh Haberman | ffc8118 | 2016-02-22 15:39:29 -0800 | [diff] [blame] | 85 | if [ "$TRAVIS" == "true" ]; then |
| 86 | # Install latest version of Mono |
| 87 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF |
Jon Skeet | 10a8fb4 | 2016-07-14 22:01:47 +0100 | [diff] [blame] | 88 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1397BC53640DB551 |
Josh Haberman | ffc8118 | 2016-02-22 15:39:29 -0800 | [diff] [blame] | 89 | echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list |
Josh Haberman | ffc8118 | 2016-02-22 15:39:29 -0800 | [diff] [blame] | 90 | sudo apt-get update -qq |
| 91 | sudo apt-get install -qq mono-devel referenceassemblies-pcl nunit |
Jon Skeet | 10a8fb4 | 2016-07-14 22:01:47 +0100 | [diff] [blame] | 92 | |
| 93 | # Then install the dotnet SDK as per Ubuntu 14.04 instructions on dot.net. |
Jon Skeet | deaea21 | 2016-07-19 17:57:46 -0700 | [diff] [blame] | 94 | sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list' |
Jon Skeet | 10a8fb4 | 2016-07-14 22:01:47 +0100 | [diff] [blame] | 95 | sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893 |
| 96 | sudo apt-get update -qq |
| 97 | sudo apt-get install -qq dotnet-dev-1.0.0-preview2-003121 |
Josh Haberman | ffc8118 | 2016-02-22 15:39:29 -0800 | [diff] [blame] | 98 | fi |
Jan Tattermusch | ddb36ef | 2015-05-18 17:34:02 -0700 | [diff] [blame] | 99 | |
Jon Skeet | 10a8fb4 | 2016-07-14 22:01:47 +0100 | [diff] [blame] | 100 | # Perform "dotnet new" once to get the setup preprocessing out of the |
| 101 | # way. That spews a lot of output (including backspaces) into logs |
| 102 | # otherwise, and can cause problems. It doesn't matter if this step |
| 103 | # is performed multiple times; it's cheap after the first time anyway. |
| 104 | mkdir dotnettmp |
| 105 | (cd dotnettmp; dotnet new > /dev/null) |
| 106 | rm -rf dotnettmp |
| 107 | |
| 108 | (cd csharp/src; dotnet restore) |
Jan Tattermusch | ddb36ef | 2015-05-18 17:34:02 -0700 | [diff] [blame] | 109 | csharp/buildall.sh |
Josh Haberman | e891c29 | 2015-12-30 16:03:49 -0800 | [diff] [blame] | 110 | cd conformance && make test_csharp && cd .. |
Jan Tattermusch | ddb36ef | 2015-05-18 17:34:02 -0700 | [diff] [blame] | 111 | } |
| 112 | |
Tim Swast | 7e31c4d | 2015-11-20 15:32:53 -0800 | [diff] [blame] | 113 | build_golang() { |
| 114 | # Go build needs `protoc`. |
| 115 | internal_build_cpp |
| 116 | # Add protoc to the path so that the examples build finds it. |
| 117 | export PATH="`pwd`/src:$PATH" |
| 118 | |
| 119 | # Install Go and the Go protobuf compiler plugin. |
Feng Xiao | 20fbb35 | 2016-07-21 18:04:56 -0700 | [diff] [blame] | 120 | on_travis sudo apt-get update -qq |
| 121 | on_travis sudo apt-get install -qq golang |
| 122 | |
Tim Swast | 7e31c4d | 2015-11-20 15:32:53 -0800 | [diff] [blame] | 123 | export GOPATH="$HOME/gocode" |
| 124 | mkdir -p "$GOPATH/src/github.com/google" |
Feng Xiao | 20fbb35 | 2016-07-21 18:04:56 -0700 | [diff] [blame] | 125 | rm -f "$GOPATH/src/github.com/google/protobuf" |
Tim Swast | 7e31c4d | 2015-11-20 15:32:53 -0800 | [diff] [blame] | 126 | ln -s "`pwd`" "$GOPATH/src/github.com/google/protobuf" |
| 127 | export PATH="$GOPATH/bin:$PATH" |
| 128 | go get github.com/golang/protobuf/protoc-gen-go |
| 129 | |
| 130 | cd examples && make gotest && cd .. |
| 131 | } |
| 132 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 133 | use_java() { |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 134 | version=$1 |
| 135 | case "$version" in |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 136 | jdk7) |
Josh Haberman | 0f8c25d | 2016-02-19 09:11:38 -0800 | [diff] [blame] | 137 | on_travis sudo apt-get install openjdk-7-jdk |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 138 | export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH |
Feng Xiao | ad49ed7 | 2016-07-21 11:37:46 -0700 | [diff] [blame] | 139 | export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 140 | ;; |
| 141 | oracle7) |
Josh Haberman | ffc8118 | 2016-02-22 15:39:29 -0800 | [diff] [blame] | 142 | if [ "$TRAVIS" == "true" ]; then |
| 143 | sudo apt-get install python-software-properties # for apt-add-repository |
| 144 | echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select true" | \ |
| 145 | sudo debconf-set-selections |
| 146 | yes | sudo apt-add-repository ppa:webupd8team/java |
| 147 | yes | sudo apt-get install oracle-java7-installer |
| 148 | fi; |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 149 | export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH |
Feng Xiao | ad49ed7 | 2016-07-21 11:37:46 -0700 | [diff] [blame] | 150 | export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 151 | ;; |
| 152 | esac |
| 153 | |
Josh Haberman | 1ee0fda | 2016-03-03 16:02:55 -0800 | [diff] [blame] | 154 | if [ "$TRAVIS" != "true" ]; then |
| 155 | MAVEN_LOCAL_REPOSITORY=/var/maven_local_repository |
| 156 | MVN="$MVN -e -X --offline -Dmaven.repo.local=$MAVEN_LOCAL_REPOSITORY" |
| 157 | fi; |
| 158 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 159 | which java |
| 160 | java -version |
Feng Xiao | ad49ed7 | 2016-07-21 11:37:46 -0700 | [diff] [blame] | 161 | $MVN -version |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 162 | } |
| 163 | |
Josh Haberman | d08c39c | 2016-02-20 12:03:39 -0800 | [diff] [blame] | 164 | # --batch-mode supresses download progress output that spams the logs. |
Josh Haberman | b28b3f6 | 2016-02-20 12:17:10 -0800 | [diff] [blame] | 165 | MVN="mvn --batch-mode" |
Josh Haberman | d08c39c | 2016-02-20 12:03:39 -0800 | [diff] [blame] | 166 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 167 | build_java() { |
Josh Haberman | 2f3f1de | 2016-03-01 15:37:17 -0800 | [diff] [blame] | 168 | version=$1 |
| 169 | dir=java_$version |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 170 | # Java build needs `protoc`. |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 171 | internal_build_cpp |
Josh Haberman | 2f3f1de | 2016-03-01 15:37:17 -0800 | [diff] [blame] | 172 | cp -r java $dir |
| 173 | cd $dir && $MVN clean && $MVN test |
Feng Xiao | 9e5fb55 | 2015-12-21 11:08:18 -0800 | [diff] [blame] | 174 | cd ../.. |
| 175 | } |
| 176 | |
Josh Haberman | 2f3f1de | 2016-03-01 15:37:17 -0800 | [diff] [blame] | 177 | # The conformance tests are hard-coded to work with the $ROOT/java directory. |
| 178 | # So this can't run in parallel with two different sets of tests. |
Feng Xiao | 9e5fb55 | 2015-12-21 11:08:18 -0800 | [diff] [blame] | 179 | build_java_with_conformance_tests() { |
| 180 | # Java build needs `protoc`. |
| 181 | internal_build_cpp |
Josh Haberman | d08c39c | 2016-02-20 12:03:39 -0800 | [diff] [blame] | 182 | cd java && $MVN test && $MVN install |
Josh Haberman | 2f3f1de | 2016-03-01 15:37:17 -0800 | [diff] [blame] | 183 | cd util && $MVN package assembly:single |
Feng Xiao | af81dcf | 2015-12-21 03:25:59 -0800 | [diff] [blame] | 184 | cd ../.. |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 185 | cd conformance && make test_java && cd .. |
| 186 | } |
| 187 | |
| 188 | build_javanano() { |
| 189 | # Java build needs `protoc`. |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 190 | internal_build_cpp |
Josh Haberman | b28b3f6 | 2016-02-20 12:17:10 -0800 | [diff] [blame] | 191 | cd javanano && $MVN test && cd .. |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 192 | } |
| 193 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 194 | build_java_jdk7() { |
| 195 | use_java jdk7 |
Feng Xiao | 9e5fb55 | 2015-12-21 11:08:18 -0800 | [diff] [blame] | 196 | build_java_with_conformance_tests |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 197 | } |
| 198 | build_java_oracle7() { |
| 199 | use_java oracle7 |
Josh Haberman | 2f3f1de | 2016-03-01 15:37:17 -0800 | [diff] [blame] | 200 | build_java oracle7 |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 201 | } |
Feng Xiao | baa4023 | 2016-07-29 14:11:21 -0700 | [diff] [blame] | 202 | build_java_compatibility() { |
| 203 | use_java jdk7 |
| 204 | internal_build_cpp |
| 205 | # Use the unit-tests extraced from 2.5.0 to test the compatibilty between |
| 206 | # 3.0.0-beta-4 and the current version. |
| 207 | cd java/compatibility_tests/v2.5.0 |
| 208 | ./test.sh 3.0.0-beta-4 |
| 209 | } |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 210 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 211 | build_javanano_jdk7() { |
| 212 | use_java jdk7 |
| 213 | build_javanano |
| 214 | } |
| 215 | build_javanano_oracle7() { |
| 216 | use_java oracle7 |
| 217 | build_javanano |
| 218 | } |
| 219 | |
Dan O'Reilly | 5de2a81 | 2015-08-20 18:19:56 -0400 | [diff] [blame] | 220 | internal_install_python_deps() { |
Josh Haberman | 483533d | 2016-02-19 12:48:33 -0800 | [diff] [blame] | 221 | if [ "$TRAVIS" != "true" ]; then |
| 222 | return; |
| 223 | fi |
Thomas Van Lenten | 9642b82 | 2015-06-10 17:21:23 -0400 | [diff] [blame] | 224 | # Install tox (OS X doesn't have pip). |
| 225 | if [ $(uname -s) == "Darwin" ]; then |
| 226 | sudo easy_install tox |
| 227 | else |
| 228 | sudo pip install tox |
| 229 | fi |
Dan O'Reilly | d9598ca | 2015-08-26 20:30:41 -0400 | [diff] [blame] | 230 | # Only install Python2.6/3.x on Linux. |
Dan O'Reilly | 76f8a3f | 2015-08-21 18:51:47 -0400 | [diff] [blame] | 231 | if [ $(uname -s) == "Linux" ]; then |
| 232 | sudo apt-get install -y python-software-properties # for apt-add-repository |
| 233 | sudo apt-add-repository -y ppa:fkrull/deadsnakes |
| 234 | sudo apt-get update -qq |
| 235 | sudo apt-get install -y python2.6 python2.6-dev |
Dan O'Reilly | d9598ca | 2015-08-26 20:30:41 -0400 | [diff] [blame] | 236 | sudo apt-get install -y python3.3 python3.3-dev |
| 237 | sudo apt-get install -y python3.4 python3.4-dev |
Dan O'Reilly | 76f8a3f | 2015-08-21 18:51:47 -0400 | [diff] [blame] | 238 | fi |
Dan O'Reilly | 5de2a81 | 2015-08-20 18:19:56 -0400 | [diff] [blame] | 239 | } |
| 240 | |
Thomas Van Lenten | 9642b82 | 2015-06-10 17:21:23 -0400 | [diff] [blame] | 241 | build_objectivec_ios() { |
Thomas Van Lenten | 368a2f4 | 2016-05-24 11:27:33 -0400 | [diff] [blame] | 242 | # Reused the build script that takes care of configuring and ensuring things |
| 243 | # are up to date. The OS X test runs the objc conformance test, so skip it |
| 244 | # here. |
| 245 | # Note: travis has xctool installed, and we've looked at using it in the past |
| 246 | # but it has ended up proving unreliable (bugs), an they are removing build |
| 247 | # support in favor of xcbuild (or just xcodebuild). |
| 248 | objectivec/DevTools/full_mac_build.sh \ |
| 249 | --core-only --skip-xcode-osx --skip-objc-conformance "$@" |
| 250 | } |
| 251 | |
| 252 | build_objectivec_ios_debug() { |
| 253 | build_objectivec_ios --skip-xcode-release |
| 254 | } |
| 255 | |
| 256 | build_objectivec_ios_release() { |
| 257 | build_objectivec_ios --skip-xcode-debug |
Thomas Van Lenten | 9642b82 | 2015-06-10 17:21:23 -0400 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | build_objectivec_osx() { |
Thomas Van Lenten | 368a2f4 | 2016-05-24 11:27:33 -0400 | [diff] [blame] | 261 | # Reused the build script that takes care of configuring and ensuring things |
| 262 | # are up to date. |
| 263 | objectivec/DevTools/full_mac_build.sh \ |
| 264 | --core-only --skip-xcode-ios |
Thomas Van Lenten | 9642b82 | 2015-06-10 17:21:23 -0400 | [diff] [blame] | 265 | } |
Dan O'Reilly | 5de2a81 | 2015-08-20 18:19:56 -0400 | [diff] [blame] | 266 | |
Sergio Campamá | f0c1492 | 2016-06-14 11:26:01 -0700 | [diff] [blame] | 267 | build_objectivec_cocoapods_integration() { |
| 268 | # First, load the RVM environment in bash, needed to update ruby. |
| 269 | source ~/.rvm/scripts/rvm |
Sergio Campamá | f6d1d1a | 2016-07-15 13:59:09 -0700 | [diff] [blame] | 270 | # Update rvm to the latest version. This is needed to solve |
| 271 | # https://github.com/google/protobuf/issues/1786 and may not be needed in the |
| 272 | # future when Travis updates the default version of rvm. |
| 273 | rvm get head |
Sergio Campamá | f0c1492 | 2016-06-14 11:26:01 -0700 | [diff] [blame] | 274 | # Update ruby to 2.2.3 as the default one crashes with segmentation faults |
| 275 | # when using pod. |
| 276 | rvm use 2.2.3 --install --binary --fuzzy |
| 277 | # Update pod to the latest version. |
| 278 | gem install cocoapods --no-ri --no-rdoc |
| 279 | objectivec/Tests/CocoaPods/run_tests.sh |
| 280 | } |
| 281 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 282 | build_python() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 283 | internal_build_cpp |
Dan O'Reilly | 5de2a81 | 2015-08-20 18:19:56 -0400 | [diff] [blame] | 284 | internal_install_python_deps |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 285 | cd python |
Dan O'Reilly | d9598ca | 2015-08-26 20:30:41 -0400 | [diff] [blame] | 286 | # Only test Python 2.6/3.x on Linux |
Dan O'Reilly | 76f8a3f | 2015-08-21 18:51:47 -0400 | [diff] [blame] | 287 | if [ $(uname -s) == "Linux" ]; then |
Jie Luo | 2850a98 | 2015-10-09 17:07:03 -0700 | [diff] [blame] | 288 | envlist=py\{26,27,33,34\}-python |
Dan O'Reilly | 76f8a3f | 2015-08-21 18:51:47 -0400 | [diff] [blame] | 289 | else |
| 290 | envlist=py27-python |
| 291 | fi |
| 292 | tox -e $envlist |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 293 | cd .. |
| 294 | } |
| 295 | |
| 296 | build_python_cpp() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 297 | internal_build_cpp |
Dan O'Reilly | 5de2a81 | 2015-08-20 18:19:56 -0400 | [diff] [blame] | 298 | internal_install_python_deps |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 299 | export LD_LIBRARY_PATH=../src/.libs # for Linux |
| 300 | export DYLD_LIBRARY_PATH=../src/.libs # for OS X |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 301 | cd python |
Dan O'Reilly | d9598ca | 2015-08-26 20:30:41 -0400 | [diff] [blame] | 302 | # Only test Python 2.6/3.x on Linux |
Dan O'Reilly | 76f8a3f | 2015-08-21 18:51:47 -0400 | [diff] [blame] | 303 | if [ $(uname -s) == "Linux" ]; then |
Jisi Liu | 72bd9c9 | 2015-10-06 10:48:57 -0700 | [diff] [blame] | 304 | # py26 is currently disabled due to json_format |
| 305 | envlist=py\{27,33,34\}-cpp |
Dan O'Reilly | 76f8a3f | 2015-08-21 18:51:47 -0400 | [diff] [blame] | 306 | else |
| 307 | envlist=py27-cpp |
| 308 | fi |
| 309 | tox -e $envlist |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 310 | cd .. |
| 311 | } |
| 312 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 313 | build_ruby21() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 314 | internal_build_cpp # For conformance tests. |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 315 | cd ruby && bash travis-test.sh ruby-2.1 && cd .. |
| 316 | } |
| 317 | build_ruby22() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 318 | internal_build_cpp # For conformance tests. |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 319 | cd ruby && bash travis-test.sh ruby-2.2 && cd .. |
| 320 | } |
| 321 | build_jruby() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 322 | internal_build_cpp # For conformance tests. |
Feng Xiao | 20fbb35 | 2016-07-21 18:04:56 -0700 | [diff] [blame] | 323 | # TODO(xiaofeng): Upgrade to jruby-9.x. There are some broken jests to be |
| 324 | # fixed. |
| 325 | cd ruby && bash travis-test.sh jruby-1.7 && cd .. |
| 326 | } |
| 327 | build_ruby_all() { |
| 328 | build_ruby21 |
| 329 | build_ruby22 |
| 330 | build_jruby |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 331 | } |
| 332 | |
Josh Haberman | e9cf31e | 2015-12-21 15:18:17 -0800 | [diff] [blame] | 333 | build_javascript() { |
| 334 | internal_build_cpp |
Josh Haberman | 0d2d8bc | 2015-12-28 06:43:42 -0800 | [diff] [blame] | 335 | cd js && npm install && npm test && cd .. |
Josh Haberman | e9cf31e | 2015-12-21 15:18:17 -0800 | [diff] [blame] | 336 | } |
| 337 | |
Bo Yang | c8bd36e | 2016-09-30 19:07:33 +0000 | [diff] [blame] | 338 | use_php() { |
| 339 | VERSION=$1 |
| 340 | PHP=`which php` |
| 341 | PHP_CONFIG=`which php-config` |
| 342 | PHPIZE=`which phpize` |
| 343 | rm $PHP |
| 344 | rm $PHP_CONFIG |
| 345 | rm $PHPIZE |
| 346 | cp "/usr/bin/php$VERSION" $PHP |
| 347 | cp "/usr/bin/php-config$VERSION" $PHP_CONFIG |
| 348 | cp "/usr/bin/phpize$VERSION" $PHPIZE |
| 349 | } |
| 350 | |
Bo Yang | c96dd66 | 2016-10-04 17:32:08 +0000 | [diff] [blame] | 351 | use_php_zts() { |
| 352 | VERSION=$1 |
| 353 | PHP=`which php` |
| 354 | PHP_CONFIG=`which php-config` |
| 355 | PHPIZE=`which phpize` |
| 356 | ln -sfn "/usr/local/php-${VERSION}-zts/bin/php" $PHP |
| 357 | ln -sfn "/usr/local/php-${VERSION}-zts/bin/php-config" $PHP_CONFIG |
| 358 | ln -sfn "/usr/local/php-${VERSION}-zts/bin/phpize" $PHPIZE |
| 359 | } |
| 360 | |
Paul Yang | 51c5ff8 | 2016-10-25 17:27:05 -0700 | [diff] [blame] | 361 | use_php_bc() { |
| 362 | VERSION=$1 |
| 363 | PHP=`which php` |
| 364 | PHP_CONFIG=`which php-config` |
| 365 | PHPIZE=`which phpize` |
| 366 | ln -sfn "/usr/local/php-${VERSION}-bc/bin/php" $PHP |
| 367 | ln -sfn "/usr/local/php-${VERSION}-bc/bin/php-config" $PHP_CONFIG |
| 368 | ln -sfn "/usr/local/php-${VERSION}-bc/bin/phpize" $PHPIZE |
| 369 | } |
| 370 | |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 371 | build_php5.5() { |
Bo Yang | c8bd36e | 2016-09-30 19:07:33 +0000 | [diff] [blame] | 372 | use_php 5.5 |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 373 | rm -rf vendor |
| 374 | cp -r /usr/local/vendor-5.5 vendor |
| 375 | ./vendor/bin/phpunit |
| 376 | } |
| 377 | |
Bo Yang | 34cdaf4 | 2016-10-03 21:59:58 +0000 | [diff] [blame] | 378 | build_php5.5_c() { |
| 379 | use_php 5.5 |
| 380 | cd php/tests && /bin/bash ./test.sh && cd ../.. |
| 381 | } |
Bo Yang | 34cdaf4 | 2016-10-03 21:59:58 +0000 | [diff] [blame] | 382 | |
Bo Yang | c96dd66 | 2016-10-04 17:32:08 +0000 | [diff] [blame] | 383 | build_php5.5_zts_c() { |
| 384 | use_php_zts 5.5 |
Bo Yang | 4f3d20a | 2016-10-05 10:54:39 -0700 | [diff] [blame] | 385 | wget https://phar.phpunit.de/phpunit-old.phar -O /usr/bin/phpunit |
Bo Yang | c96dd66 | 2016-10-04 17:32:08 +0000 | [diff] [blame] | 386 | cd php/tests && /bin/bash ./test.sh && cd ../.. |
| 387 | } |
| 388 | |
Paul Yang | 51c5ff8 | 2016-10-25 17:27:05 -0700 | [diff] [blame] | 389 | build_php5.5_32() { |
| 390 | use_php_bc 5.5 |
| 391 | rm -rf vendor |
| 392 | cp -r /usr/local/vendor-5.5 vendor |
| 393 | ./vendor/bin/phpunit |
| 394 | } |
| 395 | |
Paul Yang | df83907 | 2016-11-10 11:20:50 -0800 | [diff] [blame] | 396 | build_php5.5_c_32() { |
| 397 | use_php_bc 5.5 |
| 398 | wget https://phar.phpunit.de/phpunit-old.phar -O /usr/bin/phpunit |
| 399 | cd php/tests && /bin/bash ./test.sh && cd ../.. |
| 400 | } |
| 401 | |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 402 | build_php5.6() { |
Bo Yang | c8bd36e | 2016-09-30 19:07:33 +0000 | [diff] [blame] | 403 | use_php 5.6 |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 404 | rm -rf vendor |
| 405 | cp -r /usr/local/vendor-5.6 vendor |
| 406 | ./vendor/bin/phpunit |
| 407 | } |
| 408 | |
Bo Yang | 34cdaf4 | 2016-10-03 21:59:58 +0000 | [diff] [blame] | 409 | build_php5.6_c() { |
| 410 | use_php 5.6 |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 411 | cd php/tests && /bin/bash ./test.sh && cd ../.. |
| 412 | } |
| 413 | |
Bo Yang | 63448e6 | 2016-10-05 18:28:13 -0700 | [diff] [blame] | 414 | build_php5.6_mac() { |
| 415 | # Install PHP |
| 416 | curl -s https://php-osx.liip.ch/install.sh | bash -s 5.6 |
Paul Yang | 1f2dbc8 | 2016-11-08 11:38:34 -0800 | [diff] [blame] | 417 | PHP_FOLDER=`find /usr/local -type d -name "php5-5.6*"` # The folder name may change upon time |
| 418 | export PATH="$PHP_FOLDER/bin:$PATH" |
Bo Yang | 63448e6 | 2016-10-05 18:28:13 -0700 | [diff] [blame] | 419 | |
| 420 | # Install phpunit |
| 421 | curl https://phar.phpunit.de/phpunit.phar -L -o phpunit.phar |
| 422 | chmod +x phpunit.phar |
| 423 | sudo mv phpunit.phar /usr/local/bin/phpunit |
| 424 | |
| 425 | # Install valgrind |
| 426 | echo "#! /bin/bash" > valgrind |
| 427 | chmod ug+x valgrind |
| 428 | sudo mv valgrind /usr/local/bin/valgrind |
| 429 | |
| 430 | # Test |
| 431 | cd php/tests && /bin/bash ./test.sh && cd ../.. |
| 432 | } |
| 433 | |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 434 | build_php7.0() { |
Bo Yang | c8bd36e | 2016-09-30 19:07:33 +0000 | [diff] [blame] | 435 | use_php 7.0 |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 436 | rm -rf vendor |
| 437 | cp -r /usr/local/vendor-7.0 vendor |
| 438 | ./vendor/bin/phpunit |
| 439 | } |
| 440 | |
Bo Yang | 34cdaf4 | 2016-10-03 21:59:58 +0000 | [diff] [blame] | 441 | build_php7.0_c() { |
| 442 | use_php 7.0 |
| 443 | cd php/tests && /bin/bash ./test.sh && cd ../.. |
| 444 | } |
| 445 | |
Bo Yang | c8bd36e | 2016-09-30 19:07:33 +0000 | [diff] [blame] | 446 | build_php_all() { |
| 447 | build_php5.5 |
| 448 | build_php5.6 |
| 449 | build_php7.0 |
| 450 | build_php5.5_c |
| 451 | build_php5.6_c |
| 452 | # build_php7.0_c |
Bo Yang | c96dd66 | 2016-10-04 17:32:08 +0000 | [diff] [blame] | 453 | build_php5.5_zts_c |
Bo Yang | c8bd36e | 2016-09-30 19:07:33 +0000 | [diff] [blame] | 454 | } |
| 455 | |
Paul Yang | 51c5ff8 | 2016-10-25 17:27:05 -0700 | [diff] [blame] | 456 | build_php_all_32() { |
| 457 | build_php5.5_32 |
Paul Yang | df83907 | 2016-11-10 11:20:50 -0800 | [diff] [blame] | 458 | build_php5.5_c_32 |
Paul Yang | 51c5ff8 | 2016-10-25 17:27:05 -0700 | [diff] [blame] | 459 | } |
| 460 | |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 461 | # Note: travis currently does not support testing more than one language so the |
| 462 | # .travis.yml cheats and claims to only be cpp. If they add multiple language |
| 463 | # support, this should probably get updated to install steps and/or |
| 464 | # rvm/gemfile/jdk/etc. entries rather than manually doing the work. |
| 465 | |
| 466 | # .travis.yml uses matrix.exclude to block the cases where app-get can't be |
| 467 | # use to install things. |
| 468 | |
| 469 | # -------- main -------- |
| 470 | |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 471 | if [ "$#" -ne 1 ]; then |
| 472 | echo " |
| 473 | Usage: $0 { cpp | |
Feng Xiao | a4f68b1 | 2016-07-19 17:20:31 -0700 | [diff] [blame] | 474 | cpp_distcheck | |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 475 | csharp | |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 476 | java_jdk7 | |
| 477 | java_oracle7 | |
Feng Xiao | baa4023 | 2016-07-29 14:11:21 -0700 | [diff] [blame] | 478 | java_compatibility | |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 479 | javanano_jdk7 | |
| 480 | javanano_oracle7 | |
| 481 | objectivec_ios | |
Thomas Van Lenten | 368a2f4 | 2016-05-24 11:27:33 -0400 | [diff] [blame] | 482 | objectivec_ios_debug | |
| 483 | objectivec_ios_release | |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 484 | objectivec_osx | |
Sergio Campamá | f0c1492 | 2016-06-14 11:26:01 -0700 | [diff] [blame] | 485 | objectivec_cocoapods_integration | |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 486 | python | |
| 487 | python_cpp | |
Josh Haberman | ffc8118 | 2016-02-22 15:39:29 -0800 | [diff] [blame] | 488 | ruby21 | |
| 489 | ruby22 | |
Feng Xiao | 20fbb35 | 2016-07-21 18:04:56 -0700 | [diff] [blame] | 490 | jruby | |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 491 | ruby_all | |
| 492 | php5.5 | |
| 493 | php5.5_c | |
| 494 | php5.6 | |
| 495 | php5.6_c | |
| 496 | php7.0 | |
Bo Yang | c8bd36e | 2016-09-30 19:07:33 +0000 | [diff] [blame] | 497 | php7.0_c | |
| 498 | php_all) |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 499 | " |
| 500 | exit 1 |
| 501 | fi |
| 502 | |
| 503 | set -e # exit immediately on error |
| 504 | set -x # display all commands |
| 505 | eval "build_$1" |