xyzzyz | a5b3d51a | 2016-06-02 19:58:00 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 3 | # Build and runs tests for the protobuf project. We use this script to run |
| 4 | # tests on kokoro (Ubuntu and MacOS). It can run locally as well but you |
| 5 | # will need to make sure the required compilers/tools are available. |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 6 | |
| 7 | # For when some other test needs the C++ main build, including protoc and |
| 8 | # libprotobuf. |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 9 | LAST_RELEASED=3.9.0 |
| 10 | |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 11 | internal_build_cpp() { |
xyzzyz | a5b3d51a | 2016-06-02 19:58:00 | [diff] [blame] | 12 | if [ -f src/protoc ]; then |
| 13 | # Already built. |
| 14 | return |
| 15 | fi |
| 16 | |
Andres Medina | e684cf4 | 2018-08-27 18:48:23 | [diff] [blame] | 17 | # Initialize any submodules. |
| 18 | git submodule update --init --recursive |
| 19 | |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 20 | ./autogen.sh |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 21 | ./configure CXXFLAGS="-fPIC -std=c++11" # -fPIC is needed for python cpp test. |
| 22 | # See python/setup.py for more details |
| 23 | make -j$(nproc) |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | build_cpp() { |
| 27 | internal_build_cpp |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 28 | make check -j$(nproc) || (cat src/test-suite.log; false) |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 29 | cd conformance && make test_cpp && cd .. |
| 30 | } |
| 31 | |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 32 | build_cpp_tcmalloc() { |
| 33 | internal_build_cpp |
| 34 | ./configure LIBS=-ltcmalloc && make clean && make \ |
| 35 | PTHREAD_CFLAGS='-pthread -DGOOGLE_PROTOBUF_HEAP_CHECK_DRACONIAN' \ |
| 36 | check |
| 37 | cd src |
| 38 | PPROF_PATH=/usr/bin/google-pprof HEAPCHECK=strict ./protobuf-test |
| 39 | } |
| 40 | |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 41 | build_cpp_distcheck() { |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 42 | grep -q -- "-Og" src/Makefile.am && |
| 43 | echo "The -Og flag is incompatible with Clang versions older than 4.0." && |
| 44 | exit 1 |
| 45 | |
Andres Medina | e684cf4 | 2018-08-27 18:48:23 | [diff] [blame] | 46 | # Initialize any submodules. |
| 47 | git submodule update --init --recursive |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 48 | ./autogen.sh |
| 49 | ./configure |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 50 | make dist |
| 51 | |
| 52 | # List all files that should be included in the distribution package. |
Andres Medina | e684cf4 | 2018-08-27 18:48:23 | [diff] [blame] | 53 | git ls-files | grep "^\(java\|python\|objectivec\|csharp\|js\|ruby\|php\|cmake\|examples\|src/google/protobuf/.*\.proto\)" |\ |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 54 | grep -v ".gitignore" | grep -v "java/lite/proguard.pgcfg" |\ |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 55 | grep -v "python/compatibility_tests" | grep -v "python/docs" | grep -v "python/.repo-metadata.json" |\ |
| 56 | grep -v "python/protobuf_distutils" | grep -v "csharp/compatibility_tests" > dist.lst |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 57 | # Unzip the dist tar file. |
| 58 | DIST=`ls *.tar.gz` |
| 59 | tar -xf $DIST |
| 60 | cd ${DIST//.tar.gz} |
| 61 | # Check if every file exists in the dist tar file. |
| 62 | FILES_MISSING="" |
| 63 | for FILE in $(<../dist.lst); do |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 64 | [ -f "$FILE" ] || { |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 65 | echo "$FILE is not found!" |
| 66 | FILES_MISSING="$FILE $FILES_MISSING" |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 67 | } |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 68 | done |
| 69 | cd .. |
| 70 | if [ ! -z "$FILES_MISSING" ]; then |
| 71 | echo "Missing files in EXTRA_DIST: $FILES_MISSING" |
| 72 | exit 1 |
| 73 | fi |
| 74 | |
| 75 | # Do the regular dist-check for C++. |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 76 | make distcheck -j$(nproc) |
| 77 | } |
| 78 | |
| 79 | build_dist_install() { |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 80 | # Create a symlink pointing to python2 and put it at the beginning of $PATH. |
| 81 | # This is necessary because the googletest build system involves a Python |
| 82 | # script that is not compatible with Python 3. More recent googletest |
| 83 | # versions have fixed this, but they have also removed the autotools build |
| 84 | # system support that we rely on. This is a temporary workaround to keep the |
| 85 | # googletest build working when the default python binary is Python 3. |
| 86 | mkdir tmp || true |
| 87 | pushd tmp |
| 88 | ln -s /usr/bin/python2 ./python |
| 89 | popd |
| 90 | PATH=$PWD/tmp:$PATH |
| 91 | |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 92 | # Initialize any submodules. |
| 93 | git submodule update --init --recursive |
| 94 | ./autogen.sh |
| 95 | ./configure |
| 96 | make dist |
| 97 | |
| 98 | # Unzip the dist tar file and install it. |
| 99 | DIST=`ls *.tar.gz` |
| 100 | tar -xf $DIST |
| 101 | pushd ${DIST//.tar.gz} |
| 102 | ./configure && make check -j4 && make install |
| 103 | |
| 104 | export LD_LIBRARY_PATH=/usr/local/lib |
| 105 | |
| 106 | # Try to install Java |
| 107 | pushd java |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 108 | use_java jdk11 |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 109 | $MVN install |
| 110 | popd |
| 111 | |
| 112 | # Try to install Python |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 113 | python3 -m venv venv |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 114 | source venv/bin/activate |
| 115 | pushd python |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 116 | python3 setup.py clean build sdist |
| 117 | pip3 install dist/protobuf-*.tar.gz |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 118 | popd |
| 119 | deactivate |
| 120 | rm -rf python/venv |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | build_csharp() { |
Andres Medina | e684cf4 | 2018-08-27 18:48:23 | [diff] [blame] | 124 | # Required for conformance tests and to regenerate protos. |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 125 | internal_build_cpp |
xyzzyz | a5b3d51a | 2016-06-02 19:58:00 | [diff] [blame] | 126 | NUGET=/usr/local/bin/nuget.exe |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 127 | |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 128 | # Disable some unwanted dotnet options |
| 129 | export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true |
| 130 | export DOTNET_CLI_TELEMETRY_OPTOUT=true |
| 131 | |
| 132 | # TODO(jtattermusch): is this still needed with "first time experience" |
| 133 | # disabled? |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 134 | # Perform "dotnet new" once to get the setup preprocessing out of the |
| 135 | # way. That spews a lot of output (including backspaces) into logs |
| 136 | # otherwise, and can cause problems. It doesn't matter if this step |
| 137 | # is performed multiple times; it's cheap after the first time anyway. |
| 138 | # (It also doesn't matter if it's unnecessary, which it will be on some |
| 139 | # systems. It's necessary on Jenkins in order to avoid unprintable |
| 140 | # characters appearing in the JUnit output.) |
| 141 | mkdir dotnettmp |
| 142 | (cd dotnettmp; dotnet new > /dev/null) |
| 143 | rm -rf dotnettmp |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 144 | |
Andres Medina | e684cf4 | 2018-08-27 18:48:23 | [diff] [blame] | 145 | # Check that the protos haven't broken C# codegen. |
| 146 | # TODO(jonskeet): Fail if regenerating creates any changes. |
| 147 | csharp/generate_protos.sh |
| 148 | |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 149 | csharp/buildall.sh |
xyzzyz | a5b3d51a | 2016-06-02 19:58:00 | [diff] [blame] | 150 | cd conformance && make test_csharp && cd .. |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 151 | |
| 152 | # Run csharp compatibility test between 3.0.0 and the current version. |
| 153 | csharp/compatibility_tests/v3.0.0/test.sh 3.0.0 |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 154 | |
| 155 | # Run csharp compatibility test between last released and the current version. |
| 156 | csharp/compatibility_tests/v3.0.0/test.sh $LAST_RELEASED |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | build_golang() { |
| 160 | # Go build needs `protoc`. |
| 161 | internal_build_cpp |
| 162 | # Add protoc to the path so that the examples build finds it. |
| 163 | export PATH="`pwd`/src:$PATH" |
| 164 | |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 165 | export GOPATH="$HOME/gocode" |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 166 | mkdir -p "$GOPATH/src/github.com/protocolbuffers" |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 167 | mkdir -p "$GOPATH/src/github.com/golang" |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 168 | rm -f "$GOPATH/src/github.com/protocolbuffers/protobuf" |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 169 | rm -f "$GOPATH/src/github.com/golang/protobuf" |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 170 | ln -s "`pwd`" "$GOPATH/src/github.com/protocolbuffers/protobuf" |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 171 | export PATH="$GOPATH/bin:$PATH" |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 172 | (cd $GOPATH/src/github.com/golang && git clone https://github.com/golang/protobuf.git && cd protobuf && git checkout v1.3.5) |
| 173 | go install github.com/golang/protobuf/protoc-gen-go |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 174 | |
Andres Medina | e684cf4 | 2018-08-27 18:48:23 | [diff] [blame] | 175 | cd examples && PROTO_PATH="-I../src -I." make gotest && cd .. |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | use_java() { |
| 179 | version=$1 |
| 180 | case "$version" in |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 181 | jdk11) |
| 182 | export PATH=/usr/lib/jvm/java-11-openjdk-amd64/bin:$PATH |
| 183 | export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 |
| 184 | ;; |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 185 | jdk8) |
| 186 | export PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin:$PATH |
| 187 | export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 |
| 188 | ;; |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 189 | jdk7) |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 190 | export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 191 | export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 192 | ;; |
| 193 | oracle7) |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 194 | export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 195 | export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 196 | ;; |
| 197 | esac |
| 198 | |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 199 | MAVEN_LOCAL_REPOSITORY=/var/maven_local_repository |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 200 | MVN="$MVN -e --quiet -Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$MAVEN_LOCAL_REPOSITORY" |
xyzzyz | a5b3d51a | 2016-06-02 19:58:00 | [diff] [blame] | 201 | |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 202 | which java |
| 203 | java -version |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 204 | $MVN -version |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 205 | } |
| 206 | |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 207 | # --batch-mode suppresses download progress output that spams the logs. |
xyzzyz | a5b3d51a | 2016-06-02 19:58:00 | [diff] [blame] | 208 | MVN="mvn --batch-mode" |
| 209 | |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 210 | internal_build_java() { |
xyzzyz | a5b3d51a | 2016-06-02 19:58:00 | [diff] [blame] | 211 | version=$1 |
| 212 | dir=java_$version |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 213 | # Java build needs `protoc`. |
| 214 | internal_build_cpp |
xyzzyz | a5b3d51a | 2016-06-02 19:58:00 | [diff] [blame] | 215 | cp -r java $dir |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 216 | cd $dir && $MVN clean |
| 217 | # Skip tests here - callers will decide what tests they want to run |
| 218 | $MVN install -Dmaven.test.skip=true |
| 219 | } |
| 220 | |
| 221 | build_java() { |
| 222 | version=$1 |
| 223 | internal_build_java $version |
| 224 | # Skip the Kotlin tests on Oracle 7 |
| 225 | if [ "$version" == "oracle7" ]; then |
| 226 | $MVN test -pl bom,lite,core,util |
| 227 | else |
| 228 | $MVN test |
| 229 | fi |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 230 | cd ../.. |
| 231 | } |
| 232 | |
xyzzyz | a5b3d51a | 2016-06-02 19:58:00 | [diff] [blame] | 233 | # The conformance tests are hard-coded to work with the $ROOT/java directory. |
| 234 | # So this can't run in parallel with two different sets of tests. |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 235 | build_java_with_conformance_tests() { |
| 236 | # Java build needs `protoc`. |
| 237 | internal_build_cpp |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 238 | # This local installation avoids the problem caused by a new version not yet in Maven Central |
| 239 | cd java/bom && $MVN install |
| 240 | cd ../.. |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 241 | cd java/core && $MVN test && $MVN install |
| 242 | cd ../lite && $MVN test && $MVN install |
| 243 | cd ../util && $MVN test && $MVN install && $MVN package assembly:single |
| 244 | if [ "$version" == "jdk8" ]; then |
| 245 | cd ../kotlin && $MVN test && $MVN install |
| 246 | cd ../kotlin-lite && $MVN test && $MVN install |
| 247 | fi |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 248 | cd ../.. |
| 249 | cd conformance && make test_java && cd .. |
| 250 | } |
| 251 | |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 252 | build_java_jdk7() { |
| 253 | use_java jdk7 |
| 254 | build_java_with_conformance_tests |
| 255 | } |
| 256 | build_java_oracle7() { |
| 257 | use_java oracle7 |
xyzzyz | a5b3d51a | 2016-06-02 19:58:00 | [diff] [blame] | 258 | build_java oracle7 |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 259 | } |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 260 | build_java_linkage_monitor() { |
| 261 | # Linkage Monitor checks compatibility with other Google libraries |
| 262 | # https://github.com/GoogleCloudPlatform/cloud-opensource-java/tree/master/linkage-monitor |
| 263 | |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 264 | use_java jdk11 |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 265 | internal_build_cpp |
| 266 | |
| 267 | # Linkage Monitor uses $HOME/.m2 local repository |
| 268 | MVN="mvn -e -B -Dhttps.protocols=TLSv1.2" |
| 269 | cd java |
| 270 | # Installs the snapshot version locally |
| 271 | $MVN install -Dmaven.test.skip=true |
| 272 | |
| 273 | # Linkage Monitor uses the snapshot versions installed in $HOME/.m2 to verify compatibility |
| 274 | JAR=linkage-monitor-latest-all-deps.jar |
| 275 | curl -v -O "https://storage.googleapis.com/cloud-opensource-java-linkage-monitor/${JAR}" |
| 276 | # Fails if there's new linkage errors compared with baseline |
| 277 | java -jar $JAR com.google.cloud:libraries-bom |
Peter Kasting | 983299c94 | 2017-07-26 06:57:31 | [diff] [blame] | 278 | } |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 279 | |
Peter Kasting | 983299c94 | 2017-07-26 06:57:31 | [diff] [blame] | 280 | build_objectivec_ios() { |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 281 | # Reused the build script that takes care of configuring and ensuring things |
| 282 | # are up to date. The OS X test runs the objc conformance test, so skip it |
| 283 | # here. |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 284 | objectivec/DevTools/full_mac_build.sh \ |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 285 | --core-only --skip-xcode-osx --skip-xcode-tvos --skip-objc-conformance "$@" |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | build_objectivec_ios_debug() { |
| 289 | build_objectivec_ios --skip-xcode-release |
| 290 | } |
| 291 | |
| 292 | build_objectivec_ios_release() { |
| 293 | build_objectivec_ios --skip-xcode-debug |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | build_objectivec_osx() { |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 297 | # Reused the build script that takes care of configuring and ensuring things |
| 298 | # are up to date. |
| 299 | objectivec/DevTools/full_mac_build.sh \ |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 300 | --core-only --skip-xcode-ios --skip-xcode-tvos |
| 301 | } |
| 302 | |
| 303 | build_objectivec_tvos() { |
| 304 | # Reused the build script that takes care of configuring and ensuring things |
| 305 | # are up to date. The OS X test runs the objc conformance test, so skip it |
| 306 | # here. |
| 307 | objectivec/DevTools/full_mac_build.sh \ |
| 308 | --core-only --skip-xcode-ios --skip-xcode-osx --skip-objc-conformance "$@" |
| 309 | } |
| 310 | |
| 311 | build_objectivec_tvos_debug() { |
| 312 | build_objectivec_tvos --skip-xcode-release |
| 313 | } |
| 314 | |
| 315 | build_objectivec_tvos_release() { |
| 316 | build_objectivec_tvos --skip-xcode-debug |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | build_objectivec_cocoapods_integration() { |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 320 | objectivec/Tests/CocoaPods/run_tests.sh |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 321 | } |
| 322 | |
| 323 | build_python() { |
| 324 | internal_build_cpp |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 325 | cd python |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 326 | tox --skip-missing-interpreters |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 327 | cd .. |
| 328 | } |
| 329 | |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 330 | build_python_version() { |
| 331 | internal_build_cpp |
| 332 | cd python |
| 333 | envlist=$1 |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 334 | tox -e $envlist |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 335 | cd .. |
| 336 | } |
| 337 | |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 338 | build_python37() { |
| 339 | build_python_version py37-python |
| 340 | } |
| 341 | |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 342 | build_python38() { |
| 343 | build_python_version py38-python |
| 344 | } |
| 345 | |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 346 | build_python39() { |
| 347 | build_python_version py39-python |
| 348 | } |
| 349 | |
| 350 | build_python310() { |
| 351 | build_python_version py310-python |
| 352 | } |
| 353 | |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 354 | build_python_cpp() { |
| 355 | internal_build_cpp |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 356 | export LD_LIBRARY_PATH=../src/.libs # for Linux |
| 357 | export DYLD_LIBRARY_PATH=../src/.libs # for OS X |
| 358 | cd python |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 359 | tox --skip-missing-interpreters |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 360 | cd .. |
| 361 | } |
| 362 | |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 363 | build_python_cpp_version() { |
| 364 | internal_build_cpp |
| 365 | export LD_LIBRARY_PATH=../src/.libs # for Linux |
| 366 | export DYLD_LIBRARY_PATH=../src/.libs # for OS X |
| 367 | cd python |
| 368 | envlist=$1 |
| 369 | tox -e $envlist |
| 370 | cd .. |
| 371 | } |
| 372 | |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 373 | build_python37_cpp() { |
| 374 | build_python_cpp_version py37-cpp |
| 375 | } |
| 376 | |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 377 | build_python38_cpp() { |
| 378 | build_python_cpp_version py38-cpp |
| 379 | } |
| 380 | |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 381 | build_python39_cpp() { |
| 382 | build_python_cpp_version py39-cpp |
David Benjamin | f8d98ca | 2022-06-22 18:34:42 | [diff] [blame] | 383 | } |
| 384 | |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 385 | build_python310_cpp() { |
| 386 | build_python_cpp_version py310-cpp |
| 387 | } |
| 388 | |
| 389 | |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 390 | build_ruby23() { |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 391 | internal_build_cpp # For conformance tests. |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 392 | cd ruby && bash travis-test.sh ruby-2.3.8 && cd .. |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 393 | } |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 394 | build_ruby24() { |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 395 | internal_build_cpp # For conformance tests. |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 396 | cd ruby && bash travis-test.sh ruby-2.4 && cd .. |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 397 | } |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 398 | build_ruby25() { |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 399 | internal_build_cpp # For conformance tests. |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 400 | cd ruby && bash travis-test.sh ruby-2.5.1 && cd .. |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 401 | } |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 402 | build_ruby26() { |
| 403 | internal_build_cpp # For conformance tests. |
| 404 | cd ruby && bash travis-test.sh ruby-2.6.0 && cd .. |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 405 | } |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 406 | build_ruby27() { |
| 407 | internal_build_cpp # For conformance tests. |
| 408 | cd ruby && bash travis-test.sh ruby-2.7.0 && cd .. |
| 409 | } |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 410 | build_ruby30() { |
| 411 | internal_build_cpp # For conformance tests. |
| 412 | cd ruby && bash travis-test.sh ruby-3.0.2 && cd .. |
| 413 | } |
| 414 | build_ruby31() { |
| 415 | internal_build_cpp # For conformance tests. |
| 416 | cd ruby && bash travis-test.sh ruby-3.1.0 && cd .. |
| 417 | } |
| 418 | |
| 419 | build_jruby92() { |
| 420 | internal_build_cpp # For conformance tests. |
| 421 | internal_build_java jdk8 && cd .. # For Maven protobuf jar with local changes |
| 422 | cd ruby && bash travis-test.sh jruby-9.2.20.1 && cd .. |
| 423 | } |
| 424 | |
| 425 | build_jruby93() { |
| 426 | internal_build_cpp # For conformance tests. |
| 427 | internal_build_java jdk8 && cd .. # For Maven protobuf jar with local changes |
| 428 | cd ruby && bash travis-test.sh jruby-9.3.3.0 && cd .. |
| 429 | } |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 430 | |
| 431 | build_javascript() { |
| 432 | internal_build_cpp |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 433 | NODE_VERSION=node-v12.16.3-darwin-x64 |
| 434 | NODE_TGZ="$NODE_VERSION.tar.gz" |
| 435 | pushd /tmp |
| 436 | curl -OL https://nodejs.org/dist/v12.16.3/$NODE_TGZ |
| 437 | tar zxvf $NODE_TGZ |
| 438 | export PATH=$PATH:`pwd`/$NODE_VERSION/bin |
| 439 | popd |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 440 | cd js && npm install && npm test && cd .. |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 441 | cd conformance && make test_nodejs && cd .. |
| 442 | } |
| 443 | |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 444 | use_php() { |
| 445 | VERSION=$1 |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 446 | export PATH=/usr/local/php-${VERSION}/bin:$PATH |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 447 | internal_build_cpp |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 448 | } |
| 449 | |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 450 | build_php() { |
| 451 | use_php $1 |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 452 | pushd php |
| 453 | rm -rf vendor |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 454 | php -v |
| 455 | php -m |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 456 | composer update |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 457 | composer test |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 458 | popd |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 459 | (cd conformance && make test_php) |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 460 | } |
| 461 | |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 462 | test_php_c() { |
Findit | d8c5cddc | 2022-06-22 20:46:25 | [diff] [blame] | 463 | pushd php |
| 464 | rm -rf vendor |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 465 | php -v |
| 466 | php -m |
Findit | d8c5cddc | 2022-06-22 20:46:25 | [diff] [blame] | 467 | composer update |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 468 | composer test_c |
Findit | d8c5cddc | 2022-06-22 20:46:25 | [diff] [blame] | 469 | popd |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 470 | (cd conformance && make test_php_c) |
Findit | d8c5cddc | 2022-06-22 20:46:25 | [diff] [blame] | 471 | } |
| 472 | |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 473 | build_php_c() { |
| 474 | use_php $1 |
| 475 | test_php_c |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | build_php7.0_mac() { |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 479 | internal_build_cpp |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 480 | # Install PHP |
| 481 | curl -s https://php-osx.liip.ch/install.sh | bash -s 7.0 |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 482 | PHP_FOLDER=`find /usr/local -type d -name "php5-7.0*"` # The folder name may change upon time |
| 483 | test ! -z "$PHP_FOLDER" |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 484 | export PATH="$PHP_FOLDER/bin:$PATH" |
| 485 | |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 486 | # Install Composer |
| 487 | wget https://getcomposer.org/download/2.0.13/composer.phar --progress=dot:mega -O /usr/local/bin/composer |
| 488 | chmod a+x /usr/local/bin/composer |
| 489 | |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 490 | # Install valgrind |
| 491 | echo "#! /bin/bash" > valgrind |
| 492 | chmod ug+x valgrind |
| 493 | sudo mv valgrind /usr/local/bin/valgrind |
| 494 | |
| 495 | # Test |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 496 | test_php_c |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 497 | } |
| 498 | |
| 499 | build_php7.3_mac() { |
| 500 | internal_build_cpp |
| 501 | # Install PHP |
| 502 | # We can't test PHP 7.4 with these binaries yet: |
| 503 | # https://github.com/liip/php-osx/issues/276 |
| 504 | curl -s https://php-osx.liip.ch/install.sh | bash -s 7.3 |
| 505 | PHP_FOLDER=`find /usr/local -type d -name "php5-7.3*"` # The folder name may change upon time |
| 506 | test ! -z "$PHP_FOLDER" |
| 507 | export PATH="$PHP_FOLDER/bin:$PATH" |
| 508 | |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 509 | # Install Composer |
| 510 | wget https://getcomposer.org/download/2.0.13/composer.phar --progress=dot:mega -O /usr/local/bin/composer |
| 511 | chmod a+x /usr/local/bin/composer |
| 512 | |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 513 | # Install valgrind |
| 514 | echo "#! /bin/bash" > valgrind |
| 515 | chmod ug+x valgrind |
| 516 | sudo mv valgrind /usr/local/bin/valgrind |
| 517 | |
| 518 | # Test |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 519 | test_php_c |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 520 | } |
| 521 | |
| 522 | build_php_compatibility() { |
| 523 | internal_build_cpp |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 524 | php/tests/compatibility_test.sh $LAST_RELEASED |
| 525 | } |
| 526 | |
| 527 | build_php_multirequest() { |
| 528 | use_php 7.4 |
| 529 | php/tests/multirequest.sh |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 530 | } |
| 531 | |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 532 | build_php8.0_all() { |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 533 | build_php 8.0 |
| 534 | build_php 8.1 |
| 535 | build_php_c 8.0 |
| 536 | build_php_c 8.1 |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 537 | } |
| 538 | |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 539 | build_php_all_32() { |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 540 | build_php 7.0 |
| 541 | build_php 7.1 |
| 542 | build_php 7.4 |
| 543 | build_php_c 7.0 |
| 544 | build_php_c 7.1 |
| 545 | build_php_c 7.4 |
| 546 | build_php_c 7.1-zts |
| 547 | build_php_c 7.2-zts |
| 548 | build_php_c 7.5-zts |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | build_php_all() { |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 552 | build_php_all_32 |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 553 | build_php_multirequest |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 554 | build_php_compatibility |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 555 | } |
| 556 | |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 557 | build_benchmark() { |
| 558 | use_php 7.2 |
| 559 | cd kokoro/linux/benchmark && ./run.sh |
| 560 | } |
xyzzyz | a5b3d51a | 2016-06-02 19:58:00 | [diff] [blame] | 561 | |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 562 | # -------- main -------- |
| 563 | |
| 564 | if [ "$#" -ne 1 ]; then |
| 565 | echo " |
| 566 | Usage: $0 { cpp | |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 567 | cpp_distcheck | |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 568 | csharp | |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 569 | java_jdk7 | |
| 570 | java_oracle7 | |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 571 | java_linkage_monitor | |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 572 | objectivec_ios | |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 573 | objectivec_ios_debug | |
| 574 | objectivec_ios_release | |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 575 | objectivec_osx | |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 576 | objectivec_tvos | |
| 577 | objectivec_tvos_debug | |
| 578 | objectivec_tvos_release | |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 579 | objectivec_cocoapods_integration | |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 580 | python | |
| 581 | python_cpp | |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 582 | python_compatibility | |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 583 | ruby23 | |
| 584 | ruby24 | |
| 585 | ruby25 | |
| 586 | ruby26 | |
Andres Medina | f348ad3 | 2020-11-18 16:55:36 | [diff] [blame] | 587 | ruby27 | |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 588 | ruby30 | |
| 589 | ruby31 | |
| 590 | jruby92 | |
| 591 | jruby93 | |
Tom Anderson | ac47edd | 2017-07-27 17:23:14 | [diff] [blame] | 592 | ruby_all | |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 593 | php_all | |
Tommy Nyquist | 29527fb | 2022-06-29 19:29:44 | [diff] [blame] | 594 | php_all_32 | |
| 595 | php7.0_mac | |
| 596 | php7.3_mac | |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 597 | dist_install | |
| 598 | benchmark) |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 599 | " |
| 600 | exit 1 |
| 601 | fi |
| 602 | |
| 603 | set -e # exit immediately on error |
| 604 | set -x # display all commands |
Mohamed Heikal | e10d989 | 2019-08-20 18:56:20 | [diff] [blame] | 605 | cd $(dirname $0) |
xyzzyz | 7cf8148f | 2016-04-20 23:50:23 | [diff] [blame] | 606 | eval "build_$1" |