Tamir Duberstein | e54c145 | 2015-05-06 20:24:58 -0400 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 2 | |
Thomas Van Lenten | c4d3638 | 2015-06-09 13:35:41 -0400 | [diff] [blame] | 3 | # Note: travis currently does not support testing more than one language so the |
| 4 | # .travis.yml cheats and claims to only be cpp. If they add multiple language |
| 5 | # support, this should probably get updated to install steps and/or |
| 6 | # rvm/gemfile/jdk/etc. entries rather than manually doing the work. |
| 7 | |
| 8 | # .travis.yml uses matrix.exclude to block the cases where app-get can't be |
| 9 | # use to install things. |
| 10 | |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 11 | # For when some other test needs the C++ main build, including protoc and |
| 12 | # libprotobuf. |
| 13 | internal_build_cpp() { |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 14 | ./autogen.sh |
| 15 | ./configure |
| 16 | make -j2 |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | build_cpp() { |
| 20 | internal_build_cpp |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 21 | make check -j2 |
| 22 | cd conformance && make test_cpp && cd .. |
| 23 | } |
| 24 | |
| 25 | build_cpp_distcheck() { |
| 26 | ./autogen.sh |
| 27 | ./configure |
| 28 | make distcheck -j2 |
| 29 | } |
| 30 | |
Jan Tattermusch | ddb36ef | 2015-05-18 17:34:02 -0700 | [diff] [blame] | 31 | build_csharp() { |
Jon Skeet | b6defa7 | 2015-08-04 10:01:40 +0100 | [diff] [blame] | 32 | # Just for the conformance tests. We don't currently |
| 33 | # need to really build protoc, but it's simplest to keep with the |
| 34 | # conventions of the other builds. |
| 35 | internal_build_cpp |
| 36 | |
Jan Tattermusch | ddb36ef | 2015-05-18 17:34:02 -0700 | [diff] [blame] | 37 | # Install latest version of Mono |
| 38 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF |
| 39 | echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list |
| 40 | echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list |
| 41 | sudo apt-get update -qq |
| 42 | sudo apt-get install -qq mono-devel referenceassemblies-pcl nunit |
| 43 | wget www.nuget.org/NuGet.exe -O nuget.exe |
| 44 | |
| 45 | (cd csharp/src; mono ../../nuget.exe restore) |
| 46 | csharp/buildall.sh |
Jon Skeet | b6defa7 | 2015-08-04 10:01:40 +0100 | [diff] [blame] | 47 | cd conformance && make test_csharp && cd .. |
Jan Tattermusch | ddb36ef | 2015-05-18 17:34:02 -0700 | [diff] [blame] | 48 | } |
| 49 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 50 | use_java() { |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 51 | version=$1 |
| 52 | case "$version" in |
| 53 | jdk6) |
| 54 | sudo apt-get install openjdk-6-jdk |
| 55 | export PATH=/usr/lib/jvm/java-6-openjdk-amd64/bin:$PATH |
| 56 | ;; |
| 57 | jdk7) |
| 58 | sudo apt-get install openjdk-7-jdk |
| 59 | export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH |
| 60 | ;; |
| 61 | oracle7) |
| 62 | sudo apt-get install python-software-properties # for apt-add-repository |
| 63 | echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select true" | \ |
| 64 | sudo debconf-set-selections |
| 65 | yes | sudo apt-add-repository ppa:webupd8team/java |
| 66 | yes | sudo apt-get install oracle-java7-installer |
| 67 | export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH |
| 68 | ;; |
| 69 | esac |
| 70 | |
| 71 | which java |
| 72 | java -version |
| 73 | } |
| 74 | |
| 75 | build_java() { |
| 76 | # Java build needs `protoc`. |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 77 | internal_build_cpp |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 78 | cd java && mvn test && cd .. |
| 79 | cd conformance && make test_java && cd .. |
| 80 | } |
| 81 | |
| 82 | build_javanano() { |
| 83 | # Java build needs `protoc`. |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 84 | internal_build_cpp |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 85 | cd javanano && mvn test && cd .. |
| 86 | } |
| 87 | |
| 88 | build_java_jdk6() { |
| 89 | use_java jdk6 |
| 90 | build_java |
| 91 | } |
| 92 | build_java_jdk7() { |
| 93 | use_java jdk7 |
| 94 | build_java |
| 95 | } |
| 96 | build_java_oracle7() { |
| 97 | use_java oracle7 |
| 98 | build_java |
| 99 | } |
| 100 | |
| 101 | build_javanano_jdk6() { |
| 102 | use_java jdk6 |
| 103 | build_javanano |
| 104 | } |
| 105 | build_javanano_jdk7() { |
| 106 | use_java jdk7 |
| 107 | build_javanano |
| 108 | } |
| 109 | build_javanano_oracle7() { |
| 110 | use_java oracle7 |
| 111 | build_javanano |
| 112 | } |
| 113 | |
| 114 | build_python() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 115 | internal_build_cpp |
Dan O'Reilly | 5029c7b | 2015-08-20 15:45:53 -0400 | [diff] [blame] | 116 | sudo pip install tox |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 117 | cd python |
Dan O'Reilly | 416f001 | 2015-08-20 15:29:10 -0400 | [diff] [blame] | 118 | tox |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 119 | cd .. |
| 120 | } |
| 121 | |
| 122 | build_python_cpp() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 123 | internal_build_cpp |
Dan O'Reilly | 5029c7b | 2015-08-20 15:45:53 -0400 | [diff] [blame] | 124 | sudo pip install tox |
Tamir Duberstein | c91d9ab | 2015-05-14 21:32:39 -0400 | [diff] [blame] | 125 | export LD_LIBRARY_PATH=../src/.libs # for Linux |
| 126 | export DYLD_LIBRARY_PATH=../src/.libs # for OS X |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 127 | cd python |
Dan O'Reilly | 416f001 | 2015-08-20 15:29:10 -0400 | [diff] [blame] | 128 | tox -- --cpp_implementation |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 129 | cd .. |
| 130 | } |
| 131 | |
| 132 | build_ruby19() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 133 | internal_build_cpp # For conformance tests. |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 134 | cd ruby && bash travis-test.sh ruby-1.9 && cd .. |
| 135 | } |
| 136 | build_ruby20() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 137 | internal_build_cpp # For conformance tests. |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 138 | cd ruby && bash travis-test.sh ruby-2.0 && cd .. |
| 139 | } |
| 140 | build_ruby21() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 141 | internal_build_cpp # For conformance tests. |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 142 | cd ruby && bash travis-test.sh ruby-2.1 && cd .. |
| 143 | } |
| 144 | build_ruby22() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 145 | internal_build_cpp # For conformance tests. |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 146 | cd ruby && bash travis-test.sh ruby-2.2 && cd .. |
| 147 | } |
| 148 | build_jruby() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 149 | internal_build_cpp # For conformance tests. |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 150 | cd ruby && bash travis-test.sh jruby && cd .. |
| 151 | } |
| 152 | |
| 153 | # -------- main -------- |
| 154 | |
| 155 | if [ "$#" -ne 1 ]; then |
| 156 | echo " |
| 157 | Usage: $0 { cpp | |
Jan Tattermusch | ddb36ef | 2015-05-18 17:34:02 -0700 | [diff] [blame] | 158 | csharp | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 159 | java_jdk6 | |
| 160 | java_jdk7 | |
| 161 | java_oracle7 | |
| 162 | javanano_jdk6 | |
| 163 | javanano_jdk7 | |
| 164 | javanano_oracle7 | |
| 165 | python | |
| 166 | python_cpp | |
| 167 | ruby_19 | |
| 168 | ruby_20 | |
| 169 | ruby_21 | |
| 170 | ruby_22 | |
| 171 | jruby } |
| 172 | " |
| 173 | exit 1 |
| 174 | fi |
| 175 | |
| 176 | set -e # exit immediately on error |
| 177 | set -x # display all commands |
| 178 | eval "build_$1" |