blob: a6ba14057930e350c13e8bc2b4ce42ddad6e5982 [file] [log] [blame]
Josh Haberman57be1d72016-02-18 14:55:00 -08001# This file is not intended to be executed directly. It is intended to be
2# included in a larger shell script.
Thomas Van Lentenc4d36382015-06-09 13:35:41 -04003
Josh Haberman181c7f22015-07-15 11:05:10 -07004# For when some other test needs the C++ main build, including protoc and
5# libprotobuf.
6internal_build_cpp() {
Josh Habermand33e93b2016-02-18 19:13:07 -08007 if [[ $(uname -s) == "Linux" && "$TRAVIS" == "true" ]]; then
Feng Xiao91258632015-12-21 03:34:28 -08008 # Install GCC 4.8 to replace the default GCC 4.6. We need 4.8 for more
9 # decent C++ 11 support in order to compile conformance tests.
10 sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
11 sudo apt-get update -qq
12 sudo apt-get install -qq g++-4.8
13 export CXX="g++-4.8" CC="gcc-4.8"
14 fi
Feng Xiao1e2fece2015-12-18 15:16:07 -080015
Chris Fallin20e94b22015-05-13 16:43:48 -070016 ./autogen.sh
17 ./configure
Josh Habermand33e93b2016-02-18 19:13:07 -080018 make $PARALLELISM
Josh Haberman181c7f22015-07-15 11:05:10 -070019}
20
21build_cpp() {
22 internal_build_cpp
Josh Habermand33e93b2016-02-18 19:13:07 -080023 make check $PARALLELISM
Chris Fallin20e94b22015-05-13 16:43:48 -070024 cd conformance && make test_cpp && cd ..
25}
26
27build_cpp_distcheck() {
28 ./autogen.sh
29 ./configure
Josh Habermand33e93b2016-02-18 19:13:07 -080030 make distcheck $PARALLELISM
Chris Fallin20e94b22015-05-13 16:43:48 -070031}
32
Jan Tattermuschddb36ef2015-05-18 17:34:02 -070033build_csharp() {
Jon Skeetb6defa72015-08-04 10:01:40 +010034 # Just for the conformance tests. We don't currently
35 # need to really build protoc, but it's simplest to keep with the
36 # conventions of the other builds.
37 internal_build_cpp
38
Jan Tattermuschddb36ef2015-05-18 17:34:02 -070039 # Install latest version of Mono
40 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
41 echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
42 echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list
43 sudo apt-get update -qq
44 sudo apt-get install -qq mono-devel referenceassemblies-pcl nunit
45 wget www.nuget.org/NuGet.exe -O nuget.exe
46
47 (cd csharp/src; mono ../../nuget.exe restore)
48 csharp/buildall.sh
Josh Habermane891c292015-12-30 16:03:49 -080049 cd conformance && make test_csharp && cd ..
Jan Tattermuschddb36ef2015-05-18 17:34:02 -070050}
51
Tim Swast7e31c4d2015-11-20 15:32:53 -080052build_golang() {
53 # Go build needs `protoc`.
54 internal_build_cpp
55 # Add protoc to the path so that the examples build finds it.
56 export PATH="`pwd`/src:$PATH"
57
58 # Install Go and the Go protobuf compiler plugin.
59 sudo apt-get update -qq
60 sudo apt-get install -qq golang
61 export GOPATH="$HOME/gocode"
62 mkdir -p "$GOPATH/src/github.com/google"
63 ln -s "`pwd`" "$GOPATH/src/github.com/google/protobuf"
64 export PATH="$GOPATH/bin:$PATH"
65 go get github.com/golang/protobuf/protoc-gen-go
66
67 cd examples && make gotest && cd ..
68}
69
Chris Fallin20e94b22015-05-13 16:43:48 -070070use_java() {
Chris Fallin20e94b22015-05-13 16:43:48 -070071 version=$1
72 case "$version" in
73 jdk6)
74 sudo apt-get install openjdk-6-jdk
75 export PATH=/usr/lib/jvm/java-6-openjdk-amd64/bin:$PATH
76 ;;
77 jdk7)
78 sudo apt-get install openjdk-7-jdk
79 export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
80 ;;
81 oracle7)
82 sudo apt-get install python-software-properties # for apt-add-repository
83 echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select true" | \
84 sudo debconf-set-selections
85 yes | sudo apt-add-repository ppa:webupd8team/java
86 yes | sudo apt-get install oracle-java7-installer
87 export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH
88 ;;
89 esac
90
91 which java
92 java -version
93}
94
95build_java() {
96 # Java build needs `protoc`.
Josh Haberman181c7f22015-07-15 11:05:10 -070097 internal_build_cpp
Feng Xiaoaf81dcf2015-12-21 03:25:59 -080098 cd java && mvn test && mvn install
Feng Xiao9e5fb552015-12-21 11:08:18 -080099 cd util && mvn test
100 cd ../..
101}
102
103build_java_with_conformance_tests() {
104 # Java build needs `protoc`.
105 internal_build_cpp
106 cd java && mvn test && mvn install
Feng Xiaoaf81dcf2015-12-21 03:25:59 -0800107 cd util && mvn test && mvn assembly:single
108 cd ../..
Chris Fallin20e94b22015-05-13 16:43:48 -0700109 cd conformance && make test_java && cd ..
110}
111
112build_javanano() {
113 # Java build needs `protoc`.
Josh Haberman181c7f22015-07-15 11:05:10 -0700114 internal_build_cpp
Chris Fallin20e94b22015-05-13 16:43:48 -0700115 cd javanano && mvn test && cd ..
116}
117
118build_java_jdk6() {
119 use_java jdk6
120 build_java
121}
122build_java_jdk7() {
123 use_java jdk7
Feng Xiao9e5fb552015-12-21 11:08:18 -0800124 build_java_with_conformance_tests
Chris Fallin20e94b22015-05-13 16:43:48 -0700125}
126build_java_oracle7() {
127 use_java oracle7
128 build_java
129}
130
131build_javanano_jdk6() {
132 use_java jdk6
133 build_javanano
134}
135build_javanano_jdk7() {
136 use_java jdk7
137 build_javanano
138}
139build_javanano_oracle7() {
140 use_java oracle7
141 build_javanano
142}
143
Dan O'Reilly5de2a812015-08-20 18:19:56 -0400144internal_install_python_deps() {
Thomas Van Lenten9642b822015-06-10 17:21:23 -0400145 # Install tox (OS X doesn't have pip).
146 if [ $(uname -s) == "Darwin" ]; then
147 sudo easy_install tox
148 else
149 sudo pip install tox
150 fi
Dan O'Reillyd9598ca2015-08-26 20:30:41 -0400151 # Only install Python2.6/3.x on Linux.
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400152 if [ $(uname -s) == "Linux" ]; then
153 sudo apt-get install -y python-software-properties # for apt-add-repository
154 sudo apt-add-repository -y ppa:fkrull/deadsnakes
155 sudo apt-get update -qq
156 sudo apt-get install -y python2.6 python2.6-dev
Dan O'Reillyd9598ca2015-08-26 20:30:41 -0400157 sudo apt-get install -y python3.3 python3.3-dev
158 sudo apt-get install -y python3.4 python3.4-dev
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400159 fi
Dan O'Reilly5de2a812015-08-20 18:19:56 -0400160}
161
Thomas Van Lenten76b61382015-11-09 14:21:51 -0500162internal_objectivec_common () {
163 # Make sure xctool is up to date. Adapted from
164 # http://docs.travis-ci.com/user/osx-ci-environment/
165 # We don't use a before_install because we test multiple OSes.
166 brew update
Thomas Van Lenten8c784502016-02-18 11:08:30 -0500167 # xctool 0.2.8 seems to have a bug where it randomly kills tests saying
168 # they failed. Disabling the updates, but letting it report about being
169 # updates as a hint that this needs to eventually get re-enabled.
170 # https://github.com/facebook/xctool/issues/619
171 # https://github.com/google/protobuf/issues/1232
172 brew outdated xctool || true
173 #brew outdated xctool || brew upgrade xctool
Thomas Van Lenten76b61382015-11-09 14:21:51 -0500174 # Reused the build script that takes care of configuring and ensuring things
Thomas Van Lenten1745f7e2015-11-17 10:18:49 -0500175 # are up to date. Xcode and conformance tests will be directly invoked.
176 objectivec/DevTools/full_mac_build.sh \
177 --core-only --skip-xcode --skip-objc-conformance
Thomas Van Lenten76b61382015-11-09 14:21:51 -0500178}
179
180internal_xctool_debug_and_release() {
Thomas Van Lentenefca3682016-02-16 15:10:14 -0500181 # Always use -reporter plain to avoid escape codes in output (makes travis
182 # logs easier to read).
183 xctool -reporter plain -configuration Debug "$@"
184 xctool -reporter plain -configuration Release "$@"
Thomas Van Lenten9642b822015-06-10 17:21:23 -0400185}
186
187build_objectivec_ios() {
Thomas Van Lenten76b61382015-11-09 14:21:51 -0500188 internal_objectivec_common
189 # https://github.com/facebook/xctool/issues/509 - unlike xcodebuild, xctool
190 # doesn't support >1 destination, so we have to build first and then run the
191 # tests one destination at a time.
192 internal_xctool_debug_and_release \
193 -project objectivec/ProtocolBuffers_iOS.xcodeproj \
194 -scheme ProtocolBuffers \
195 -sdk iphonesimulator \
196 build-tests
197 IOS_DESTINATIONS=(
198 "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
Thomas Van Lenten13241192016-02-16 09:19:50 -0500199 "platform=iOS Simulator,name=iPhone 6,OS=9.2" # 64bit
Thomas Van Lenten76b61382015-11-09 14:21:51 -0500200 "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit
Thomas Van Lenten13241192016-02-16 09:19:50 -0500201 "platform=iOS Simulator,name=iPad Air,OS=9.2" # 64bit
Thomas Van Lenten76b61382015-11-09 14:21:51 -0500202 )
203 for i in "${IOS_DESTINATIONS[@]}" ; do
204 internal_xctool_debug_and_release \
205 -project objectivec/ProtocolBuffers_iOS.xcodeproj \
206 -scheme ProtocolBuffers \
207 -sdk iphonesimulator \
208 -destination "${i}" \
Thomas Van Lenten8c784502016-02-18 11:08:30 -0500209 run-tests
Thomas Van Lenten76b61382015-11-09 14:21:51 -0500210 done
Thomas Van Lenten9642b822015-06-10 17:21:23 -0400211}
212
213build_objectivec_osx() {
Thomas Van Lenten76b61382015-11-09 14:21:51 -0500214 internal_objectivec_common
215 internal_xctool_debug_and_release \
216 -project objectivec/ProtocolBuffers_OSX.xcodeproj \
217 -scheme ProtocolBuffers \
218 -destination "platform=OS X,arch=x86_64" \
219 test
Thomas Van Lenten1745f7e2015-11-17 10:18:49 -0500220 cd conformance && make test_objc && cd ..
Thomas Van Lenten9642b822015-06-10 17:21:23 -0400221}
Dan O'Reilly5de2a812015-08-20 18:19:56 -0400222
Chris Fallin20e94b22015-05-13 16:43:48 -0700223build_python() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700224 internal_build_cpp
Dan O'Reilly5de2a812015-08-20 18:19:56 -0400225 internal_install_python_deps
Chris Fallin20e94b22015-05-13 16:43:48 -0700226 cd python
Dan O'Reillyd9598ca2015-08-26 20:30:41 -0400227 # Only test Python 2.6/3.x on Linux
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400228 if [ $(uname -s) == "Linux" ]; then
Jie Luo2850a982015-10-09 17:07:03 -0700229 envlist=py\{26,27,33,34\}-python
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400230 else
231 envlist=py27-python
232 fi
233 tox -e $envlist
Chris Fallin20e94b22015-05-13 16:43:48 -0700234 cd ..
235}
236
237build_python_cpp() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700238 internal_build_cpp
Dan O'Reilly5de2a812015-08-20 18:19:56 -0400239 internal_install_python_deps
240 export LD_LIBRARY_PATH=../src/.libs # for Linux
Tamir Dubersteinc91d9ab2015-05-14 21:32:39 -0400241 export DYLD_LIBRARY_PATH=../src/.libs # for OS X
Chris Fallin20e94b22015-05-13 16:43:48 -0700242 cd python
Dan O'Reillyd9598ca2015-08-26 20:30:41 -0400243 # Only test Python 2.6/3.x on Linux
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400244 if [ $(uname -s) == "Linux" ]; then
Jisi Liu72bd9c92015-10-06 10:48:57 -0700245 # py26 is currently disabled due to json_format
246 envlist=py\{27,33,34\}-cpp
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400247 else
248 envlist=py27-cpp
249 fi
250 tox -e $envlist
Chris Fallin20e94b22015-05-13 16:43:48 -0700251 cd ..
252}
253
254build_ruby19() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700255 internal_build_cpp # For conformance tests.
Chris Fallin20e94b22015-05-13 16:43:48 -0700256 cd ruby && bash travis-test.sh ruby-1.9 && cd ..
257}
258build_ruby20() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700259 internal_build_cpp # For conformance tests.
Chris Fallin20e94b22015-05-13 16:43:48 -0700260 cd ruby && bash travis-test.sh ruby-2.0 && cd ..
261}
262build_ruby21() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700263 internal_build_cpp # For conformance tests.
Chris Fallin20e94b22015-05-13 16:43:48 -0700264 cd ruby && bash travis-test.sh ruby-2.1 && cd ..
265}
266build_ruby22() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700267 internal_build_cpp # For conformance tests.
Chris Fallin20e94b22015-05-13 16:43:48 -0700268 cd ruby && bash travis-test.sh ruby-2.2 && cd ..
269}
270build_jruby() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700271 internal_build_cpp # For conformance tests.
Chris Fallin20e94b22015-05-13 16:43:48 -0700272 cd ruby && bash travis-test.sh jruby && cd ..
273}
274
Josh Habermane9cf31e2015-12-21 15:18:17 -0800275build_javascript() {
276 internal_build_cpp
Josh Haberman0d2d8bc2015-12-28 06:43:42 -0800277 cd js && npm install && npm test && cd ..
Josh Habermane9cf31e2015-12-21 15:18:17 -0800278}
279