2019-05-23 01:57:00 +03:00
|
|
|
#!/usr/bin/env bash
|
2021-01-16 09:03:39 +03:00
|
|
|
ARCH="x86_64"
|
2020-05-06 21:58:41 +03:00
|
|
|
if [ "$1" == "ios" ]; then
|
|
|
|
IOS_BUILD="YES"
|
|
|
|
# Skip building tests on iOS as there is no way to run them
|
|
|
|
BUILD_TESTS="OFF"
|
|
|
|
else
|
|
|
|
IOS_BUILD="NO"
|
2021-01-16 09:03:39 +03:00
|
|
|
if [ "$1" == "arm64" ]; then
|
|
|
|
ARCH="arm64"
|
|
|
|
BUILD_TESTS="OFF"
|
|
|
|
else
|
|
|
|
BUILD_TESTS="ON"
|
|
|
|
fi
|
2020-05-06 21:58:41 +03:00
|
|
|
fi
|
|
|
|
|
2019-06-20 00:34:04 +03:00
|
|
|
cd `dirname $0`
|
2020-05-02 21:46:33 +03:00
|
|
|
|
2020-09-22 11:16:29 +03:00
|
|
|
GTEST_PATH=googletest
|
2022-02-20 01:34:22 +03:00
|
|
|
USE_LATEST_GTEST="false"
|
2020-09-22 11:16:29 +03:00
|
|
|
|
2022-02-20 01:34:22 +03:00
|
|
|
echo "Not an ios build. Check for newer googletest requirement"
|
|
|
|
OS_NAME=`uname -s`
|
|
|
|
|
|
|
|
#TODO: switch all OS builds to Google Test located in third_party/googletest submodule
|
|
|
|
if [[ ${IOS_BUILD} == "NO" ]]; then
|
|
|
|
case "$OS_NAME" in
|
|
|
|
Darwin)
|
|
|
|
mac_os_ver=$(sw_vers -productVersion)
|
|
|
|
IFS='.' read -r -a mac_ver_first_octet <<< "$mac_os_ver"
|
|
|
|
# Use new Google Test on macOS 11.0 or higher ; old one no longer compiles on 11.0
|
|
|
|
if [[ "$mac_ver_first_octet" -ge 11 ]] ; then
|
|
|
|
echo "running on Mac OS 11.0 or higher"
|
|
|
|
USE_LATEST_GTEST="true"
|
|
|
|
else
|
|
|
|
echo "running older MacOS $mac_os_ver"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
Linux)
|
2020-05-02 21:46:33 +03:00
|
|
|
source /etc/os-release
|
2022-02-20 01:34:22 +03:00
|
|
|
echo $VERSION_ID
|
2020-05-02 21:46:33 +03:00
|
|
|
# Use new Google Test on latest Ubuntu 20.04 : old one no longer compiles on 20
|
|
|
|
if [ "$VERSION_ID" == "20.04" ]; then
|
2022-02-20 01:34:22 +03:00
|
|
|
echo "Running on Ubuntu 20.04"
|
|
|
|
USE_LATEST_GTEST="true"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$USE_LATEST_GTEST" == "true" ]; then
|
|
|
|
echo "Using latest googletest"
|
|
|
|
GTEST_PATH=third_party/googletest
|
|
|
|
if [ ! "$(ls -A $GTEST_PATH/CMakeLists.txt)" ]; then
|
|
|
|
echo Clone googletest from google/googletest:master ...
|
|
|
|
rm -rf ${GTEST_PATH} #delete just if empty directory exists
|
|
|
|
git clone https://github.com/google/googletest $GTEST_PATH
|
|
|
|
else
|
|
|
|
echo "Using existing googletest from thirdparty/"
|
2020-05-02 21:46:33 +03:00
|
|
|
fi
|
2022-02-20 01:34:22 +03:00
|
|
|
else
|
|
|
|
echo "Using existing(older) googletest from repo root"
|
2020-05-02 21:46:33 +03:00
|
|
|
fi
|
|
|
|
|
2020-09-22 11:16:29 +03:00
|
|
|
pushd $GTEST_PATH
|
2019-02-01 12:08:09 +03:00
|
|
|
set -evx
|
|
|
|
env | sort
|
2019-06-20 00:34:04 +03:00
|
|
|
rm -rf build
|
2019-05-23 01:57:00 +03:00
|
|
|
mkdir -p build || true
|
2019-02-01 12:08:09 +03:00
|
|
|
cd build
|
2020-05-03 00:31:54 +03:00
|
|
|
cmake -Dgtest_build_samples=OFF \
|
|
|
|
-Dgmock_build_samples=OFF \
|
2020-10-29 00:29:29 +03:00
|
|
|
-Dgtest_build_tests=OFF \
|
|
|
|
-Dgmock_build_tests=OFF \
|
2019-05-23 01:57:00 +03:00
|
|
|
-DCMAKE_CXX_FLAGS="-fPIC $CXX_FLAGS" \
|
2020-05-06 21:58:41 +03:00
|
|
|
-DBUILD_IOS=$IOS_BUILD \
|
2021-01-16 09:03:39 +03:00
|
|
|
-DARCH=$ARCH \
|
2019-02-01 12:08:09 +03:00
|
|
|
..
|
|
|
|
make
|
2020-09-22 11:16:29 +03:00
|
|
|
popd
|
2020-05-02 21:46:33 +03:00
|
|
|
# CTEST_OUTPUT_ON_FAILURE=1 make test
|
|
|
|
# make install
|