blob: 7a5ee75e2b5e5af978c08c54cb31e2cbf53a1504 [file] [log] [blame]
Louis Dionnecb4e59e2019-01-09 16:35:55 +00001#!/usr/bin/env bash
2
3set -ue
4
5function usage() {
6 cat <<EOM
Louis Dionne53e9c2d2019-08-06 20:01:28 +00007$(basename ${0}) [-h|--help] --monorepo-root <MONOREPO-ROOT> --std <STD> --arch <ARCHITECTURE> [--lit-args <ARGS...>]
Louis Dionnecb4e59e2019-01-09 16:35:55 +00008
9This script is used to continually test libc++ and libc++abi trunk on MacOS.
10
Louis Dionne84422522019-08-06 15:28:34 +000011 --monorepo-root Full path to the root of the LLVM monorepo. Both libc++ and libc++abi from the monorepo are used.
Louis Dionnea3ec6272019-02-05 16:42:37 +000012 --std Version of the C++ Standard to run the tests under (c++03, c++11, etc..).
13 --arch Architecture to build the tests for (32, 64).
14 --libcxx-exceptions Whether to enable exceptions when building libc++ and running the libc++ tests. libc++abi is always built with support for exceptions because other libraries in the runtime depend on it (like libobjc). This must be ON or OFF.
Louis Dionne3b1ef582019-07-19 18:47:00 +000015 [--cmake-args] Additional arguments to pass to CMake (both the libc++ and the libc++abi configuration). If there are multiple arguments, quote them to paass them as a single argument to this script.
16 [--lit-args] Additional arguments to pass to lit. If there are multiple arguments, quote them to pass them as a single argument to this script.
Louis Dionnea3ec6272019-02-05 16:42:37 +000017 [--no-cleanup] Do not cleanup the temporary directory that was used for testing at the end. This can be useful to debug failures. Make sure to clean up manually after.
18 [-h, --help] Print this help.
Louis Dionnecb4e59e2019-01-09 16:35:55 +000019EOM
20}
21
22while [[ $# -gt 0 ]]; do
23 case "$1" in
Louis Dionne84422522019-08-06 15:28:34 +000024 --monorepo-root)
25 MONOREPO_ROOT="${2}"
26 if [[ ! -e "${MONOREPO_ROOT}" ]]; then
27 echo "--monorepo-root '${MONOREPO_ROOT}' is not a valid directory"
Louis Dionnecb4e59e2019-01-09 16:35:55 +000028 usage
29 exit 1
30 fi
31 shift; shift
32 ;;
33 --std)
34 STD="${2}"
35 shift; shift
36 ;;
37 --arch)
38 ARCH="${2}"
39 shift; shift
40 ;;
Louis Dionnea3ec6272019-02-05 16:42:37 +000041 --libcxx-exceptions)
42 LIBCXX_EXCEPTIONS="${2}"
43 shift; shift
44 ;;
Louis Dionne3b1ef582019-07-19 18:47:00 +000045 --cmake-args)
46 ADDITIONAL_CMAKE_ARGS="${2}"
47 shift; shift
48 ;;
Louis Dionnecb4e59e2019-01-09 16:35:55 +000049 --lit-args)
50 ADDITIONAL_LIT_ARGS="${2}"
51 shift; shift
52 ;;
53 --no-cleanup)
54 NO_CLEANUP=""
55 shift
56 ;;
57 -h|--help)
58 usage
59 exit 0
60 ;;
61 *)
62 echo "${1} is not a supported argument"
63 usage
64 exit 1
65 ;;
66 esac
67done
68
Louis Dionne84422522019-08-06 15:28:34 +000069if [[ -z ${MONOREPO_ROOT+x} ]]; then echo "--monorepo-root is a required parameter"; usage; exit 1; fi
Louis Dionnecb4e59e2019-01-09 16:35:55 +000070if [[ -z ${STD+x} ]]; then echo "--std is a required parameter"; usage; exit 1; fi
71if [[ -z ${ARCH+x} ]]; then echo "--arch is a required parameter"; usage; exit 1; fi
Louis Dionnea3ec6272019-02-05 16:42:37 +000072if [[ "${LIBCXX_EXCEPTIONS}" != "ON" && "${LIBCXX_EXCEPTIONS}" != "OFF" ]]; then echo "--libcxx-exceptions is a required parameter and must be either ON or OFF"; usage; exit 1; fi
Louis Dionne3b1ef582019-07-19 18:47:00 +000073if [[ -z ${ADDITIONAL_CMAKE_ARGS+x} ]]; then ADDITIONAL_CMAKE_ARGS=""; fi
Louis Dionnecb4e59e2019-01-09 16:35:55 +000074if [[ -z ${ADDITIONAL_LIT_ARGS+x} ]]; then ADDITIONAL_LIT_ARGS=""; fi
75
76
77TEMP_DIR="$(mktemp -d)"
78echo "Created temporary directory ${TEMP_DIR}"
79function cleanup {
80 if [[ -z ${NO_CLEANUP+x} ]]; then
81 echo "Removing temporary directory ${TEMP_DIR}"
82 rm -rf "${TEMP_DIR}"
83 else
84 echo "Temporary directory is at '${TEMP_DIR}', make sure to clean it up yourself"
85 fi
86}
87trap cleanup EXIT
88
89
Louis Dionne84422522019-08-06 15:28:34 +000090LLVM_BUILD_DIR="${TEMP_DIR}/llvm-build"
91LLVM_INSTALL_DIR="${TEMP_DIR}/llvm-install"
Louis Dionnecb4e59e2019-01-09 16:35:55 +000092
93echo "@@@ Setting up LIT flags @@@"
94LIT_FLAGS="-sv --param=std=${STD} ${ADDITIONAL_LIT_ARGS}"
95if [[ "${ARCH}" == "32" ]]; then
96 LIT_FLAGS+=" --param=enable_32bit=true"
97fi
98echo "@@@@@@"
99
100
Louis Dionne84422522019-08-06 15:28:34 +0000101echo "@@@ Configuring CMake @@@"
102mkdir -p "${LLVM_BUILD_DIR}"
103(cd "${LLVM_BUILD_DIR}" &&
Louis Dionne340b7252019-09-11 16:57:19 +0000104 xcrun cmake \
105 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake" \
106 -GNinja \
Louis Dionne84422522019-08-06 15:28:34 +0000107 -DCMAKE_INSTALL_PREFIX="${LLVM_INSTALL_DIR}" \
Louis Dionnea3ec6272019-02-05 16:42:37 +0000108 -DLIBCXX_ENABLE_EXCEPTIONS="${LIBCXX_EXCEPTIONS}" \
Louis Dionnea3ec6272019-02-05 16:42:37 +0000109 -DLIBCXXABI_ENABLE_EXCEPTIONS=ON \
Louis Dionne3b1ef582019-07-19 18:47:00 +0000110 ${ADDITIONAL_CMAKE_ARGS} \
Louis Dionnecb4e59e2019-01-09 16:35:55 +0000111 -DLLVM_LIT_ARGS="${LIT_FLAGS}" \
Louis Dionne84422522019-08-06 15:28:34 +0000112 -DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" \
Louis Dionne340b7252019-09-11 16:57:19 +0000113 -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" \
114 "${MONOREPO_ROOT}/llvm"
Louis Dionnecb4e59e2019-01-09 16:35:55 +0000115)
116echo "@@@@@@"
117
118
119echo "@@@ Building libc++.dylib and libc++abi.dylib from sources (just to make sure it works) @@@"
Louis Dionne84422522019-08-06 15:28:34 +0000120ninja -C "${LLVM_BUILD_DIR}" install-cxx install-cxxabi -v
Louis Dionnecb4e59e2019-01-09 16:35:55 +0000121echo "@@@@@@"
122
123
124echo "@@@ Running tests for libc++ @@@"
125# TODO: We should run check-cxx-abilist too
Louis Dionne84422522019-08-06 15:28:34 +0000126ninja -C "${LLVM_BUILD_DIR}" check-cxx
Louis Dionnecb4e59e2019-01-09 16:35:55 +0000127echo "@@@@@@"
128
129
130echo "@@@ Running tests for libc++abi @@@"
Louis Dionne84422522019-08-06 15:28:34 +0000131ninja -C "${LLVM_BUILD_DIR}" check-cxxabi
Louis Dionnecb4e59e2019-01-09 16:35:55 +0000132echo "@@@@@@"