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