travis.sh 4.0 KB

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