xref: /aosp_15_r20/external/abseil-cpp/ci/linux_gcc_alpine_cmake.sh (revision 9356374a3709195abf420251b3e825997ff56c0f)
1*9356374aSAndroid Build Coastguard Worker#!/bin/bash
2*9356374aSAndroid Build Coastguard Worker#
3*9356374aSAndroid Build Coastguard Worker# Copyright 2019 The Abseil Authors.
4*9356374aSAndroid Build Coastguard Worker#
5*9356374aSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License");
6*9356374aSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License.
7*9356374aSAndroid Build Coastguard Worker# You may obtain a copy of the License at
8*9356374aSAndroid Build Coastguard Worker#
9*9356374aSAndroid Build Coastguard Worker#    https://www.apache.org/licenses/LICENSE-2.0
10*9356374aSAndroid Build Coastguard Worker#
11*9356374aSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
12*9356374aSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS,
13*9356374aSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*9356374aSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and
15*9356374aSAndroid Build Coastguard Worker# limitations under the License.
16*9356374aSAndroid Build Coastguard Worker
17*9356374aSAndroid Build Coastguard Workerset -euox pipefail
18*9356374aSAndroid Build Coastguard Worker
19*9356374aSAndroid Build Coastguard Workerif [[ -z ${ABSEIL_ROOT:-} ]]; then
20*9356374aSAndroid Build Coastguard Worker  ABSEIL_ROOT="$(realpath $(dirname ${0})/..)"
21*9356374aSAndroid Build Coastguard Workerfi
22*9356374aSAndroid Build Coastguard Worker
23*9356374aSAndroid Build Coastguard Workersource "${ABSEIL_ROOT}/ci/cmake_common.sh"
24*9356374aSAndroid Build Coastguard Worker
25*9356374aSAndroid Build Coastguard Workerif [[ -z ${ABSL_CMAKE_CXX_STANDARDS:-} ]]; then
26*9356374aSAndroid Build Coastguard Worker  ABSL_CMAKE_CXX_STANDARDS="14 17"
27*9356374aSAndroid Build Coastguard Workerfi
28*9356374aSAndroid Build Coastguard Worker
29*9356374aSAndroid Build Coastguard Workerif [[ -z ${ABSL_CMAKE_BUILD_TYPES:-} ]]; then
30*9356374aSAndroid Build Coastguard Worker  ABSL_CMAKE_BUILD_TYPES="Debug Release"
31*9356374aSAndroid Build Coastguard Workerfi
32*9356374aSAndroid Build Coastguard Worker
33*9356374aSAndroid Build Coastguard Workerif [[ -z ${ABSL_CMAKE_BUILD_SHARED:-} ]]; then
34*9356374aSAndroid Build Coastguard Worker  ABSL_CMAKE_BUILD_SHARED="OFF ON"
35*9356374aSAndroid Build Coastguard Workerfi
36*9356374aSAndroid Build Coastguard Worker
37*9356374aSAndroid Build Coastguard Workerif [[ -z ${ABSL_CMAKE_BUILD_MONOLITHIC_SHARED_LIBS:-} ]]; then
38*9356374aSAndroid Build Coastguard Worker  ABSL_CMAKE_BUILD_MONOLITHIC_SHARED_LIBS="OFF ON"
39*9356374aSAndroid Build Coastguard Workerfi
40*9356374aSAndroid Build Coastguard Worker
41*9356374aSAndroid Build Coastguard Workersource "${ABSEIL_ROOT}/ci/linux_docker_containers.sh"
42*9356374aSAndroid Build Coastguard Workerreadonly DOCKER_CONTAINER=${LINUX_ALPINE_CONTAINER}
43*9356374aSAndroid Build Coastguard Worker
44*9356374aSAndroid Build Coastguard Workerfor std in ${ABSL_CMAKE_CXX_STANDARDS}; do
45*9356374aSAndroid Build Coastguard Worker  for compilation_mode in ${ABSL_CMAKE_BUILD_TYPES}; do
46*9356374aSAndroid Build Coastguard Worker    for build_shared in ${ABSL_CMAKE_BUILD_SHARED}; do
47*9356374aSAndroid Build Coastguard Worker      if [[ $build_shared == "OFF" ]]; then
48*9356374aSAndroid Build Coastguard Worker        monolithic_shared_options="OFF"
49*9356374aSAndroid Build Coastguard Worker      else
50*9356374aSAndroid Build Coastguard Worker        monolithic_shared_options="$ABSL_CMAKE_BUILD_MONOLITHIC_SHARED_LIBS"
51*9356374aSAndroid Build Coastguard Worker      fi
52*9356374aSAndroid Build Coastguard Worker
53*9356374aSAndroid Build Coastguard Worker      for monolithic_shared in $monolithic_shared_options; do
54*9356374aSAndroid Build Coastguard Worker        time docker run \
55*9356374aSAndroid Build Coastguard Worker          --mount type=bind,source="${ABSEIL_ROOT}",target=/abseil-cpp,readonly \
56*9356374aSAndroid Build Coastguard Worker          --tmpfs=/buildfs:exec \
57*9356374aSAndroid Build Coastguard Worker          --workdir=/buildfs \
58*9356374aSAndroid Build Coastguard Worker          --cap-add=SYS_PTRACE \
59*9356374aSAndroid Build Coastguard Worker          --rm \
60*9356374aSAndroid Build Coastguard Worker          -e CFLAGS="-Werror" \
61*9356374aSAndroid Build Coastguard Worker          -e CXXFLAGS="-Werror" \
62*9356374aSAndroid Build Coastguard Worker          ${DOCKER_EXTRA_ARGS:-} \
63*9356374aSAndroid Build Coastguard Worker          "${DOCKER_CONTAINER}" \
64*9356374aSAndroid Build Coastguard Worker          /bin/sh -c "
65*9356374aSAndroid Build Coastguard Worker            cmake /abseil-cpp \
66*9356374aSAndroid Build Coastguard Worker              -DABSL_GOOGLETEST_DOWNLOAD_URL=${ABSL_GOOGLETEST_DOWNLOAD_URL} \
67*9356374aSAndroid Build Coastguard Worker              -DBUILD_SHARED_LIBS=${build_shared} \
68*9356374aSAndroid Build Coastguard Worker              -DABSL_BUILD_TESTING=ON \
69*9356374aSAndroid Build Coastguard Worker              -DCMAKE_BUILD_TYPE=${compilation_mode} \
70*9356374aSAndroid Build Coastguard Worker              -DCMAKE_CXX_STANDARD=${std} \
71*9356374aSAndroid Build Coastguard Worker              -DABSL_BUILD_MONOLITHIC_SHARED_LIBS=${monolithic_shared} \
72*9356374aSAndroid Build Coastguard Worker              -DCMAKE_MODULE_LINKER_FLAGS=\"-Wl,--no-undefined\" && \
73*9356374aSAndroid Build Coastguard Worker            make -j$(nproc) && \
74*9356374aSAndroid Build Coastguard Worker            TZDIR=/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo \
75*9356374aSAndroid Build Coastguard Worker            ctest -j$(nproc) --output-on-failure"
76*9356374aSAndroid Build Coastguard Worker        done
77*9356374aSAndroid Build Coastguard Worker    done
78*9356374aSAndroid Build Coastguard Worker  done
79*9356374aSAndroid Build Coastguard Workerdone
80