travis.sh 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. sudo apt-get install -y python-software-properties # for apt-add-repository
  102. sudo apt-add-repository -y ppa:fkrull/deadsnakes
  103. sudo apt-get update -qq
  104. sudo apt-get install -y python2.6 python2.6-dev
  105. }
  106. build_python() {
  107. internal_build_cpp
  108. internal_install_python_deps
  109. cd python
  110. tox -e py26-python,py27-python
  111. cd ..
  112. }
  113. build_python_cpp() {
  114. internal_build_cpp
  115. internal_install_python_deps
  116. export LD_LIBRARY_PATH=../src/.libs # for Linux
  117. export DYLD_LIBRARY_PATH=../src/.libs # for OS X
  118. cd python
  119. tox -e py26-cpp,py27-cpp
  120. cd ..
  121. }
  122. build_ruby19() {
  123. internal_build_cpp # For conformance tests.
  124. cd ruby && bash travis-test.sh ruby-1.9 && cd ..
  125. }
  126. build_ruby20() {
  127. internal_build_cpp # For conformance tests.
  128. cd ruby && bash travis-test.sh ruby-2.0 && cd ..
  129. }
  130. build_ruby21() {
  131. internal_build_cpp # For conformance tests.
  132. cd ruby && bash travis-test.sh ruby-2.1 && cd ..
  133. }
  134. build_ruby22() {
  135. internal_build_cpp # For conformance tests.
  136. cd ruby && bash travis-test.sh ruby-2.2 && cd ..
  137. }
  138. build_jruby() {
  139. internal_build_cpp # For conformance tests.
  140. cd ruby && bash travis-test.sh jruby && cd ..
  141. }
  142. # -------- main --------
  143. if [ "$#" -ne 1 ]; then
  144. echo "
  145. Usage: $0 { cpp |
  146. csharp |
  147. java_jdk6 |
  148. java_jdk7 |
  149. java_oracle7 |
  150. javanano_jdk6 |
  151. javanano_jdk7 |
  152. javanano_oracle7 |
  153. python |
  154. python_cpp |
  155. ruby_19 |
  156. ruby_20 |
  157. ruby_21 |
  158. ruby_22 |
  159. jruby }
  160. "
  161. exit 1
  162. fi
  163. set -e # exit immediately on error
  164. set -x # display all commands
  165. eval "build_$1"