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