1#!/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 17set -euox pipefail 18 19if [[ -z ${ABSEIL_ROOT:-} ]]; then 20 ABSEIL_ROOT="$(realpath $(dirname ${0})/..)" 21fi 22 23source "${ABSEIL_ROOT}/ci/cmake_common.sh" 24 25if [[ -z ${ABSL_CMAKE_CXX_STANDARDS:-} ]]; then 26 ABSL_CMAKE_CXX_STANDARDS="14 17" 27fi 28 29if [[ -z ${ABSL_CMAKE_BUILD_TYPES:-} ]]; then 30 ABSL_CMAKE_BUILD_TYPES="Debug Release" 31fi 32 33if [[ -z ${ABSL_CMAKE_BUILD_SHARED:-} ]]; then 34 ABSL_CMAKE_BUILD_SHARED="OFF ON" 35fi 36 37if [[ -z ${ABSL_CMAKE_BUILD_MONOLITHIC_SHARED_LIBS:-} ]]; then 38 ABSL_CMAKE_BUILD_MONOLITHIC_SHARED_LIBS="OFF ON" 39fi 40 41source "${ABSEIL_ROOT}/ci/linux_docker_containers.sh" 42readonly DOCKER_CONTAINER=${LINUX_ALPINE_CONTAINER} 43 44for std in ${ABSL_CMAKE_CXX_STANDARDS}; do 45 for compilation_mode in ${ABSL_CMAKE_BUILD_TYPES}; do 46 for build_shared in ${ABSL_CMAKE_BUILD_SHARED}; do 47 if [[ $build_shared == "OFF" ]]; then 48 monolithic_shared_options="OFF" 49 else 50 monolithic_shared_options="$ABSL_CMAKE_BUILD_MONOLITHIC_SHARED_LIBS" 51 fi 52 53 for monolithic_shared in $monolithic_shared_options; do 54 time docker run \ 55 --mount type=bind,source="${ABSEIL_ROOT}",target=/abseil-cpp,readonly \ 56 --tmpfs=/buildfs:exec \ 57 --workdir=/buildfs \ 58 --cap-add=SYS_PTRACE \ 59 --rm \ 60 -e CFLAGS="-Werror" \ 61 -e CXXFLAGS="-Werror" \ 62 ${DOCKER_EXTRA_ARGS:-} \ 63 "${DOCKER_CONTAINER}" \ 64 /bin/sh -c " 65 cmake /abseil-cpp \ 66 -DABSL_GOOGLETEST_DOWNLOAD_URL=${ABSL_GOOGLETEST_DOWNLOAD_URL} \ 67 -DBUILD_SHARED_LIBS=${build_shared} \ 68 -DABSL_BUILD_TESTING=ON \ 69 -DCMAKE_BUILD_TYPE=${compilation_mode} \ 70 -DCMAKE_CXX_STANDARD=${std} \ 71 -DABSL_BUILD_MONOLITHIC_SHARED_LIBS=${monolithic_shared} \ 72 -DCMAKE_MODULE_LINKER_FLAGS=\"-Wl,--no-undefined\" && \ 73 make -j$(nproc) && \ 74 TZDIR=/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo \ 75 ctest -j$(nproc) --output-on-failure" 76 done 77 done 78 done 79done 80