travis.sh 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. # Install latest version of Mono
  27. sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
  28. echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
  29. echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list
  30. sudo apt-get update -qq
  31. sudo apt-get install -qq mono-devel referenceassemblies-pcl nunit
  32. wget www.nuget.org/NuGet.exe -O nuget.exe
  33. (cd csharp/src; mono ../../nuget.exe restore)
  34. csharp/buildall.sh
  35. }
  36. use_java() {
  37. version=$1
  38. case "$version" in
  39. jdk6)
  40. sudo apt-get install openjdk-6-jdk
  41. export PATH=/usr/lib/jvm/java-6-openjdk-amd64/bin:$PATH
  42. ;;
  43. jdk7)
  44. sudo apt-get install openjdk-7-jdk
  45. export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
  46. ;;
  47. oracle7)
  48. sudo apt-get install python-software-properties # for apt-add-repository
  49. echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select true" | \
  50. sudo debconf-set-selections
  51. yes | sudo apt-add-repository ppa:webupd8team/java
  52. yes | sudo apt-get install oracle-java7-installer
  53. export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH
  54. ;;
  55. esac
  56. which java
  57. java -version
  58. }
  59. build_java() {
  60. # Java build needs `protoc`.
  61. internal_build_cpp
  62. cd java && mvn test && cd ..
  63. cd conformance && make test_java && cd ..
  64. }
  65. build_javanano() {
  66. # Java build needs `protoc`.
  67. internal_build_cpp
  68. cd javanano && mvn test && cd ..
  69. }
  70. build_java_jdk6() {
  71. use_java jdk6
  72. build_java
  73. }
  74. build_java_jdk7() {
  75. use_java jdk7
  76. build_java
  77. }
  78. build_java_oracle7() {
  79. use_java oracle7
  80. build_java
  81. }
  82. build_javanano_jdk6() {
  83. use_java jdk6
  84. build_javanano
  85. }
  86. build_javanano_jdk7() {
  87. use_java jdk7
  88. build_javanano
  89. }
  90. build_javanano_oracle7() {
  91. use_java oracle7
  92. build_javanano
  93. }
  94. build_python() {
  95. internal_build_cpp
  96. cd python
  97. python setup.py build
  98. python setup.py test
  99. python setup.py sdist
  100. sudo pip install virtualenv && virtualenv /tmp/protoenv && /tmp/protoenv/bin/pip install dist/*
  101. cd ..
  102. }
  103. build_python_cpp() {
  104. internal_build_cpp
  105. export LD_LIBRARY_PATH=../src/.libs # for Linux
  106. export DYLD_LIBRARY_PATH=../src/.libs # for OS X
  107. cd python
  108. python setup.py build --cpp_implementation
  109. python setup.py test --cpp_implementation
  110. python setup.py sdist --cpp_implementation
  111. sudo pip install virtualenv && virtualenv /tmp/protoenv && /tmp/protoenv/bin/pip install dist/*
  112. cd ..
  113. }
  114. build_ruby19() {
  115. internal_build_cpp # For conformance tests.
  116. cd ruby && bash travis-test.sh ruby-1.9 && cd ..
  117. }
  118. build_ruby20() {
  119. internal_build_cpp # For conformance tests.
  120. cd ruby && bash travis-test.sh ruby-2.0 && cd ..
  121. }
  122. build_ruby21() {
  123. internal_build_cpp # For conformance tests.
  124. cd ruby && bash travis-test.sh ruby-2.1 && cd ..
  125. }
  126. build_ruby22() {
  127. internal_build_cpp # For conformance tests.
  128. cd ruby && bash travis-test.sh ruby-2.2 && cd ..
  129. }
  130. build_jruby() {
  131. internal_build_cpp # For conformance tests.
  132. cd ruby && bash travis-test.sh jruby && cd ..
  133. }
  134. # -------- main --------
  135. if [ "$#" -ne 1 ]; then
  136. echo "
  137. Usage: $0 { cpp |
  138. csharp |
  139. java_jdk6 |
  140. java_jdk7 |
  141. java_oracle7 |
  142. javanano_jdk6 |
  143. javanano_jdk7 |
  144. javanano_oracle7 |
  145. python |
  146. python_cpp |
  147. ruby_19 |
  148. ruby_20 |
  149. ruby_21 |
  150. ruby_22 |
  151. jruby }
  152. "
  153. exit 1
  154. fi
  155. set -e # exit immediately on error
  156. set -x # display all commands
  157. eval "build_$1"