blob: 843d23c1d00c3ee652e91257c75988aea70e6cee [file] [log] [blame]
Louis Dionne62248ac2019-01-09 16:35:55 +00001#!/usr/bin/env bash
2
3set -ue
4
5function usage() {
6 cat <<EOM
Louis Dionne74953e12020-04-30 12:55:01 -04007$(basename ${0}) [-h|--help] --monorepo-root <MONOREPO-ROOT> --std <STD> --libcxx-exceptions <ON|OFF> [--lit-args <ARGS...>]
Louis Dionne62248ac2019-01-09 16:35:55 +00008
9This script is used to continually test libc++ and libc++abi trunk on MacOS.
10
Louis Dionne9bb01b22019-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 Dionned8a646c2019-02-05 16:42:37 +000012 --std Version of the C++ Standard to run the tests under (c++03, c++11, etc..).
Louis Dionned8a646c2019-02-05 16:42:37 +000013 --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 Dionneed0a75e2019-07-19 18:47:00 +000014 [--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.
15 [--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 Dionned8a646c2019-02-05 16:42:37 +000016 [--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.
17 [-h, --help] Print this help.
Louis Dionne62248ac2019-01-09 16:35:55 +000018EOM
19}
20
21while [[ $# -gt 0 ]]; do
22 case "$1" in
Louis Dionne9bb01b22019-08-06 15:28:34 +000023 --monorepo-root)
24 MONOREPO_ROOT="${2}"
25 if [[ ! -e "${MONOREPO_ROOT}" ]]; then
26 echo "--monorepo-root '${MONOREPO_ROOT}' is not a valid directory"
Louis Dionne62248ac2019-01-09 16:35:55 +000027 usage
28 exit 1
29 fi
30 shift; shift
31 ;;
32 --std)
33 STD="${2}"
34 shift; shift
35 ;;
Louis Dionned8a646c2019-02-05 16:42:37 +000036 --libcxx-exceptions)
37 LIBCXX_EXCEPTIONS="${2}"
38 shift; shift
39 ;;
Louis Dionneed0a75e2019-07-19 18:47:00 +000040 --cmake-args)
41 ADDITIONAL_CMAKE_ARGS="${2}"
42 shift; shift
43 ;;
Louis Dionne62248ac2019-01-09 16:35:55 +000044 --lit-args)
45 ADDITIONAL_LIT_ARGS="${2}"
46 shift; shift
47 ;;
48 --no-cleanup)
49 NO_CLEANUP=""
50 shift
51 ;;
52 -h|--help)
53 usage
54 exit 0
55 ;;
56 *)
57 echo "${1} is not a supported argument"
58 usage
59 exit 1
60 ;;
61 esac
62done
63
Louis Dionne9bb01b22019-08-06 15:28:34 +000064if [[ -z ${MONOREPO_ROOT+x} ]]; then echo "--monorepo-root is a required parameter"; usage; exit 1; fi
Louis Dionne62248ac2019-01-09 16:35:55 +000065if [[ -z ${STD+x} ]]; then echo "--std is a required parameter"; usage; exit 1; fi
Louis Dionned8a646c2019-02-05 16:42:37 +000066if [[ "${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 Dionneed0a75e2019-07-19 18:47:00 +000067if [[ -z ${ADDITIONAL_CMAKE_ARGS+x} ]]; then ADDITIONAL_CMAKE_ARGS=""; fi
Louis Dionne62248ac2019-01-09 16:35:55 +000068if [[ -z ${ADDITIONAL_LIT_ARGS+x} ]]; then ADDITIONAL_LIT_ARGS=""; fi
69
70
71TEMP_DIR="$(mktemp -d)"
72echo "Created temporary directory ${TEMP_DIR}"
73function cleanup {
74 if [[ -z ${NO_CLEANUP+x} ]]; then
75 echo "Removing temporary directory ${TEMP_DIR}"
76 rm -rf "${TEMP_DIR}"
77 else
78 echo "Temporary directory is at '${TEMP_DIR}', make sure to clean it up yourself"
79 fi
80}
81trap cleanup EXIT
82
83
Louis Dionne9bb01b22019-08-06 15:28:34 +000084LLVM_BUILD_DIR="${TEMP_DIR}/llvm-build"
85LLVM_INSTALL_DIR="${TEMP_DIR}/llvm-install"
Louis Dionne62248ac2019-01-09 16:35:55 +000086
87echo "@@@ Setting up LIT flags @@@"
88LIT_FLAGS="-sv --param=std=${STD} ${ADDITIONAL_LIT_ARGS}"
Louis Dionne62248ac2019-01-09 16:35:55 +000089echo "@@@@@@"
90
91
Louis Dionne9bb01b22019-08-06 15:28:34 +000092echo "@@@ Configuring CMake @@@"
93mkdir -p "${LLVM_BUILD_DIR}"
94(cd "${LLVM_BUILD_DIR}" &&
Louis Dionne747d3112019-09-11 16:57:19 +000095 xcrun cmake \
96 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake" \
97 -GNinja \
Louis Dionne9bb01b22019-08-06 15:28:34 +000098 -DCMAKE_INSTALL_PREFIX="${LLVM_INSTALL_DIR}" \
Louis Dionned8a646c2019-02-05 16:42:37 +000099 -DLIBCXX_ENABLE_EXCEPTIONS="${LIBCXX_EXCEPTIONS}" \
Louis Dionned8a646c2019-02-05 16:42:37 +0000100 -DLIBCXXABI_ENABLE_EXCEPTIONS=ON \
Louis Dionneed0a75e2019-07-19 18:47:00 +0000101 ${ADDITIONAL_CMAKE_ARGS} \
Louis Dionne62248ac2019-01-09 16:35:55 +0000102 -DLLVM_LIT_ARGS="${LIT_FLAGS}" \
Louis Dionne9bb01b22019-08-06 15:28:34 +0000103 -DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" \
Louis Dionne74953e12020-04-30 12:55:01 -0400104 -DCMAKE_OSX_ARCHITECTURES="x86_64" \
Louis Dionne747d3112019-09-11 16:57:19 +0000105 "${MONOREPO_ROOT}/llvm"
Louis Dionne62248ac2019-01-09 16:35:55 +0000106)
107echo "@@@@@@"
108
109
110echo "@@@ Building libc++.dylib and libc++abi.dylib from sources (just to make sure it works) @@@"
Louis Dionne9bb01b22019-08-06 15:28:34 +0000111ninja -C "${LLVM_BUILD_DIR}" install-cxx install-cxxabi -v
Louis Dionne62248ac2019-01-09 16:35:55 +0000112echo "@@@@@@"
113
114
115echo "@@@ Running tests for libc++ @@@"
116# TODO: We should run check-cxx-abilist too
Louis Dionne9bb01b22019-08-06 15:28:34 +0000117ninja -C "${LLVM_BUILD_DIR}" check-cxx
Louis Dionne62248ac2019-01-09 16:35:55 +0000118echo "@@@@@@"
119
120
121echo "@@@ Running tests for libc++abi @@@"
Louis Dionne9bb01b22019-08-06 15:28:34 +0000122ninja -C "${LLVM_BUILD_DIR}" check-cxxabi
Louis Dionne62248ac2019-01-09 16:35:55 +0000123echo "@@@@@@"
Louis Dionnef0928ed2020-04-23 13:53:14 -0400124
125
126# TODO: In the future, we should only build that way, and we should run the
127# test suite against those.
128echo "@@@ Building libc++ and libc++abi using the Apple script (to make sure they work) @@@"
129"${MONOREPO_ROOT}/libcxx/utils/ci/apple-install-libcxx.sh" \
130 --llvm-root "${MONOREPO_ROOT}" \
131 --build-dir "${LLVM_BUILD_DIR}/apple-build-cxx" \
132 --install-dir "${LLVM_BUILD_DIR}/apple-install-cxx" \
133 --symbols-dir "${LLVM_BUILD_DIR}/apple-symbols-cxx" \
134 --sdk macosx \
135 --architectures "x86_64" \
136 --version 999.99.99 \
137 --cache "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake"
138
139"${MONOREPO_ROOT}/libcxx/utils/ci/apple-install-libcxxabi.sh" \
140 --llvm-root "${MONOREPO_ROOT}" \
141 --build-dir "${LLVM_BUILD_DIR}/apple-build-cxxabi" \
142 --install-dir "${LLVM_BUILD_DIR}/apple-install-cxxabi" \
143 --symbols-dir "${LLVM_BUILD_DIR}/apple-symbols-cxxabi" \
144 --sdk macosx \
145 --architectures "x86_64" \
146 --version 999.99.99 \
147 --cache "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake"
148echo "@@@@@@"