Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 1 | #!/bin/bash |
Thomas Van Lenten | c4d3638 | 2015-06-09 13:35:41 -0400 | [diff] [blame] | 2 | |
Josh Haberman | 0f8c25d | 2016-02-19 09:11:38 -0800 | [diff] [blame] | 3 | on_travis() { |
| 4 | if [ "$TRAVIS" == "true" ]; then |
| 5 | "$@" |
| 6 | fi |
| 7 | } |
| 8 | |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 9 | # For when some other test needs the C++ main build, including protoc and |
| 10 | # libprotobuf. |
| 11 | internal_build_cpp() { |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 12 | if [ -f src/protoc ]; then |
| 13 | # Already built. |
| 14 | return |
| 15 | fi |
| 16 | |
Josh Haberman | d33e93b | 2016-02-18 19:13:07 -0800 | [diff] [blame] | 17 | if [[ $(uname -s) == "Linux" && "$TRAVIS" == "true" ]]; then |
Feng Xiao | 9125863 | 2015-12-21 03:34:28 -0800 | [diff] [blame] | 18 | # Install GCC 4.8 to replace the default GCC 4.6. We need 4.8 for more |
| 19 | # decent C++ 11 support in order to compile conformance tests. |
| 20 | sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y |
| 21 | sudo apt-get update -qq |
| 22 | sudo apt-get install -qq g++-4.8 |
| 23 | export CXX="g++-4.8" CC="gcc-4.8" |
| 24 | fi |
Feng Xiao | 1e2fece | 2015-12-18 15:16:07 -0800 | [diff] [blame] | 25 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 26 | ./autogen.sh |
| 27 | ./configure |
Josh Haberman | d33e93b | 2016-02-18 19:13:07 -0800 | [diff] [blame] | 28 | make $PARALLELISM |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | build_cpp() { |
| 32 | internal_build_cpp |
Josh Haberman | d33e93b | 2016-02-18 19:13:07 -0800 | [diff] [blame] | 33 | make check $PARALLELISM |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 34 | cd conformance && make test_cpp && cd .. |
| 35 | } |
| 36 | |
| 37 | build_cpp_distcheck() { |
| 38 | ./autogen.sh |
| 39 | ./configure |
Josh Haberman | d33e93b | 2016-02-18 19:13:07 -0800 | [diff] [blame] | 40 | make distcheck $PARALLELISM |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 41 | } |
| 42 | |
Jan Tattermusch | ddb36ef | 2015-05-18 17:34:02 -0700 | [diff] [blame] | 43 | build_csharp() { |
Jon Skeet | b6defa7 | 2015-08-04 10:01:40 +0100 | [diff] [blame] | 44 | # Just for the conformance tests. We don't currently |
| 45 | # need to really build protoc, but it's simplest to keep with the |
| 46 | # conventions of the other builds. |
| 47 | internal_build_cpp |
| 48 | |
Jan Tattermusch | ddb36ef | 2015-05-18 17:34:02 -0700 | [diff] [blame] | 49 | # Install latest version of Mono |
| 50 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF |
| 51 | echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list |
| 52 | echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list |
| 53 | sudo apt-get update -qq |
| 54 | sudo apt-get install -qq mono-devel referenceassemblies-pcl nunit |
| 55 | wget www.nuget.org/NuGet.exe -O nuget.exe |
| 56 | |
| 57 | (cd csharp/src; mono ../../nuget.exe restore) |
| 58 | csharp/buildall.sh |
Josh Haberman | e891c29 | 2015-12-30 16:03:49 -0800 | [diff] [blame] | 59 | cd conformance && make test_csharp && cd .. |
Jan Tattermusch | ddb36ef | 2015-05-18 17:34:02 -0700 | [diff] [blame] | 60 | } |
| 61 | |
Tim Swast | 7e31c4d | 2015-11-20 15:32:53 -0800 | [diff] [blame] | 62 | build_golang() { |
| 63 | # Go build needs `protoc`. |
| 64 | internal_build_cpp |
| 65 | # Add protoc to the path so that the examples build finds it. |
| 66 | export PATH="`pwd`/src:$PATH" |
| 67 | |
| 68 | # Install Go and the Go protobuf compiler plugin. |
| 69 | sudo apt-get update -qq |
| 70 | sudo apt-get install -qq golang |
| 71 | export GOPATH="$HOME/gocode" |
| 72 | mkdir -p "$GOPATH/src/github.com/google" |
| 73 | ln -s "`pwd`" "$GOPATH/src/github.com/google/protobuf" |
| 74 | export PATH="$GOPATH/bin:$PATH" |
| 75 | go get github.com/golang/protobuf/protoc-gen-go |
| 76 | |
| 77 | cd examples && make gotest && cd .. |
| 78 | } |
| 79 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 80 | use_java() { |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 81 | version=$1 |
| 82 | case "$version" in |
| 83 | jdk6) |
Josh Haberman | 0f8c25d | 2016-02-19 09:11:38 -0800 | [diff] [blame] | 84 | on_travis sudo apt-get install openjdk-6-jdk |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 85 | export PATH=/usr/lib/jvm/java-6-openjdk-amd64/bin:$PATH |
| 86 | ;; |
| 87 | jdk7) |
Josh Haberman | 0f8c25d | 2016-02-19 09:11:38 -0800 | [diff] [blame] | 88 | on_travis sudo apt-get install openjdk-7-jdk |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 89 | export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH |
| 90 | ;; |
| 91 | oracle7) |
| 92 | sudo apt-get install python-software-properties # for apt-add-repository |
| 93 | echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select true" | \ |
| 94 | sudo debconf-set-selections |
| 95 | yes | sudo apt-add-repository ppa:webupd8team/java |
| 96 | yes | sudo apt-get install oracle-java7-installer |
| 97 | export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH |
| 98 | ;; |
| 99 | esac |
| 100 | |
| 101 | which java |
| 102 | java -version |
| 103 | } |
| 104 | |
| 105 | build_java() { |
| 106 | # Java build needs `protoc`. |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 107 | internal_build_cpp |
Feng Xiao | af81dcf | 2015-12-21 03:25:59 -0800 | [diff] [blame] | 108 | cd java && mvn test && mvn install |
Feng Xiao | 9e5fb55 | 2015-12-21 11:08:18 -0800 | [diff] [blame] | 109 | cd util && mvn test |
| 110 | cd ../.. |
| 111 | } |
| 112 | |
| 113 | build_java_with_conformance_tests() { |
| 114 | # Java build needs `protoc`. |
| 115 | internal_build_cpp |
| 116 | cd java && mvn test && mvn install |
Feng Xiao | af81dcf | 2015-12-21 03:25:59 -0800 | [diff] [blame] | 117 | cd util && mvn test && mvn assembly:single |
| 118 | cd ../.. |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 119 | cd conformance && make test_java && cd .. |
| 120 | } |
| 121 | |
| 122 | build_javanano() { |
| 123 | # Java build needs `protoc`. |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 124 | internal_build_cpp |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 125 | cd javanano && mvn test && cd .. |
| 126 | } |
| 127 | |
| 128 | build_java_jdk6() { |
| 129 | use_java jdk6 |
| 130 | build_java |
| 131 | } |
| 132 | build_java_jdk7() { |
| 133 | use_java jdk7 |
Feng Xiao | 9e5fb55 | 2015-12-21 11:08:18 -0800 | [diff] [blame] | 134 | build_java_with_conformance_tests |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 135 | } |
| 136 | build_java_oracle7() { |
| 137 | use_java oracle7 |
| 138 | build_java |
| 139 | } |
| 140 | |
| 141 | build_javanano_jdk6() { |
| 142 | use_java jdk6 |
| 143 | build_javanano |
| 144 | } |
| 145 | build_javanano_jdk7() { |
| 146 | use_java jdk7 |
| 147 | build_javanano |
| 148 | } |
| 149 | build_javanano_oracle7() { |
| 150 | use_java oracle7 |
| 151 | build_javanano |
| 152 | } |
| 153 | |
Dan O'Reilly | 5de2a81 | 2015-08-20 18:19:56 -0400 | [diff] [blame] | 154 | internal_install_python_deps() { |
Josh Haberman | 483533d | 2016-02-19 12:48:33 -0800 | [diff] [blame^] | 155 | if [ "$TRAVIS" != "true" ]; then |
| 156 | return; |
| 157 | fi |
Thomas Van Lenten | 9642b82 | 2015-06-10 17:21:23 -0400 | [diff] [blame] | 158 | # Install tox (OS X doesn't have pip). |
| 159 | if [ $(uname -s) == "Darwin" ]; then |
| 160 | sudo easy_install tox |
| 161 | else |
| 162 | sudo pip install tox |
| 163 | fi |
Dan O'Reilly | d9598ca | 2015-08-26 20:30:41 -0400 | [diff] [blame] | 164 | # Only install Python2.6/3.x on Linux. |
Dan O'Reilly | 76f8a3f | 2015-08-21 18:51:47 -0400 | [diff] [blame] | 165 | if [ $(uname -s) == "Linux" ]; then |
| 166 | sudo apt-get install -y python-software-properties # for apt-add-repository |
| 167 | sudo apt-add-repository -y ppa:fkrull/deadsnakes |
| 168 | sudo apt-get update -qq |
| 169 | sudo apt-get install -y python2.6 python2.6-dev |
Dan O'Reilly | d9598ca | 2015-08-26 20:30:41 -0400 | [diff] [blame] | 170 | sudo apt-get install -y python3.3 python3.3-dev |
| 171 | sudo apt-get install -y python3.4 python3.4-dev |
Dan O'Reilly | 76f8a3f | 2015-08-21 18:51:47 -0400 | [diff] [blame] | 172 | fi |
Dan O'Reilly | 5de2a81 | 2015-08-20 18:19:56 -0400 | [diff] [blame] | 173 | } |
| 174 | |
Thomas Van Lenten | 76b6138 | 2015-11-09 14:21:51 -0500 | [diff] [blame] | 175 | internal_objectivec_common () { |
| 176 | # Make sure xctool is up to date. Adapted from |
| 177 | # http://docs.travis-ci.com/user/osx-ci-environment/ |
| 178 | # We don't use a before_install because we test multiple OSes. |
| 179 | brew update |
Thomas Van Lenten | 8c78450 | 2016-02-18 11:08:30 -0500 | [diff] [blame] | 180 | # xctool 0.2.8 seems to have a bug where it randomly kills tests saying |
| 181 | # they failed. Disabling the updates, but letting it report about being |
| 182 | # updates as a hint that this needs to eventually get re-enabled. |
| 183 | # https://github.com/facebook/xctool/issues/619 |
| 184 | # https://github.com/google/protobuf/issues/1232 |
| 185 | brew outdated xctool || true |
| 186 | #brew outdated xctool || brew upgrade xctool |
Thomas Van Lenten | 76b6138 | 2015-11-09 14:21:51 -0500 | [diff] [blame] | 187 | # Reused the build script that takes care of configuring and ensuring things |
Thomas Van Lenten | 1745f7e | 2015-11-17 10:18:49 -0500 | [diff] [blame] | 188 | # are up to date. Xcode and conformance tests will be directly invoked. |
| 189 | objectivec/DevTools/full_mac_build.sh \ |
| 190 | --core-only --skip-xcode --skip-objc-conformance |
Thomas Van Lenten | 76b6138 | 2015-11-09 14:21:51 -0500 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | internal_xctool_debug_and_release() { |
Thomas Van Lenten | efca368 | 2016-02-16 15:10:14 -0500 | [diff] [blame] | 194 | # Always use -reporter plain to avoid escape codes in output (makes travis |
| 195 | # logs easier to read). |
| 196 | xctool -reporter plain -configuration Debug "$@" |
| 197 | xctool -reporter plain -configuration Release "$@" |
Thomas Van Lenten | 9642b82 | 2015-06-10 17:21:23 -0400 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | build_objectivec_ios() { |
Thomas Van Lenten | 76b6138 | 2015-11-09 14:21:51 -0500 | [diff] [blame] | 201 | internal_objectivec_common |
| 202 | # https://github.com/facebook/xctool/issues/509 - unlike xcodebuild, xctool |
| 203 | # doesn't support >1 destination, so we have to build first and then run the |
| 204 | # tests one destination at a time. |
| 205 | internal_xctool_debug_and_release \ |
| 206 | -project objectivec/ProtocolBuffers_iOS.xcodeproj \ |
| 207 | -scheme ProtocolBuffers \ |
| 208 | -sdk iphonesimulator \ |
| 209 | build-tests |
| 210 | IOS_DESTINATIONS=( |
| 211 | "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit |
Thomas Van Lenten | 1324119 | 2016-02-16 09:19:50 -0500 | [diff] [blame] | 212 | "platform=iOS Simulator,name=iPhone 6,OS=9.2" # 64bit |
Thomas Van Lenten | 76b6138 | 2015-11-09 14:21:51 -0500 | [diff] [blame] | 213 | "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit |
Thomas Van Lenten | 1324119 | 2016-02-16 09:19:50 -0500 | [diff] [blame] | 214 | "platform=iOS Simulator,name=iPad Air,OS=9.2" # 64bit |
Thomas Van Lenten | 76b6138 | 2015-11-09 14:21:51 -0500 | [diff] [blame] | 215 | ) |
| 216 | for i in "${IOS_DESTINATIONS[@]}" ; do |
| 217 | internal_xctool_debug_and_release \ |
| 218 | -project objectivec/ProtocolBuffers_iOS.xcodeproj \ |
| 219 | -scheme ProtocolBuffers \ |
| 220 | -sdk iphonesimulator \ |
| 221 | -destination "${i}" \ |
Thomas Van Lenten | 8c78450 | 2016-02-18 11:08:30 -0500 | [diff] [blame] | 222 | run-tests |
Thomas Van Lenten | 76b6138 | 2015-11-09 14:21:51 -0500 | [diff] [blame] | 223 | done |
Thomas Van Lenten | 9642b82 | 2015-06-10 17:21:23 -0400 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | build_objectivec_osx() { |
Thomas Van Lenten | 76b6138 | 2015-11-09 14:21:51 -0500 | [diff] [blame] | 227 | internal_objectivec_common |
| 228 | internal_xctool_debug_and_release \ |
| 229 | -project objectivec/ProtocolBuffers_OSX.xcodeproj \ |
| 230 | -scheme ProtocolBuffers \ |
| 231 | -destination "platform=OS X,arch=x86_64" \ |
| 232 | test |
Thomas Van Lenten | 1745f7e | 2015-11-17 10:18:49 -0500 | [diff] [blame] | 233 | cd conformance && make test_objc && cd .. |
Thomas Van Lenten | 9642b82 | 2015-06-10 17:21:23 -0400 | [diff] [blame] | 234 | } |
Dan O'Reilly | 5de2a81 | 2015-08-20 18:19:56 -0400 | [diff] [blame] | 235 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 236 | build_python() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 237 | internal_build_cpp |
Dan O'Reilly | 5de2a81 | 2015-08-20 18:19:56 -0400 | [diff] [blame] | 238 | internal_install_python_deps |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 239 | cd python |
Dan O'Reilly | d9598ca | 2015-08-26 20:30:41 -0400 | [diff] [blame] | 240 | # Only test Python 2.6/3.x on Linux |
Dan O'Reilly | 76f8a3f | 2015-08-21 18:51:47 -0400 | [diff] [blame] | 241 | if [ $(uname -s) == "Linux" ]; then |
Jie Luo | 2850a98 | 2015-10-09 17:07:03 -0700 | [diff] [blame] | 242 | envlist=py\{26,27,33,34\}-python |
Dan O'Reilly | 76f8a3f | 2015-08-21 18:51:47 -0400 | [diff] [blame] | 243 | else |
| 244 | envlist=py27-python |
| 245 | fi |
| 246 | tox -e $envlist |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 247 | cd .. |
| 248 | } |
| 249 | |
| 250 | build_python_cpp() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 251 | internal_build_cpp |
Dan O'Reilly | 5de2a81 | 2015-08-20 18:19:56 -0400 | [diff] [blame] | 252 | internal_install_python_deps |
| 253 | export LD_LIBRARY_PATH=../src/.libs # for Linux |
Tamir Duberstein | c91d9ab | 2015-05-14 21:32:39 -0400 | [diff] [blame] | 254 | export DYLD_LIBRARY_PATH=../src/.libs # for OS X |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 255 | cd python |
Dan O'Reilly | d9598ca | 2015-08-26 20:30:41 -0400 | [diff] [blame] | 256 | # Only test Python 2.6/3.x on Linux |
Dan O'Reilly | 76f8a3f | 2015-08-21 18:51:47 -0400 | [diff] [blame] | 257 | if [ $(uname -s) == "Linux" ]; then |
Jisi Liu | 72bd9c9 | 2015-10-06 10:48:57 -0700 | [diff] [blame] | 258 | # py26 is currently disabled due to json_format |
| 259 | envlist=py\{27,33,34\}-cpp |
Dan O'Reilly | 76f8a3f | 2015-08-21 18:51:47 -0400 | [diff] [blame] | 260 | else |
| 261 | envlist=py27-cpp |
| 262 | fi |
| 263 | tox -e $envlist |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 264 | cd .. |
| 265 | } |
| 266 | |
| 267 | build_ruby19() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 268 | internal_build_cpp # For conformance tests. |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 269 | cd ruby && bash travis-test.sh ruby-1.9 && cd .. |
| 270 | } |
| 271 | build_ruby20() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 272 | internal_build_cpp # For conformance tests. |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 273 | cd ruby && bash travis-test.sh ruby-2.0 && cd .. |
| 274 | } |
| 275 | build_ruby21() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 276 | internal_build_cpp # For conformance tests. |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 277 | cd ruby && bash travis-test.sh ruby-2.1 && cd .. |
| 278 | } |
| 279 | build_ruby22() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 280 | internal_build_cpp # For conformance tests. |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 281 | cd ruby && bash travis-test.sh ruby-2.2 && cd .. |
| 282 | } |
| 283 | build_jruby() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 284 | internal_build_cpp # For conformance tests. |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 285 | cd ruby && bash travis-test.sh jruby && cd .. |
| 286 | } |
| 287 | |
Josh Haberman | e9cf31e | 2015-12-21 15:18:17 -0800 | [diff] [blame] | 288 | build_javascript() { |
| 289 | internal_build_cpp |
Josh Haberman | 0d2d8bc | 2015-12-28 06:43:42 -0800 | [diff] [blame] | 290 | cd js && npm install && npm test && cd .. |
Josh Haberman | e9cf31e | 2015-12-21 15:18:17 -0800 | [diff] [blame] | 291 | } |
| 292 | |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 293 | [ -n "${PARALLELISM}" ] && PARALLELISM=-j8 |
| 294 | |
| 295 | # Note: travis currently does not support testing more than one language so the |
| 296 | # .travis.yml cheats and claims to only be cpp. If they add multiple language |
| 297 | # support, this should probably get updated to install steps and/or |
| 298 | # rvm/gemfile/jdk/etc. entries rather than manually doing the work. |
| 299 | |
| 300 | # .travis.yml uses matrix.exclude to block the cases where app-get can't be |
| 301 | # use to install things. |
| 302 | |
| 303 | # -------- main -------- |
| 304 | |
| 305 | # Set value used in tests.sh. |
| 306 | PARALLELISM=-j2 |
| 307 | |
| 308 | if [ "$#" -ne 1 ]; then |
| 309 | echo " |
| 310 | Usage: $0 { cpp | |
| 311 | csharp | |
| 312 | java_jdk6 | |
| 313 | java_jdk7 | |
| 314 | java_oracle7 | |
| 315 | javanano_jdk6 | |
| 316 | javanano_jdk7 | |
| 317 | javanano_oracle7 | |
| 318 | objectivec_ios | |
| 319 | objectivec_osx | |
| 320 | python | |
| 321 | python_cpp | |
| 322 | ruby_19 | |
| 323 | ruby_20 | |
| 324 | ruby_21 | |
| 325 | ruby_22 | |
| 326 | jruby } |
| 327 | " |
| 328 | exit 1 |
| 329 | fi |
| 330 | |
| 331 | set -e # exit immediately on error |
| 332 | set -x # display all commands |
| 333 | eval "build_$1" |