blob: 180b8702106d0c7a7c67813399b5a5d3c09ef67e [file] [log] [blame]
Josh Haberman738393b2016-02-18 20:10:23 -08001#!/bin/bash
Josh Haberman67c727c2016-03-04 14:21:18 -08002#
Elliotte Rusty Harold19275202022-04-28 15:55:28 +00003# Build and run tests for the protobuf project. We use this script to run
Feng Xiao9de4e642018-07-13 16:55:32 -07004# tests on kokoro (Ubuntu and MacOS). It can run locally as well but you
Elliotte Rusty Harold19275202022-04-28 15:55:28 +00005# need to make sure the required compilers/tools are available.
Josh Haberman0f8c25d2016-02-19 09:11:38 -08006
Josh Haberman181c7f22015-07-15 11:05:10 -07007internal_build_cpp() {
Josh Haberman738393b2016-02-18 20:10:23 -08008 if [ -f src/protoc ]; then
9 # Already built.
10 return
11 fi
12
Carlos O'Ryan3c5442a2018-03-26 16:54:32 -040013 # Initialize any submodules.
14 git submodule update --init --recursive
15
Chris Fallin20e94b22015-05-13 16:43:48 -070016 ./autogen.sh
Ben Wolsieffer56b40a82018-10-04 20:25:10 -040017 ./configure CXXFLAGS="-fPIC -std=c++11" # -fPIC is needed for python cpp test.
18 # See python/setup.py for more details
Joshua Habermanf5e8ee42019-03-06 12:04:17 -080019 make -j$(nproc)
Josh Haberman181c7f22015-07-15 11:05:10 -070020}
21
22build_cpp() {
23 internal_build_cpp
Joshua Habermanf5e8ee42019-03-06 12:04:17 -080024 make check -j$(nproc) || (cat src/test-suite.log; false)
Bo Yangfd332d12016-09-30 00:07:47 +000025 cd conformance && make test_cpp && cd ..
Chris Fallin20e94b22015-05-13 16:43:48 -070026}
27
Hao Nguyen4f8a6352019-01-23 10:02:51 -080028build_cpp_tcmalloc() {
29 internal_build_cpp
30 ./configure LIBS=-ltcmalloc && make clean && make \
31 PTHREAD_CFLAGS='-pthread -DGOOGLE_PROTOBUF_HEAP_CHECK_DRACONIAN' \
32 check
33 cd src
Adam Cozzetted135f072019-01-25 10:28:52 -080034 PPROF_PATH=/usr/bin/google-pprof HEAPCHECK=strict ./protobuf-test
Hao Nguyen4f8a6352019-01-23 10:02:51 -080035}
36
Chris Fallin20e94b22015-05-13 16:43:48 -070037build_cpp_distcheck() {
Adam Cozzette45aba802019-03-11 14:39:49 -070038 grep -q -- "-Og" src/Makefile.am &&
39 echo "The -Og flag is incompatible with Clang versions older than 4.0." &&
40 exit 1
41
Carlos O'Ryan3c5442a2018-03-26 16:54:32 -040042 # Initialize any submodules.
43 git submodule update --init --recursive
Chris Fallin20e94b22015-05-13 16:43:48 -070044 ./autogen.sh
45 ./configure
Feng Xiaoa4f68b12016-07-19 17:20:31 -070046 make dist
47
48 # List all files that should be included in the distribution package.
Adam Cozzette860f8ad2022-04-28 12:08:26 -070049 git ls-files | grep "^\(java\|python\|objectivec\|csharp\|ruby\|php\|cmake\|examples\|src/google/protobuf/.*\.proto\)" |\
Derek Perezd1b2eff2021-04-20 09:36:06 -070050 grep -v ".gitignore" | grep -v "java/lite/proguard.pgcfg" |\
David L. Jonesf1308272020-03-06 16:37:15 -080051 grep -v "python/compatibility_tests" | grep -v "python/docs" | grep -v "python/.repo-metadata.json" |\
David L. Jonesff06e232020-08-31 10:40:57 -070052 grep -v "python/protobuf_distutils" | grep -v "csharp/compatibility_tests" > dist.lst
Feng Xiaoa4f68b12016-07-19 17:20:31 -070053 # Unzip the dist tar file.
54 DIST=`ls *.tar.gz`
55 tar -xf $DIST
56 cd ${DIST//.tar.gz}
57 # Check if every file exists in the dist tar file.
58 FILES_MISSING=""
59 for FILE in $(<../dist.lst); do
Feng Xiaoacd5b052018-08-09 21:21:01 -070060 [ -f "$FILE" ] || {
Feng Xiaoa4f68b12016-07-19 17:20:31 -070061 echo "$FILE is not found!"
62 FILES_MISSING="$FILE $FILES_MISSING"
Feng Xiaoacd5b052018-08-09 21:21:01 -070063 }
Feng Xiaoa4f68b12016-07-19 17:20:31 -070064 done
65 cd ..
66 if [ ! -z "$FILES_MISSING" ]; then
67 echo "Missing files in EXTRA_DIST: $FILES_MISSING"
68 exit 1
69 fi
70
71 # Do the regular dist-check for C++.
Joshua Habermanf5e8ee42019-03-06 12:04:17 -080072 make distcheck -j$(nproc)
Chris Fallin20e94b22015-05-13 16:43:48 -070073}
74
Hao Nguyenf85c8232019-03-07 14:34:28 -080075build_dist_install() {
Adam Cozzette0e7a35f2021-09-29 13:41:33 -070076 # Create a symlink pointing to python2 and put it at the beginning of $PATH.
77 # This is necessary because the googletest build system involves a Python
78 # script that is not compatible with Python 3. More recent googletest
79 # versions have fixed this, but they have also removed the autotools build
80 # system support that we rely on. This is a temporary workaround to keep the
81 # googletest build working when the default python binary is Python 3.
82 mkdir tmp || true
83 pushd tmp
84 ln -s /usr/bin/python2 ./python
85 popd
86 PATH=$PWD/tmp:$PATH
87
Hao Nguyenf85c8232019-03-07 14:34:28 -080088 # Initialize any submodules.
89 git submodule update --init --recursive
90 ./autogen.sh
91 ./configure
92 make dist
93
94 # Unzip the dist tar file and install it.
95 DIST=`ls *.tar.gz`
96 tar -xf $DIST
97 pushd ${DIST//.tar.gz}
98 ./configure && make check -j4 && make install
99
100 export LD_LIBRARY_PATH=/usr/local/lib
101
102 # Try to install Java
103 pushd java
Joshua Haberman301d3152022-02-08 18:31:50 -0800104 use_java jdk11
Hao Nguyenf85c8232019-03-07 14:34:28 -0800105 $MVN install
106 popd
107
108 # Try to install Python
Joshua Haberman301d3152022-02-08 18:31:50 -0800109 python3 -m venv venv
Hao Nguyenf85c8232019-03-07 14:34:28 -0800110 source venv/bin/activate
111 pushd python
Adam Cozzette151e6322021-09-23 15:08:32 -0700112 python3 setup.py clean build sdist
113 pip3 install dist/protobuf-*.tar.gz
Hao Nguyenf85c8232019-03-07 14:34:28 -0800114 popd
115 deactivate
116 rm -rf python/venv
117}
118
Jan Tattermuschddb36ef2015-05-18 17:34:02 -0700119build_csharp() {
Jon Skeet9a9a66e2017-10-25 08:03:50 +0100120 # Required for conformance tests and to regenerate protos.
Jon Skeetb6defa72015-08-04 10:01:40 +0100121 internal_build_cpp
Josh Habermanffc81182016-02-22 15:39:29 -0800122 NUGET=/usr/local/bin/nuget.exe
Jon Skeetb6defa72015-08-04 10:01:40 +0100123
Jan Tattermusch67fee072019-03-12 04:48:10 -0400124 # Disable some unwanted dotnet options
125 export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
126 export DOTNET_CLI_TELEMETRY_OPTOUT=true
127
128 # TODO(jtattermusch): is this still needed with "first time experience"
129 # disabled?
Jon Skeet10a8fb42016-07-14 22:01:47 +0100130 # Perform "dotnet new" once to get the setup preprocessing out of the
131 # way. That spews a lot of output (including backspaces) into logs
132 # otherwise, and can cause problems. It doesn't matter if this step
133 # is performed multiple times; it's cheap after the first time anyway.
Jon Skeetf26e8c22017-05-04 08:51:46 +0100134 # (It also doesn't matter if it's unnecessary, which it will be on some
135 # systems. It's necessary on Jenkins in order to avoid unprintable
136 # characters appearing in the JUnit output.)
Jon Skeet10a8fb42016-07-14 22:01:47 +0100137 mkdir dotnettmp
138 (cd dotnettmp; dotnet new > /dev/null)
139 rm -rf dotnettmp
140
Jon Skeet9a9a66e2017-10-25 08:03:50 +0100141 # Check that the protos haven't broken C# codegen.
142 # TODO(jonskeet): Fail if regenerating creates any changes.
143 csharp/generate_protos.sh
Brent Shaffer67379542018-05-23 16:43:30 -0700144
Jan Tattermuschddb36ef2015-05-18 17:34:02 -0700145 csharp/buildall.sh
Josh Habermane891c292015-12-30 16:03:49 -0800146 cd conformance && make test_csharp && cd ..
Jie Luo72886892017-02-09 16:49:52 -0800147
148 # Run csharp compatibility test between 3.0.0 and the current version.
149 csharp/compatibility_tests/v3.0.0/test.sh 3.0.0
Jon Skeet9f597a42022-03-28 11:38:50 +0100150
151 # Regression test for https://github.com/protocolbuffers/protobuf/issues/9526
152 # - all line endings in .proto and .cs (and .csproj) files should be LF.
153 if git ls-files --eol csharp | grep -E '\.cs|\.proto' | grep -v w/lf
154 then
155 echo "The files listed above have mixed or CRLF line endings; please change to LF."
156 exit 1
157 fi
Jan Tattermuschddb36ef2015-05-18 17:34:02 -0700158}
159
Tim Swast7e31c4d2015-11-20 15:32:53 -0800160build_golang() {
161 # Go build needs `protoc`.
162 internal_build_cpp
163 # Add protoc to the path so that the examples build finds it.
164 export PATH="`pwd`/src:$PATH"
165
Tim Swast7e31c4d2015-11-20 15:32:53 -0800166 export GOPATH="$HOME/gocode"
Feng Xiaoa0a17e22018-08-23 15:35:52 -0700167 mkdir -p "$GOPATH/src/github.com/protocolbuffers"
Joe Tsai654edd82020-05-12 13:02:09 -0700168 mkdir -p "$GOPATH/src/github.com/golang"
Feng Xiaoafe98de2018-08-22 11:55:30 -0700169 rm -f "$GOPATH/src/github.com/protocolbuffers/protobuf"
Joe Tsai654edd82020-05-12 13:02:09 -0700170 rm -f "$GOPATH/src/github.com/golang/protobuf"
Feng Xiaoafe98de2018-08-22 11:55:30 -0700171 ln -s "`pwd`" "$GOPATH/src/github.com/protocolbuffers/protobuf"
Tim Swast7e31c4d2015-11-20 15:32:53 -0800172 export PATH="$GOPATH/bin:$PATH"
Joe Tsai654edd82020-05-12 13:02:09 -0700173 (cd $GOPATH/src/github.com/golang && git clone https://github.com/golang/protobuf.git && cd protobuf && git checkout v1.3.5)
174 go install github.com/golang/protobuf/protoc-gen-go
Tim Swast7e31c4d2015-11-20 15:32:53 -0800175
Feng Xiao8136ccb2017-09-12 12:00:20 -0700176 cd examples && PROTO_PATH="-I../src -I." make gotest && cd ..
Tim Swast7e31c4d2015-11-20 15:32:53 -0800177}
178
Chris Fallin20e94b22015-05-13 16:43:48 -0700179use_java() {
Chris Fallin20e94b22015-05-13 16:43:48 -0700180 version=$1
181 case "$version" in
Elliotte Rusty Haroldcc8ae4c2022-04-18 19:54:42 +0000182 jdk17)
183 export PATH=/usr/lib/jvm/java-17-openjdk-amd64/bin:$PATH
184 export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
185 ;;
Joshua Haberman301d3152022-02-08 18:31:50 -0800186 jdk11)
187 export PATH=/usr/lib/jvm/java-11-openjdk-amd64/bin:$PATH
188 export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
189 ;;
Tomo Suzuki70517252019-06-26 15:28:49 -0400190 jdk8)
191 export PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin:$PATH
192 export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
193 ;;
Chris Fallin20e94b22015-05-13 16:43:48 -0700194 jdk7)
Chris Fallin20e94b22015-05-13 16:43:48 -0700195 export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
Feng Xiaoad49ed72016-07-21 11:37:46 -0700196 export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
Chris Fallin20e94b22015-05-13 16:43:48 -0700197 ;;
198 oracle7)
Chris Fallin20e94b22015-05-13 16:43:48 -0700199 export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH
Feng Xiaoad49ed72016-07-21 11:37:46 -0700200 export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
Chris Fallin20e94b22015-05-13 16:43:48 -0700201 ;;
202 esac
203
Feng Xiao9de4e642018-07-13 16:55:32 -0700204 MAVEN_LOCAL_REPOSITORY=/var/maven_local_repository
Elliotte Rusty Harold5711cab2021-12-14 23:40:36 +0000205 MVN="$MVN -e --quiet -Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$MAVEN_LOCAL_REPOSITORY"
Josh Haberman1ee0fda2016-03-03 16:02:55 -0800206
Chris Fallin20e94b22015-05-13 16:43:48 -0700207 which java
208 java -version
Feng Xiaoad49ed72016-07-21 11:37:46 -0700209 $MVN -version
Chris Fallin20e94b22015-05-13 16:43:48 -0700210}
211
Brian Wignalla104dff2020-01-08 13:18:20 -0500212# --batch-mode suppresses download progress output that spams the logs.
Josh Habermanb28b3f62016-02-20 12:17:10 -0800213MVN="mvn --batch-mode"
Josh Habermand08c39c2016-02-20 12:03:39 -0800214
Jason Lunnddd7f462021-10-06 13:06:27 -0400215internal_build_java() {
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800216 version=$1
217 dir=java_$version
Chris Fallin20e94b22015-05-13 16:43:48 -0700218 # Java build needs `protoc`.
Josh Haberman181c7f22015-07-15 11:05:10 -0700219 internal_build_cpp
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800220 cp -r java $dir
Adam Cozzette5a9367a2021-05-11 12:07:45 -0700221 cd $dir && $MVN clean
Jason Lunnddd7f462021-10-06 13:06:27 -0400222 # Skip tests here - callers will decide what tests they want to run
Adam Cozzette388df002022-03-04 17:03:36 +0000223 $MVN install -Dmaven.test.skip=true
Jason Lunnddd7f462021-10-06 13:06:27 -0400224}
225
226build_java() {
Jason Lunn2ed81732021-10-06 16:40:09 -0400227 version=$1
228 internal_build_java $version
Adam Cozzette5a9367a2021-05-11 12:07:45 -0700229 # Skip the Kotlin tests on Oracle 7
230 if [ "$version" == "oracle7" ]; then
231 $MVN test -pl bom,lite,core,util
232 else
233 $MVN test
234 fi
Feng Xiao9e5fb552015-12-21 11:08:18 -0800235 cd ../..
236}
237
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800238# The conformance tests are hard-coded to work with the $ROOT/java directory.
239# So this can't run in parallel with two different sets of tests.
Feng Xiao9e5fb552015-12-21 11:08:18 -0800240build_java_with_conformance_tests() {
241 # Java build needs `protoc`.
242 internal_build_cpp
Tomo Suzukica25bad2019-10-22 13:42:35 -0400243 # This local installation avoids the problem caused by a new version not yet in Maven Central
244 cd java/bom && $MVN install
245 cd ../..
Deanna Garcia41e89c72021-06-24 18:21:49 +0000246 cd java/core && $MVN test && $MVN install
247 cd ../lite && $MVN test && $MVN install
Deanna Garcia1e8457f2021-06-24 22:06:55 +0000248 cd ../util && $MVN test && $MVN install && $MVN package assembly:single
Deanna Garcia41e89c72021-06-24 18:21:49 +0000249 if [ "$version" == "jdk8" ]; then
250 cd ../kotlin && $MVN test && $MVN install
251 cd ../kotlin-lite && $MVN test && $MVN install
252 fi
Feng Xiaoaf81dcf2015-12-21 03:25:59 -0800253 cd ../..
Chris Fallin20e94b22015-05-13 16:43:48 -0700254 cd conformance && make test_java && cd ..
255}
256
Chris Fallin20e94b22015-05-13 16:43:48 -0700257build_java_jdk7() {
258 use_java jdk7
Feng Xiao9e5fb552015-12-21 11:08:18 -0800259 build_java_with_conformance_tests
Chris Fallin20e94b22015-05-13 16:43:48 -0700260}
Elliotte Rusty Haroldbbc4f8d2022-04-18 16:47:56 +0000261
Chris Fallin20e94b22015-05-13 16:43:48 -0700262build_java_oracle7() {
263 use_java oracle7
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800264 build_java oracle7
Chris Fallin20e94b22015-05-13 16:43:48 -0700265}
Elliotte Rusty Haroldbbc4f8d2022-04-18 16:47:56 +0000266
267build_java_jdk8() {
268 use_java jdk8
269 build_java_with_conformance_tests
270}
271
David L. Jones5283ef42022-04-22 16:44:09 -0700272build_java_jdk11() {
273 use_java jdk11
Elliotte Rusty Harold868ab142022-04-28 11:09:39 +0000274 build_java
David L. Jones5283ef42022-04-22 16:44:09 -0700275}
276
Elliotte Rusty Haroldcc8ae4c2022-04-18 19:54:42 +0000277build_java_jdk17() {
278 use_java jdk17
Elliotte Rusty Harolde22db322022-04-28 19:10:12 +0000279 build_java
Elliotte Rusty Haroldcc8ae4c2022-04-18 19:54:42 +0000280}
281
Tomo Suzuki70517252019-06-26 15:28:49 -0400282build_java_linkage_monitor() {
Tomo Suzukibedef1e2019-07-01 17:03:04 -0400283 # Linkage Monitor checks compatibility with other Google libraries
284 # https://github.com/GoogleCloudPlatform/cloud-opensource-java/tree/master/linkage-monitor
285
Joshua Haberman301d3152022-02-08 18:31:50 -0800286 use_java jdk11
Tomo Suzukibedef1e2019-07-01 17:03:04 -0400287 internal_build_cpp
288
289 # Linkage Monitor uses $HOME/.m2 local repository
290 MVN="mvn -e -B -Dhttps.protocols=TLSv1.2"
291 cd java
Tomo Suzukibedef1e2019-07-01 17:03:04 -0400292 # Installs the snapshot version locally
293 $MVN install -Dmaven.test.skip=true
294
295 # Linkage Monitor uses the snapshot versions installed in $HOME/.m2 to verify compatibility
296 JAR=linkage-monitor-latest-all-deps.jar
297 curl -v -O "https://storage.googleapis.com/cloud-opensource-java-linkage-monitor/${JAR}"
298 # Fails if there's new linkage errors compared with baseline
299 java -jar $JAR com.google.cloud:libraries-bom
Tomo Suzuki70517252019-06-26 15:28:49 -0400300}
Chris Fallin20e94b22015-05-13 16:43:48 -0700301
Thomas Van Lenten9642b822015-06-10 17:21:23 -0400302build_objectivec_ios() {
Thomas Van Lenten368a2f42016-05-24 11:27:33 -0400303 # Reused the build script that takes care of configuring and ensuring things
304 # are up to date. The OS X test runs the objc conformance test, so skip it
305 # here.
Thomas Van Lenten368a2f42016-05-24 11:27:33 -0400306 objectivec/DevTools/full_mac_build.sh \
Thomas Van Lentenbd006712019-01-07 16:42:22 -0500307 --core-only --skip-xcode-osx --skip-xcode-tvos --skip-objc-conformance "$@"
Thomas Van Lenten368a2f42016-05-24 11:27:33 -0400308}
309
310build_objectivec_ios_debug() {
311 build_objectivec_ios --skip-xcode-release
312}
313
314build_objectivec_ios_release() {
315 build_objectivec_ios --skip-xcode-debug
Thomas Van Lenten9642b822015-06-10 17:21:23 -0400316}
317
318build_objectivec_osx() {
Thomas Van Lenten368a2f42016-05-24 11:27:33 -0400319 # Reused the build script that takes care of configuring and ensuring things
320 # are up to date.
321 objectivec/DevTools/full_mac_build.sh \
Thomas Van Lentenbd006712019-01-07 16:42:22 -0500322 --core-only --skip-xcode-ios --skip-xcode-tvos
323}
324
325build_objectivec_tvos() {
326 # Reused the build script that takes care of configuring and ensuring things
327 # are up to date. The OS X test runs the objc conformance test, so skip it
328 # here.
329 objectivec/DevTools/full_mac_build.sh \
330 --core-only --skip-xcode-ios --skip-xcode-osx --skip-objc-conformance "$@"
331}
332
333build_objectivec_tvos_debug() {
334 build_objectivec_tvos --skip-xcode-release
335}
336
337build_objectivec_tvos_release() {
338 build_objectivec_tvos --skip-xcode-debug
Thomas Van Lenten9642b822015-06-10 17:21:23 -0400339}
Dan O'Reilly5de2a812015-08-20 18:19:56 -0400340
Chris Fallin20e94b22015-05-13 16:43:48 -0700341build_python() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700342 internal_build_cpp
Chris Fallin20e94b22015-05-13 16:43:48 -0700343 cd python
Joshua Haberman301d3152022-02-08 18:31:50 -0800344 tox --skip-missing-interpreters
Chris Fallin20e94b22015-05-13 16:43:48 -0700345 cd ..
346}
347
Paul Yang4dec4f92018-12-18 18:07:24 -0800348build_python_version() {
349 internal_build_cpp
350 cd python
351 envlist=$1
Joshua Haberman301d3152022-02-08 18:31:50 -0800352 tox -e $envlist
Paul Yang4dec4f92018-12-18 18:07:24 -0800353 cd ..
354}
355
Paul Yang4dec4f92018-12-18 18:07:24 -0800356build_python37() {
357 build_python_version py37-python
358}
359
Jie Luo7faab5e2019-12-13 15:49:18 -0800360build_python38() {
361 build_python_version py38-python
362}
363
Bu Sun Kim51c80ce2020-12-04 21:16:47 +0000364build_python39() {
Bu Sun Kim523b1092020-12-15 17:08:56 -0700365 build_python_version py39-python
Bu Sun Kim51c80ce2020-12-04 21:16:47 +0000366}
367
Bu Sun Kimc01cd6e2021-10-15 11:24:49 -0600368build_python310() {
369 build_python_version py310-python
370}
371
Chris Fallin20e94b22015-05-13 16:43:48 -0700372build_python_cpp() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700373 internal_build_cpp
Bo Yangfd332d12016-09-30 00:07:47 +0000374 export LD_LIBRARY_PATH=../src/.libs # for Linux
375 export DYLD_LIBRARY_PATH=../src/.libs # for OS X
Chris Fallin20e94b22015-05-13 16:43:48 -0700376 cd python
Joshua Haberman301d3152022-02-08 18:31:50 -0800377 tox --skip-missing-interpreters
Chris Fallin20e94b22015-05-13 16:43:48 -0700378 cd ..
379}
380
Paul Yang4dec4f92018-12-18 18:07:24 -0800381build_python_cpp_version() {
382 internal_build_cpp
383 export LD_LIBRARY_PATH=../src/.libs # for Linux
384 export DYLD_LIBRARY_PATH=../src/.libs # for OS X
385 cd python
386 envlist=$1
387 tox -e $envlist
388 cd ..
389}
390
Paul Yang4dec4f92018-12-18 18:07:24 -0800391build_python37_cpp() {
392 build_python_cpp_version py37-cpp
393}
394
Jie Luo7faab5e2019-12-13 15:49:18 -0800395build_python38_cpp() {
396 build_python_cpp_version py38-cpp
397}
398
Bu Sun Kim51c80ce2020-12-04 21:16:47 +0000399build_python39_cpp() {
Bu Sun Kim523b1092020-12-15 17:08:56 -0700400 build_python_cpp_version py39-cpp
Bu Sun Kim51c80ce2020-12-04 21:16:47 +0000401}
402
Bu Sun Kimc01cd6e2021-10-15 11:24:49 -0600403build_python310_cpp() {
404 build_python_cpp_version py310-cpp
405}
406
Paul Yang78ba0212018-07-02 15:11:36 -0700407build_ruby23() {
408 internal_build_cpp # For conformance tests.
Paul Yang333b3ce2018-10-18 11:16:55 -0700409 cd ruby && bash travis-test.sh ruby-2.3.8 && cd ..
Paul Yang78ba0212018-07-02 15:11:36 -0700410}
411build_ruby24() {
412 internal_build_cpp # For conformance tests.
413 cd ruby && bash travis-test.sh ruby-2.4 && cd ..
414}
415build_ruby25() {
416 internal_build_cpp # For conformance tests.
Paul Yang333b3ce2018-10-18 11:16:55 -0700417 cd ruby && bash travis-test.sh ruby-2.5.1 && cd ..
Paul Yang78ba0212018-07-02 15:11:36 -0700418}
Paul Yangde9e1a02019-01-03 14:25:50 -0800419build_ruby26() {
420 internal_build_cpp # For conformance tests.
421 cd ruby && bash travis-test.sh ruby-2.6.0 && cd ..
Chris Fallin20e94b22015-05-13 16:43:48 -0700422}
Eric Walker2c8364b2020-04-17 13:20:38 -0400423build_ruby27() {
424 internal_build_cpp # For conformance tests.
425 cd ruby && bash travis-test.sh ruby-2.7.0 && cd ..
426}
Joshua Haberman9abf6e22021-01-13 12:16:25 -0800427build_ruby30() {
428 internal_build_cpp # For conformance tests.
Joshua Habermand339e172021-08-01 12:07:15 -0700429 cd ruby && bash travis-test.sh ruby-3.0.2 && cd ..
Joshua Haberman9abf6e22021-01-13 12:16:25 -0800430}
Marco Concetto Rudilossoabdfd092022-03-17 16:38:36 +0000431build_ruby31() {
432 internal_build_cpp # For conformance tests.
433 cd ruby && bash travis-test.sh ruby-3.1.0 && cd ..
434}
Chris Fallin20e94b22015-05-13 16:43:48 -0700435
Jason Lunn728878e2021-10-07 18:45:38 -0400436build_jruby92() {
Jason Lunnddd7f462021-10-06 13:06:27 -0400437 internal_build_cpp # For conformance tests.
438 internal_build_java jdk8 && cd .. # For Maven protobuf jar with local changes
Jason Lunndf099912022-02-25 14:11:12 +0000439 cd ruby && bash travis-test.sh jruby-9.2.20.1 && cd ..
Jason Lunn728878e2021-10-07 18:45:38 -0400440}
441
442build_jruby93() {
443 internal_build_cpp # For conformance tests.
444 internal_build_java jdk8 && cd .. # For Maven protobuf jar with local changes
Jason Lunn6b262772022-03-29 19:01:05 +0000445 cd ruby && bash travis-test.sh jruby-9.3.4.0 && cd ..
Rob Widmer24b20942020-09-16 11:00:29 -0400446}
447
Bo Yangc8bd36e2016-09-30 19:07:33 +0000448use_php() {
449 VERSION=$1
Paul Yangd7c44092018-12-18 10:57:03 -0800450 export PATH=/usr/local/php-${VERSION}/bin:$PATH
Joshua Habermanf1ce8662020-06-09 15:40:29 -0700451 internal_build_cpp
Bo Yangc8bd36e2016-09-30 19:07:33 +0000452}
453
Joshua Haberman8b870752021-05-04 10:19:22 -0700454build_php() {
455 use_php $1
Paul Yang525be942021-02-04 09:50:28 -0800456 pushd php
457 rm -rf vendor
Brett McBride4c03fcf2022-01-27 15:45:20 +1100458 php -v
459 php -m
Paul Yang525be942021-02-04 09:50:28 -0800460 composer update
461 composer test
462 popd
463 (cd conformance && make test_php)
464}
465
Joshua Haberman8b870752021-05-04 10:19:22 -0700466test_php_c() {
Paul Yange3e38b82016-12-08 14:39:20 -0800467 pushd php
Bo Yangfd332d12016-09-30 00:07:47 +0000468 rm -rf vendor
Brett McBride4c03fcf2022-01-27 15:45:20 +1100469 php -v
470 php -m
Paul Yangd7c44092018-12-18 10:57:03 -0800471 composer update
Joshua Haberman8b870752021-05-04 10:19:22 -0700472 composer test_c
Paul Yange3e38b82016-12-08 14:39:20 -0800473 popd
Joshua Haberman8b870752021-05-04 10:19:22 -0700474 (cd conformance && make test_php_c)
Bo Yangfd332d12016-09-30 00:07:47 +0000475}
476
Joshua Haberman8b870752021-05-04 10:19:22 -0700477build_php_c() {
478 use_php $1
479 test_php_c
Paul Yang190b5272017-04-19 16:23:51 -0700480}
481
482build_php7.0_mac() {
Joshua Habermanf1ce8662020-06-09 15:40:29 -0700483 internal_build_cpp
Paul Yang190b5272017-04-19 16:23:51 -0700484 # Install PHP
485 curl -s https://php-osx.liip.ch/install.sh | bash -s 7.0
Joshua Haberman27ba0c52020-05-13 15:36:21 -0700486 PHP_FOLDER=`find /usr/local -type d -name "php5-7.0*"` # The folder name may change upon time
487 test ! -z "$PHP_FOLDER"
Paul Yang190b5272017-04-19 16:23:51 -0700488 export PATH="$PHP_FOLDER/bin:$PATH"
489
Joshua Haberman8b870752021-05-04 10:19:22 -0700490 # Install Composer
491 wget https://getcomposer.org/download/2.0.13/composer.phar --progress=dot:mega -O /usr/local/bin/composer
492 chmod a+x /usr/local/bin/composer
493
Paul Yang190b5272017-04-19 16:23:51 -0700494 # Install valgrind
495 echo "#! /bin/bash" > valgrind
496 chmod ug+x valgrind
497 sudo mv valgrind /usr/local/bin/valgrind
498
499 # Test
Joshua Haberman8b870752021-05-04 10:19:22 -0700500 test_php_c
Bo Yang34cdaf42016-10-03 21:59:58 +0000501}
502
Joshua Haberman27ba0c52020-05-13 15:36:21 -0700503build_php7.3_mac() {
Joshua Habermanf1ce8662020-06-09 15:40:29 -0700504 internal_build_cpp
Paul Yang85219572020-01-30 12:45:47 -0800505 # Install PHP
Joshua Haberman27ba0c52020-05-13 15:36:21 -0700506 # We can't test PHP 7.4 with these binaries yet:
507 # https://github.com/liip/php-osx/issues/276
508 curl -s https://php-osx.liip.ch/install.sh | bash -s 7.3
509 PHP_FOLDER=`find /usr/local -type d -name "php5-7.3*"` # The folder name may change upon time
510 test ! -z "$PHP_FOLDER"
Paul Yang85219572020-01-30 12:45:47 -0800511 export PATH="$PHP_FOLDER/bin:$PATH"
512
Joshua Haberman8b870752021-05-04 10:19:22 -0700513 # Install Composer
514 wget https://getcomposer.org/download/2.0.13/composer.phar --progress=dot:mega -O /usr/local/bin/composer
515 chmod a+x /usr/local/bin/composer
516
Paul Yang85219572020-01-30 12:45:47 -0800517 # Install valgrind
518 echo "#! /bin/bash" > valgrind
519 chmod ug+x valgrind
520 sudo mv valgrind /usr/local/bin/valgrind
521
522 # Test
Joshua Haberman8b870752021-05-04 10:19:22 -0700523 test_php_c
Paul Yang85219572020-01-30 12:45:47 -0800524}
525
Paul Yang25abd7b2017-05-05 11:14:11 -0700526build_php_compatibility() {
527 internal_build_cpp
Paul Yang25abd7b2017-05-05 11:14:11 -0700528}
529
Paul Yangfe1790c2019-12-12 13:59:51 -0800530build_php_multirequest() {
531 use_php 7.4
Joshua Haberman2cc68ef2020-05-28 19:24:08 -0700532 php/tests/multirequest.sh
Paul Yangfe1790c2019-12-12 13:59:51 -0800533}
534
Paul Yangd4ca9292020-08-11 19:30:46 -0700535build_php8.0_all() {
Joshua Haberman8b870752021-05-04 10:19:22 -0700536 build_php 8.0
Brett McBride4c03fcf2022-01-27 15:45:20 +1100537 build_php 8.1
Joshua Haberman8b870752021-05-04 10:19:22 -0700538 build_php_c 8.0
Brett McBride4c03fcf2022-01-27 15:45:20 +1100539 build_php_c 8.1
Paul Yangd4ca9292020-08-11 19:30:46 -0700540}
541
Paul Yang25abd7b2017-05-05 11:14:11 -0700542build_php_all_32() {
Joshua Haberman8b870752021-05-04 10:19:22 -0700543 build_php 7.0
544 build_php 7.1
545 build_php 7.4
546 build_php_c 7.0
547 build_php_c 7.1
548 build_php_c 7.4
549 build_php_c 7.1-zts
550 build_php_c 7.2-zts
551 build_php_c 7.5-zts
Paul Yang51c5ff82016-10-25 17:27:05 -0700552}
553
Paul Yang25abd7b2017-05-05 11:14:11 -0700554build_php_all() {
Joshua Haberman8b870752021-05-04 10:19:22 -0700555 build_php_all_32
Paul Yangfe1790c2019-12-12 13:59:51 -0800556 build_php_multirequest
Paul Yang25abd7b2017-05-05 11:14:11 -0700557 build_php_compatibility
558}
559
Yilun Chong6adc3d72018-12-18 16:20:23 -0800560build_benchmark() {
Yilun Chong152c8302018-12-20 17:15:51 -0800561 use_php 7.2
Yilun Chong6adc3d72018-12-18 16:20:23 -0800562 cd kokoro/linux/benchmark && ./run.sh
563}
564
Josh Haberman738393b2016-02-18 20:10:23 -0800565# -------- main --------
566
Josh Haberman738393b2016-02-18 20:10:23 -0800567if [ "$#" -ne 1 ]; then
568 echo "
569Usage: $0 { cpp |
Feng Xiaoa4f68b12016-07-19 17:20:31 -0700570 cpp_distcheck |
Josh Haberman738393b2016-02-18 20:10:23 -0800571 csharp |
Josh Haberman738393b2016-02-18 20:10:23 -0800572 java_jdk7 |
573 java_oracle7 |
Elliotte Rusty Haroldbbc4f8d2022-04-18 16:47:56 +0000574 java_jdk8 |
Elliotte Rusty Harold19275202022-04-28 15:55:28 +0000575 java_jdk11 |
Elliotte Rusty Haroldcc8ae4c2022-04-18 19:54:42 +0000576 java_jdk17 |
Tomo Suzuki70517252019-06-26 15:28:49 -0400577 java_linkage_monitor |
Josh Haberman738393b2016-02-18 20:10:23 -0800578 objectivec_ios |
Thomas Van Lenten368a2f42016-05-24 11:27:33 -0400579 objectivec_ios_debug |
580 objectivec_ios_release |
Josh Haberman738393b2016-02-18 20:10:23 -0800581 objectivec_osx |
Thomas Van Lentenbd006712019-01-07 16:42:22 -0500582 objectivec_tvos |
583 objectivec_tvos_debug |
584 objectivec_tvos_release |
Josh Haberman738393b2016-02-18 20:10:23 -0800585 python |
586 python_cpp |
Jie Luoea511492017-01-23 15:11:00 -0800587 python_compatibility |
Paul Yang39df66e2018-10-12 12:36:33 -0700588 ruby23 |
589 ruby24 |
590 ruby25 |
Paul Yangde9e1a02019-01-03 14:25:50 -0800591 ruby26 |
Masaki Haraf494cb22020-04-25 01:50:27 +0900592 ruby27 |
Joshua Haberman9abf6e22021-01-13 12:16:25 -0800593 ruby30 |
Marco Concetto Rudilossoabdfd092022-03-17 16:38:36 +0000594 ruby31 |
Jason Lunn728878e2021-10-07 18:45:38 -0400595 jruby92 |
596 jruby93 |
Bo Yangfd332d12016-09-30 00:07:47 +0000597 ruby_all |
Yilun Chong6adc3d72018-12-18 16:20:23 -0800598 php_all |
Joshua Haberman8b870752021-05-04 10:19:22 -0700599 php_all_32 |
600 php7.0_mac |
601 php7.3_mac |
Hao Nguyenf85c8232019-03-07 14:34:28 -0800602 dist_install |
Elliotte Rusty Harold19275202022-04-28 15:55:28 +0000603 benchmark }
Josh Haberman738393b2016-02-18 20:10:23 -0800604"
605 exit 1
606fi
607
608set -e # exit immediately on error
609set -x # display all commands
Feng Xiao9de4e642018-07-13 16:55:32 -0700610cd $(dirname $0)
Josh Haberman738393b2016-02-18 20:10:23 -0800611eval "build_$1"