travis.sh 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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/3.x 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. sudo apt-get install -y python3.3 python3.3-dev
  108. sudo apt-get install -y python3.4 python3.4-dev
  109. fi
  110. }
  111. build_python() {
  112. internal_build_cpp
  113. internal_install_python_deps
  114. cd python
  115. # Only test Python 2.6/3.x on Linux
  116. if [ $(uname -s) == "Linux" ]; then
  117. envlist=py\{26,27,33,34\}-python
  118. else
  119. envlist=py27-python
  120. fi
  121. tox -e $envlist
  122. cd ..
  123. }
  124. build_python_cpp() {
  125. internal_build_cpp
  126. internal_install_python_deps
  127. export LD_LIBRARY_PATH=../src/.libs # for Linux
  128. export DYLD_LIBRARY_PATH=../src/.libs # for OS X
  129. cd python
  130. # Only test Python 2.6/3.x on Linux
  131. if [ $(uname -s) == "Linux" ]; then
  132. envlist=py\{26,27,33,34\}-cpp
  133. else
  134. envlist=py27-cpp
  135. fi
  136. tox -e $envlist
  137. cd ..
  138. }
  139. build_ruby19() {
  140. internal_build_cpp # For conformance tests.
  141. cd ruby && bash travis-test.sh ruby-1.9 && cd ..
  142. }
  143. build_ruby20() {
  144. internal_build_cpp # For conformance tests.
  145. cd ruby && bash travis-test.sh ruby-2.0 && cd ..
  146. }
  147. build_ruby21() {
  148. internal_build_cpp # For conformance tests.
  149. cd ruby && bash travis-test.sh ruby-2.1 && cd ..
  150. }
  151. build_ruby22() {
  152. internal_build_cpp # For conformance tests.
  153. cd ruby && bash travis-test.sh ruby-2.2 && cd ..
  154. }
  155. build_jruby() {
  156. internal_build_cpp # For conformance tests.
  157. cd ruby && bash travis-test.sh jruby && cd ..
  158. }
  159. # -------- main --------
  160. if [ "$#" -ne 1 ]; then
  161. echo "
  162. Usage: $0 { cpp |
  163. csharp |
  164. java_jdk6 |
  165. java_jdk7 |
  166. java_oracle7 |
  167. javanano_jdk6 |
  168. javanano_jdk7 |
  169. javanano_oracle7 |
  170. python |
  171. python_cpp |
  172. ruby_19 |
  173. ruby_20 |
  174. ruby_21 |
  175. ruby_22 |
  176. jruby }
  177. "
  178. exit 1
  179. fi
  180. set -e # exit immediately on error
  181. set -x # display all commands
  182. eval "build_$1"