blob: 9514ec2b0bb3f32865548e9b930f875b1b76aa8a [file] [log] [blame]
Tamir Dubersteine54c1452015-05-06 20:24:58 -04001#!/usr/bin/env bash
Chris Fallin20e94b22015-05-13 16:43:48 -07002
Thomas Van Lentenc4d36382015-06-09 13:35:41 -04003# 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 Haberman181c7f22015-07-15 11:05:10 -070011# For when some other test needs the C++ main build, including protoc and
12# libprotobuf.
13internal_build_cpp() {
Chris Fallin20e94b22015-05-13 16:43:48 -070014 ./autogen.sh
15 ./configure
16 make -j2
Josh Haberman181c7f22015-07-15 11:05:10 -070017}
18
19build_cpp() {
20 internal_build_cpp
Chris Fallin20e94b22015-05-13 16:43:48 -070021 make check -j2
22 cd conformance && make test_cpp && cd ..
23}
24
25build_cpp_distcheck() {
26 ./autogen.sh
27 ./configure
28 make distcheck -j2
29}
30
Jan Tattermuschddb36ef2015-05-18 17:34:02 -070031build_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 Fallin20e94b22015-05-13 16:43:48 -070044use_java() {
Chris Fallin20e94b22015-05-13 16:43:48 -070045 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
69build_java() {
70 # Java build needs `protoc`.
Josh Haberman181c7f22015-07-15 11:05:10 -070071 internal_build_cpp
Chris Fallin20e94b22015-05-13 16:43:48 -070072 cd java && mvn test && cd ..
73 cd conformance && make test_java && cd ..
74}
75
76build_javanano() {
77 # Java build needs `protoc`.
Josh Haberman181c7f22015-07-15 11:05:10 -070078 internal_build_cpp
Chris Fallin20e94b22015-05-13 16:43:48 -070079 cd javanano && mvn test && cd ..
80}
81
82build_java_jdk6() {
83 use_java jdk6
84 build_java
85}
86build_java_jdk7() {
87 use_java jdk7
88 build_java
89}
90build_java_oracle7() {
91 use_java oracle7
92 build_java
93}
94
95build_javanano_jdk6() {
96 use_java jdk6
97 build_javanano
98}
99build_javanano_jdk7() {
100 use_java jdk7
101 build_javanano
102}
103build_javanano_oracle7() {
104 use_java oracle7
105 build_javanano
106}
107
108build_python() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700109 internal_build_cpp
Chris Fallin20e94b22015-05-13 16:43:48 -0700110 cd python
111 python setup.py build
112 python setup.py test
Tamir Dubersteine4f4d9f2015-05-07 07:40:38 -0400113 python setup.py sdist
114 sudo pip install virtualenv && virtualenv /tmp/protoenv && /tmp/protoenv/bin/pip install dist/*
Chris Fallin20e94b22015-05-13 16:43:48 -0700115 cd ..
116}
117
118build_python_cpp() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700119 internal_build_cpp
Tamir Dubersteinc91d9ab2015-05-14 21:32:39 -0400120 export LD_LIBRARY_PATH=../src/.libs # for Linux
121 export DYLD_LIBRARY_PATH=../src/.libs # for OS X
Chris Fallin20e94b22015-05-13 16:43:48 -0700122 cd python
123 python setup.py build --cpp_implementation
124 python setup.py test --cpp_implementation
Tamir Dubersteine4f4d9f2015-05-07 07:40:38 -0400125 python setup.py sdist --cpp_implementation
126 sudo pip install virtualenv && virtualenv /tmp/protoenv && /tmp/protoenv/bin/pip install dist/*
Chris Fallin20e94b22015-05-13 16:43:48 -0700127 cd ..
128}
129
130build_ruby19() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700131 internal_build_cpp # For conformance tests.
Chris Fallin20e94b22015-05-13 16:43:48 -0700132 cd ruby && bash travis-test.sh ruby-1.9 && cd ..
133}
134build_ruby20() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700135 internal_build_cpp # For conformance tests.
Chris Fallin20e94b22015-05-13 16:43:48 -0700136 cd ruby && bash travis-test.sh ruby-2.0 && cd ..
137}
138build_ruby21() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700139 internal_build_cpp # For conformance tests.
Chris Fallin20e94b22015-05-13 16:43:48 -0700140 cd ruby && bash travis-test.sh ruby-2.1 && cd ..
141}
142build_ruby22() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700143 internal_build_cpp # For conformance tests.
Chris Fallin20e94b22015-05-13 16:43:48 -0700144 cd ruby && bash travis-test.sh ruby-2.2 && cd ..
145}
146build_jruby() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700147 internal_build_cpp # For conformance tests.
Chris Fallin20e94b22015-05-13 16:43:48 -0700148 cd ruby && bash travis-test.sh jruby && cd ..
149}
150
151# -------- main --------
152
153if [ "$#" -ne 1 ]; then
154 echo "
155Usage: $0 { cpp |
Jan Tattermuschddb36ef2015-05-18 17:34:02 -0700156 csharp |
Chris Fallin20e94b22015-05-13 16:43:48 -0700157 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
172fi
173
174set -e # exit immediately on error
175set -x # display all commands
176eval "build_$1"