blob: ba65853f7f10a0fa8bb380fb6030eefd59522828 [file] [log] [blame]
Abseil Team74d91752019-07-03 12:13:04 -07001#!/bin/bash
2#
3# Copyright 2019 The Abseil Authors.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# https://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
Abseil Team74d91752019-07-03 12:13:04 -070017set -euox pipefail
18
Abseil Teamd43b7992020-04-03 13:24:29 -070019if [[ -z ${ABSEIL_ROOT:-} ]]; then
Abseil Team74d91752019-07-03 12:13:04 -070020 ABSEIL_ROOT="$(realpath $(dirname ${0})/..)"
21fi
22
Abseil Teameb317a72020-10-21 00:01:29 -070023source "${ABSEIL_ROOT}/ci/cmake_common.sh"
24
Abseil Teamd43b7992020-04-03 13:24:29 -070025if [[ -z ${ABSL_CMAKE_CXX_STANDARDS:-} ]]; then
Derek Mauro4bbdb022022-07-05 09:37:54 -070026 ABSL_CMAKE_CXX_STANDARDS="14 17 20"
Abseil Team74d91752019-07-03 12:13:04 -070027fi
28
Abseil Teamd43b7992020-04-03 13:24:29 -070029if [[ -z ${ABSL_CMAKE_BUILD_TYPES:-} ]]; then
Abseil Team74d91752019-07-03 12:13:04 -070030 ABSL_CMAKE_BUILD_TYPES="Debug Release"
31fi
32
Abseil Team8f1c34a2020-10-16 18:59:21 -070033if [[ -z ${ABSL_CMAKE_BUILD_SHARED:-} ]]; then
34 ABSL_CMAKE_BUILD_SHARED="OFF ON"
35fi
36
Abseil Team092ed972020-03-20 09:47:42 -070037source "${ABSEIL_ROOT}/ci/linux_docker_containers.sh"
38readonly DOCKER_CONTAINER=${LINUX_GCC_LATEST_CONTAINER}
39
Abseil Team74d91752019-07-03 12:13:04 -070040for std in ${ABSL_CMAKE_CXX_STANDARDS}; do
41 for compilation_mode in ${ABSL_CMAKE_BUILD_TYPES}; do
Abseil Team8f1c34a2020-10-16 18:59:21 -070042 for build_shared in ${ABSL_CMAKE_BUILD_SHARED}; do
43 time docker run \
Abseil Team4b915e72020-10-19 15:25:26 -070044 --mount type=bind,source="${ABSEIL_ROOT}",target=/abseil-cpp,readonly \
Abseil Team8f1c34a2020-10-16 18:59:21 -070045 --tmpfs=/buildfs:exec \
Abseil Teameb317a72020-10-21 00:01:29 -070046 --workdir=/buildfs \
Abseil Team8f1c34a2020-10-16 18:59:21 -070047 --cap-add=SYS_PTRACE \
48 --rm \
49 -e CFLAGS="-Werror" \
50 -e CXXFLAGS="-Werror" \
Abseil Teameb317a72020-10-21 00:01:29 -070051 ${DOCKER_EXTRA_ARGS:-} \
52 "${DOCKER_CONTAINER}" \
Abseil Team8f1c34a2020-10-16 18:59:21 -070053 /bin/bash -c "
Abseil Team8f1c34a2020-10-16 18:59:21 -070054 cmake /abseil-cpp \
Abseil Teameb317a72020-10-21 00:01:29 -070055 -DABSL_GOOGLETEST_DOWNLOAD_URL=${ABSL_GOOGLETEST_DOWNLOAD_URL} \
Abseil Team8f1c34a2020-10-16 18:59:21 -070056 -DBUILD_SHARED_LIBS=${build_shared} \
Matt Armstrongfb7dd242021-12-10 10:50:53 -080057 -DABSL_BUILD_TESTING=ON \
Abseil Team8f1c34a2020-10-16 18:59:21 -070058 -DCMAKE_BUILD_TYPE=${compilation_mode} \
59 -DCMAKE_CXX_STANDARD=${std} \
60 -DCMAKE_MODULE_LINKER_FLAGS=\"-Wl,--no-undefined\" && \
61 make -j$(nproc) && \
62 ctest -j$(nproc) --output-on-failure"
63 done
Abseil Team74d91752019-07-03 12:13:04 -070064 done
65done