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