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