travis.sh 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. #!/usr/bin/env bash
  2. # Note: travis currently does not support testing more than one language so the
  3. # .travis.yml cheats and claims to only be cpp. If they add multiple language
  4. # support, this should probably get updated to install steps and/or
  5. # rvm/gemfile/jdk/etc. entries rather than manually doing the work.
  6. # .travis.yml uses matrix.exclude to block the cases where app-get can't be
  7. # use to install things.
  8. # For when some other test needs the C++ main build, including protoc and
  9. # libprotobuf.
  10. internal_build_cpp() {
  11. ./autogen.sh
  12. ./configure
  13. make -j2
  14. }
  15. build_cpp() {
  16. internal_build_cpp
  17. make check -j2
  18. cd conformance && make test_cpp && cd ..
  19. }
  20. build_cpp_distcheck() {
  21. ./autogen.sh
  22. ./configure
  23. make distcheck -j2
  24. }
  25. build_csharp() {
  26. # Just for the conformance tests. We don't currently
  27. # need to really build protoc, but it's simplest to keep with the
  28. # conventions of the other builds.
  29. internal_build_cpp
  30. # Install latest version of Mono
  31. sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
  32. echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
  33. echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list
  34. sudo apt-get update -qq
  35. sudo apt-get install -qq mono-devel referenceassemblies-pcl nunit
  36. wget www.nuget.org/NuGet.exe -O nuget.exe
  37. (cd csharp/src; mono ../../nuget.exe restore)
  38. csharp/buildall.sh
  39. cd conformance && make test_csharp && cd ..
  40. }
  41. use_java() {
  42. version=$1
  43. case "$version" in
  44. jdk6)
  45. sudo apt-get install openjdk-6-jdk
  46. export PATH=/usr/lib/jvm/java-6-openjdk-amd64/bin:$PATH
  47. ;;
  48. jdk7)
  49. sudo apt-get install openjdk-7-jdk
  50. export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
  51. ;;
  52. oracle7)
  53. sudo apt-get install python-software-properties # for apt-add-repository
  54. echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select true" | \
  55. sudo debconf-set-selections
  56. yes | sudo apt-add-repository ppa:webupd8team/java
  57. yes | sudo apt-get install oracle-java7-installer
  58. export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH
  59. ;;
  60. esac
  61. which java
  62. java -version
  63. }
  64. build_java() {
  65. # Java build needs `protoc`.
  66. internal_build_cpp
  67. cd java && mvn test && cd ..
  68. cd conformance && make test_java && cd ..
  69. }
  70. build_javanano() {
  71. # Java build needs `protoc`.
  72. internal_build_cpp
  73. cd javanano && mvn test && cd ..
  74. }
  75. build_java_jdk6() {
  76. use_java jdk6
  77. build_java
  78. }
  79. build_java_jdk7() {
  80. use_java jdk7
  81. build_java
  82. }
  83. build_java_oracle7() {
  84. use_java oracle7
  85. build_java
  86. }
  87. build_javanano_jdk6() {
  88. use_java jdk6
  89. build_javanano
  90. }
  91. build_javanano_jdk7() {
  92. use_java jdk7
  93. build_javanano
  94. }
  95. build_javanano_oracle7() {
  96. use_java oracle7
  97. build_javanano
  98. }
  99. internal_install_python_deps() {
  100. sudo pip install tox
  101. # Only install Python2.6 on Linux.
  102. if [ $(uname -s) == "Linux" ]; then
  103. sudo apt-get install -y python-software-properties # for apt-add-repository
  104. sudo apt-add-repository -y ppa:fkrull/deadsnakes
  105. sudo apt-get update -qq
  106. sudo apt-get install -y python2.6 python2.6-dev
  107. fi
  108. }
  109. build_python() {
  110. internal_build_cpp
  111. internal_install_python_deps
  112. cd python
  113. # Only test Python 2.6 on Linux
  114. if [ $(uname -s) == "Linux" ]; then
  115. envlist=py26-python,py27-python
  116. else
  117. envlist=py27-python
  118. fi
  119. tox -e $envlist
  120. cd ..
  121. }
  122. build_python_cpp() {
  123. internal_build_cpp
  124. internal_install_python_deps
  125. export LD_LIBRARY_PATH=../src/.libs # for Linux
  126. export DYLD_LIBRARY_PATH=../src/.libs # for OS X
  127. cd python
  128. # Only test Python 2.6 on Linux
  129. if [ $(uname -s) == "Linux" ]; then
  130. envlist=py26-cpp,py27-cpp
  131. else
  132. envlist=py27-cpp
  133. fi
  134. tox -e $envlist
  135. cd ..
  136. }
  137. build_ruby19() {
  138. internal_build_cpp # For conformance tests.
  139. cd ruby && bash travis-test.sh ruby-1.9 && cd ..
  140. }
  141. build_ruby20() {
  142. internal_build_cpp # For conformance tests.
  143. cd ruby && bash travis-test.sh ruby-2.0 && cd ..
  144. }
  145. build_ruby21() {
  146. internal_build_cpp # For conformance tests.
  147. cd ruby && bash travis-test.sh ruby-2.1 && cd ..
  148. }
  149. build_ruby22() {
  150. internal_build_cpp # For conformance tests.
  151. cd ruby && bash travis-test.sh ruby-2.2 && cd ..
  152. }
  153. build_jruby() {
  154. internal_build_cpp # For conformance tests.
  155. cd ruby && bash travis-test.sh jruby && cd ..
  156. }
  157. # -------- main --------
  158. if [ "$#" -ne 1 ]; then
  159. echo "
  160. Usage: $0 { cpp |
  161. csharp |
  162. java_jdk6 |
  163. java_jdk7 |
  164. java_oracle7 |
  165. javanano_jdk6 |
  166. javanano_jdk7 |
  167. javanano_oracle7 |
  168. python |
  169. python_cpp |
  170. ruby_19 |
  171. ruby_20 |
  172. ruby_21 |
  173. ruby_22 |
  174. jruby }
  175. "
  176. exit 1
  177. fi
  178. set -e # exit immediately on error
  179. set -x # display all commands
  180. eval "build_$1"