OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env bash |
| 2 |
| 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 |
| 11 # For when some other test needs the C++ main build, including protoc and |
| 12 # libprotobuf. |
| 13 internal_build_cpp() { |
| 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 |
| 22 |
| 23 ./autogen.sh |
| 24 ./configure |
| 25 make -j2 |
| 26 } |
| 27 |
| 28 build_cpp() { |
| 29 internal_build_cpp |
| 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 |
| 40 build_csharp() { |
| 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 |
| 46 # Install latest version of Mono |
| 47 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6
A14DA29AA6A19B38D3D831EF |
| 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 m
ain" | 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 |
| 56 # TODO(xiaofeng): The conformance tests are disable because the testee program |
| 57 # crashes on some inputs. |
| 58 # cd conformance && make test_csharp && cd .. |
| 59 } |
| 60 |
| 61 build_golang() { |
| 62 # Go build needs `protoc`. |
| 63 internal_build_cpp |
| 64 # Add protoc to the path so that the examples build finds it. |
| 65 export PATH="`pwd`/src:$PATH" |
| 66 |
| 67 # Install Go and the Go protobuf compiler plugin. |
| 68 sudo apt-get update -qq |
| 69 sudo apt-get install -qq golang |
| 70 export GOPATH="$HOME/gocode" |
| 71 mkdir -p "$GOPATH/src/github.com/google" |
| 72 ln -s "`pwd`" "$GOPATH/src/github.com/google/protobuf" |
| 73 export PATH="$GOPATH/bin:$PATH" |
| 74 go get github.com/golang/protobuf/protoc-gen-go |
| 75 |
| 76 cd examples && make gotest && cd .. |
| 77 } |
| 78 |
| 79 use_java() { |
| 80 version=$1 |
| 81 case "$version" in |
| 82 jdk6) |
| 83 sudo apt-get install openjdk-6-jdk |
| 84 export PATH=/usr/lib/jvm/java-6-openjdk-amd64/bin:$PATH |
| 85 ;; |
| 86 jdk7) |
| 87 sudo apt-get install openjdk-7-jdk |
| 88 export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH |
| 89 ;; |
| 90 oracle7) |
| 91 sudo apt-get install python-software-properties # for apt-add-repository |
| 92 echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select tr
ue" | \ |
| 93 sudo debconf-set-selections |
| 94 yes | sudo apt-add-repository ppa:webupd8team/java |
| 95 yes | sudo apt-get install oracle-java7-installer |
| 96 export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH |
| 97 ;; |
| 98 esac |
| 99 |
| 100 which java |
| 101 java -version |
| 102 } |
| 103 |
| 104 build_java() { |
| 105 # Java build needs `protoc`. |
| 106 internal_build_cpp |
| 107 cd java && mvn test && mvn install |
| 108 cd util && mvn test |
| 109 cd ../.. |
| 110 } |
| 111 |
| 112 build_java_with_conformance_tests() { |
| 113 # Java build needs `protoc`. |
| 114 internal_build_cpp |
| 115 cd java && mvn test && mvn install |
| 116 cd util && mvn test && mvn assembly:single |
| 117 cd ../.. |
| 118 cd conformance && make test_java && cd .. |
| 119 } |
| 120 |
| 121 build_javanano() { |
| 122 # Java build needs `protoc`. |
| 123 internal_build_cpp |
| 124 cd javanano && mvn test && cd .. |
| 125 } |
| 126 |
| 127 build_java_jdk6() { |
| 128 use_java jdk6 |
| 129 build_java |
| 130 } |
| 131 build_java_jdk7() { |
| 132 use_java jdk7 |
| 133 build_java_with_conformance_tests |
| 134 } |
| 135 build_java_oracle7() { |
| 136 use_java oracle7 |
| 137 build_java |
| 138 } |
| 139 |
| 140 build_javanano_jdk6() { |
| 141 use_java jdk6 |
| 142 build_javanano |
| 143 } |
| 144 build_javanano_jdk7() { |
| 145 use_java jdk7 |
| 146 build_javanano |
| 147 } |
| 148 build_javanano_oracle7() { |
| 149 use_java oracle7 |
| 150 build_javanano |
| 151 } |
| 152 |
| 153 internal_install_python_deps() { |
| 154 # Install tox (OS X doesn't have pip). |
| 155 if [ $(uname -s) == "Darwin" ]; then |
| 156 sudo easy_install tox |
| 157 else |
| 158 sudo pip install tox |
| 159 fi |
| 160 # Only install Python2.6/3.x on Linux. |
| 161 if [ $(uname -s) == "Linux" ]; then |
| 162 sudo apt-get install -y python-software-properties # for apt-add-repository |
| 163 sudo apt-add-repository -y ppa:fkrull/deadsnakes |
| 164 sudo apt-get update -qq |
| 165 sudo apt-get install -y python2.6 python2.6-dev |
| 166 sudo apt-get install -y python3.3 python3.3-dev |
| 167 sudo apt-get install -y python3.4 python3.4-dev |
| 168 fi |
| 169 } |
| 170 |
| 171 internal_objectivec_common () { |
| 172 # Make sure xctool is up to date. Adapted from |
| 173 # http://docs.travis-ci.com/user/osx-ci-environment/ |
| 174 # We don't use a before_install because we test multiple OSes. |
| 175 brew update |
| 176 brew outdated xctool || brew upgrade xctool |
| 177 # Reused the build script that takes care of configuring and ensuring things |
| 178 # are up to date. Xcode and conformance tests will be directly invoked. |
| 179 objectivec/DevTools/full_mac_build.sh \ |
| 180 --core-only --skip-xcode --skip-objc-conformance |
| 181 } |
| 182 |
| 183 internal_xctool_debug_and_release() { |
| 184 xctool -configuration Debug "$@" |
| 185 xctool -configuration Release "$@" |
| 186 } |
| 187 |
| 188 build_objectivec_ios() { |
| 189 internal_objectivec_common |
| 190 # https://github.com/facebook/xctool/issues/509 - unlike xcodebuild, xctool |
| 191 # doesn't support >1 destination, so we have to build first and then run the |
| 192 # tests one destination at a time. |
| 193 internal_xctool_debug_and_release \ |
| 194 -project objectivec/ProtocolBuffers_iOS.xcodeproj \ |
| 195 -scheme ProtocolBuffers \ |
| 196 -sdk iphonesimulator \ |
| 197 build-tests |
| 198 IOS_DESTINATIONS=( |
| 199 "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit |
| 200 "platform=iOS Simulator,name=iPhone 6,OS=9.1" # 64bit |
| 201 "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit |
| 202 "platform=iOS Simulator,name=iPad Air,OS=9.1" # 64bit |
| 203 ) |
| 204 for i in "${IOS_DESTINATIONS[@]}" ; do |
| 205 internal_xctool_debug_and_release \ |
| 206 -project objectivec/ProtocolBuffers_iOS.xcodeproj \ |
| 207 -scheme ProtocolBuffers \ |
| 208 -sdk iphonesimulator \ |
| 209 -destination "${i}" \ |
| 210 run-tests |
| 211 done |
| 212 } |
| 213 |
| 214 build_objectivec_osx() { |
| 215 internal_objectivec_common |
| 216 internal_xctool_debug_and_release \ |
| 217 -project objectivec/ProtocolBuffers_OSX.xcodeproj \ |
| 218 -scheme ProtocolBuffers \ |
| 219 -destination "platform=OS X,arch=x86_64" \ |
| 220 test |
| 221 cd conformance && make test_objc && cd .. |
| 222 } |
| 223 |
| 224 build_python() { |
| 225 internal_build_cpp |
| 226 internal_install_python_deps |
| 227 cd python |
| 228 # Only test Python 2.6/3.x on Linux |
| 229 if [ $(uname -s) == "Linux" ]; then |
| 230 envlist=py\{26,27,33,34\}-python |
| 231 else |
| 232 envlist=py27-python |
| 233 fi |
| 234 tox -e $envlist |
| 235 cd .. |
| 236 } |
| 237 |
| 238 build_python_cpp() { |
| 239 internal_build_cpp |
| 240 internal_install_python_deps |
| 241 export LD_LIBRARY_PATH=../src/.libs # for Linux |
| 242 export DYLD_LIBRARY_PATH=../src/.libs # for OS X |
| 243 cd python |
| 244 # Only test Python 2.6/3.x on Linux |
| 245 if [ $(uname -s) == "Linux" ]; then |
| 246 # py26 is currently disabled due to json_format |
| 247 envlist=py\{27,33,34\}-cpp |
| 248 else |
| 249 envlist=py27-cpp |
| 250 fi |
| 251 tox -e $envlist |
| 252 cd .. |
| 253 } |
| 254 |
| 255 build_ruby19() { |
| 256 internal_build_cpp # For conformance tests. |
| 257 cd ruby && bash travis-test.sh ruby-1.9 && cd .. |
| 258 } |
| 259 build_ruby20() { |
| 260 internal_build_cpp # For conformance tests. |
| 261 cd ruby && bash travis-test.sh ruby-2.0 && cd .. |
| 262 } |
| 263 build_ruby21() { |
| 264 internal_build_cpp # For conformance tests. |
| 265 cd ruby && bash travis-test.sh ruby-2.1 && cd .. |
| 266 } |
| 267 build_ruby22() { |
| 268 internal_build_cpp # For conformance tests. |
| 269 cd ruby && bash travis-test.sh ruby-2.2 && cd .. |
| 270 } |
| 271 build_jruby() { |
| 272 internal_build_cpp # For conformance tests. |
| 273 cd ruby && bash travis-test.sh jruby && cd .. |
| 274 } |
| 275 |
| 276 build_javascript() { |
| 277 internal_build_cpp |
| 278 cd js && npm install && npm test && cd .. |
| 279 } |
| 280 |
| 281 # -------- main -------- |
| 282 |
| 283 if [ "$#" -ne 1 ]; then |
| 284 echo " |
| 285 Usage: $0 { cpp | |
| 286 csharp | |
| 287 java_jdk6 | |
| 288 java_jdk7 | |
| 289 java_oracle7 | |
| 290 javanano_jdk6 | |
| 291 javanano_jdk7 | |
| 292 javanano_oracle7 | |
| 293 objectivec_ios | |
| 294 objectivec_osx | |
| 295 python | |
| 296 python_cpp | |
| 297 ruby_19 | |
| 298 ruby_20 | |
| 299 ruby_21 | |
| 300 ruby_22 | |
| 301 jruby } |
| 302 " |
| 303 exit 1 |
| 304 fi |
| 305 |
| 306 set -e # exit immediately on error |
| 307 set -x # display all commands |
| 308 eval "build_$1" |
OLD | NEW |