blob: bce27d295f29430d03304be6ed7db5133e0465f3 [file] [log] [blame]
Abseil Teame4c8d0e2019-10-18 09:06:29 -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 Teame4c8d0e2019-10-18 09:06:29 -070017set -euox pipefail
18
Abseil Teamd43b7992020-04-03 13:24:29 -070019if [[ -z ${ABSEIL_ROOT:-} ]]; then
Abseil Teame4c8d0e2019-10-18 09:06:29 -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
Abseil Teame4c8d0e2019-10-18 09:06:29 -070026 ABSL_CMAKE_CXX_STANDARDS="11 14 17"
27fi
28
Abseil Teamd43b7992020-04-03 13:24:29 -070029if [[ -z ${ABSL_CMAKE_BUILD_TYPES:-} ]]; then
Abseil Teame4c8d0e2019-10-18 09:06:29 -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_ALPINE_CONTAINER}
Abseil Teame4c8d0e2019-10-18 09:06:29 -070039
40for 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:-} \
Abseil Team8f1c34a2020-10-16 18:59:21 -070052 "${DOCKER_CONTAINER}" \
53 /bin/sh -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 Teama50ae362021-02-22 13:18:10 -080056 -DBUILD_TESTING=ON \
Abseil Team8f1c34a2020-10-16 18:59:21 -070057 -DCMAKE_BUILD_TYPE=${compilation_mode} \
58 -DCMAKE_CXX_STANDARD=${std} \
59 -DCMAKE_MODULE_LINKER_FLAGS=\"-Wl,--no-undefined\" && \
60 make -j$(nproc) && \
61 ctest -j$(nproc) --output-on-failure"
62 done
Abseil Teame4c8d0e2019-10-18 09:06:29 -070063 done
64done