travis.sh 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. build_python() {
  100. internal_build_cpp
  101. cd python
  102. python setup.py build
  103. python setup.py test
  104. python setup.py sdist
  105. sudo pip install virtualenv && virtualenv /tmp/protoenv && /tmp/protoenv/bin/pip install dist/*
  106. cd ..
  107. }
  108. build_python_cpp() {
  109. internal_build_cpp
  110. export LD_LIBRARY_PATH=../src/.libs # for Linux
  111. export DYLD_LIBRARY_PATH=../src/.libs # for OS X
  112. cd python
  113. python setup.py build --cpp_implementation
  114. python setup.py test --cpp_implementation
  115. python setup.py sdist --cpp_implementation
  116. sudo pip install virtualenv && virtualenv /tmp/protoenv && /tmp/protoenv/bin/pip install dist/*
  117. cd ..
  118. }
  119. build_ruby19() {
  120. internal_build_cpp # For conformance tests.
  121. cd ruby && bash travis-test.sh ruby-1.9 && cd ..
  122. }
  123. build_ruby20() {
  124. internal_build_cpp # For conformance tests.
  125. cd ruby && bash travis-test.sh ruby-2.0 && cd ..
  126. }
  127. build_ruby21() {
  128. internal_build_cpp # For conformance tests.
  129. cd ruby && bash travis-test.sh ruby-2.1 && cd ..
  130. }
  131. build_ruby22() {
  132. internal_build_cpp # For conformance tests.
  133. cd ruby && bash travis-test.sh ruby-2.2 && cd ..
  134. }
  135. build_jruby() {
  136. internal_build_cpp # For conformance tests.
  137. cd ruby && bash travis-test.sh jruby && cd ..
  138. }
  139. # -------- main --------
  140. if [ "$#" -ne 1 ]; then
  141. echo "
  142. Usage: $0 { cpp |
  143. csharp |
  144. java_jdk6 |
  145. java_jdk7 |
  146. java_oracle7 |
  147. javanano_jdk6 |
  148. javanano_jdk7 |
  149. javanano_oracle7 |
  150. python |
  151. python_cpp |
  152. ruby_19 |
  153. ruby_20 |
  154. ruby_21 |
  155. ruby_22 |
  156. jruby }
  157. "
  158. exit 1
  159. fi
  160. set -e # exit immediately on error
  161. set -x # display all commands
  162. eval "build_$1"