1f92157deSopenharmony_ci#!/bin/bash 2f92157deSopenharmony_ci# 3f92157deSopenharmony_ci# Copyright 2020, Google Inc. 4f92157deSopenharmony_ci# All rights reserved. 5f92157deSopenharmony_ci# 6f92157deSopenharmony_ci# Redistribution and use in source and binary forms, with or without 7f92157deSopenharmony_ci# modification, are permitted provided that the following conditions are 8f92157deSopenharmony_ci# met: 9f92157deSopenharmony_ci# 10f92157deSopenharmony_ci# * Redistributions of source code must retain the above copyright 11f92157deSopenharmony_ci# notice, this list of conditions and the following disclaimer. 12f92157deSopenharmony_ci# * Redistributions in binary form must reproduce the above 13f92157deSopenharmony_ci# copyright notice, this list of conditions and the following disclaimer 14f92157deSopenharmony_ci# in the documentation and/or other materials provided with the 15f92157deSopenharmony_ci# distribution. 16f92157deSopenharmony_ci# * Neither the name of Google Inc. nor the names of its 17f92157deSopenharmony_ci# contributors may be used to endorse or promote products derived from 18f92157deSopenharmony_ci# this software without specific prior written permission. 19f92157deSopenharmony_ci# 20f92157deSopenharmony_ci# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21f92157deSopenharmony_ci# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22f92157deSopenharmony_ci# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23f92157deSopenharmony_ci# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24f92157deSopenharmony_ci# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25f92157deSopenharmony_ci# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26f92157deSopenharmony_ci# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27f92157deSopenharmony_ci# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28f92157deSopenharmony_ci# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29f92157deSopenharmony_ci# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30f92157deSopenharmony_ci# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31f92157deSopenharmony_ci 32f92157deSopenharmony_ciset -euox pipefail 33f92157deSopenharmony_ci 34f92157deSopenharmony_ciif [[ -z ${GTEST_ROOT:-} ]]; then 35f92157deSopenharmony_ci GTEST_ROOT="$(realpath $(dirname ${0})/..)" 36f92157deSopenharmony_cifi 37f92157deSopenharmony_ci 38f92157deSopenharmony_ci# Test the CMake build 39f92157deSopenharmony_cifor cmake_off_on in OFF ON; do 40f92157deSopenharmony_ci BUILD_DIR=$(mktemp -d build_dir.XXXXXXXX) 41f92157deSopenharmony_ci cd ${BUILD_DIR} 42f92157deSopenharmony_ci time cmake ${GTEST_ROOT} \ 43f92157deSopenharmony_ci -DCMAKE_CXX_STANDARD=14 \ 44f92157deSopenharmony_ci -Dgtest_build_samples=ON \ 45f92157deSopenharmony_ci -Dgtest_build_tests=ON \ 46f92157deSopenharmony_ci -Dgmock_build_tests=ON \ 47f92157deSopenharmony_ci -Dcxx_no_exception=${cmake_off_on} \ 48f92157deSopenharmony_ci -Dcxx_no_rtti=${cmake_off_on} 49f92157deSopenharmony_ci time make 50f92157deSopenharmony_ci time ctest -j$(nproc) --output-on-failure 51f92157deSopenharmony_cidone 52f92157deSopenharmony_ci 53f92157deSopenharmony_ci# Test the Bazel build 54f92157deSopenharmony_ci 55f92157deSopenharmony_ci# If we are running on Kokoro, check for a versioned Bazel binary. 56f92157deSopenharmony_ciKOKORO_GFILE_BAZEL_BIN="bazel-5.1.1-darwin-x86_64" 57f92157deSopenharmony_ciif [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -f ${KOKORO_GFILE_DIR}/${KOKORO_GFILE_BAZEL_BIN} ]]; then 58f92157deSopenharmony_ci BAZEL_BIN="${KOKORO_GFILE_DIR}/${KOKORO_GFILE_BAZEL_BIN}" 59f92157deSopenharmony_ci chmod +x ${BAZEL_BIN} 60f92157deSopenharmony_cielse 61f92157deSopenharmony_ci BAZEL_BIN="bazel" 62f92157deSopenharmony_cifi 63f92157deSopenharmony_ci 64f92157deSopenharmony_cicd ${GTEST_ROOT} 65f92157deSopenharmony_cifor absl in 0 1; do 66f92157deSopenharmony_ci ${BAZEL_BIN} test ... \ 67f92157deSopenharmony_ci --copt="-Wall" \ 68f92157deSopenharmony_ci --copt="-Werror" \ 69f92157deSopenharmony_ci --cxxopt="-std=c++14" \ 70f92157deSopenharmony_ci --define="absl=${absl}" \ 71f92157deSopenharmony_ci --features=external_include_paths \ 72f92157deSopenharmony_ci --keep_going \ 73f92157deSopenharmony_ci --show_timestamps \ 74f92157deSopenharmony_ci --test_output=errors 75f92157deSopenharmony_cidone 76