Louis Dionne | cb4e59e | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | set -ue |
| 4 | |
| 5 | function usage() { |
| 6 | cat <<EOM |
Louis Dionne | 53e9c2d | 2019-08-06 20:01:28 +0000 | [diff] [blame] | 7 | $(basename ${0}) [-h|--help] --monorepo-root <MONOREPO-ROOT> --std <STD> --arch <ARCHITECTURE> [--lit-args <ARGS...>] |
Louis Dionne | cb4e59e | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 8 | |
| 9 | This script is used to continually test libc++ and libc++abi trunk on MacOS. |
| 10 | |
Louis Dionne | 8442252 | 2019-08-06 15:28:34 +0000 | [diff] [blame] | 11 | --monorepo-root Full path to the root of the LLVM monorepo. Both libc++ and libc++abi from the monorepo are used. |
Louis Dionne | a3ec627 | 2019-02-05 16:42:37 +0000 | [diff] [blame] | 12 | --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 Dionne | 3b1ef58 | 2019-07-19 18:47:00 +0000 | [diff] [blame] | 15 | [--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 Dionne | a3ec627 | 2019-02-05 16:42:37 +0000 | [diff] [blame] | 17 | [--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 Dionne | cb4e59e | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 19 | EOM |
| 20 | } |
| 21 | |
| 22 | while [[ $# -gt 0 ]]; do |
| 23 | case "$1" in |
Louis Dionne | 8442252 | 2019-08-06 15:28:34 +0000 | [diff] [blame] | 24 | --monorepo-root) |
| 25 | MONOREPO_ROOT="${2}" |
| 26 | if [[ ! -e "${MONOREPO_ROOT}" ]]; then |
| 27 | echo "--monorepo-root '${MONOREPO_ROOT}' is not a valid directory" |
Louis Dionne | cb4e59e | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 28 | 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 Dionne | a3ec627 | 2019-02-05 16:42:37 +0000 | [diff] [blame] | 41 | --libcxx-exceptions) |
| 42 | LIBCXX_EXCEPTIONS="${2}" |
| 43 | shift; shift |
| 44 | ;; |
Louis Dionne | 3b1ef58 | 2019-07-19 18:47:00 +0000 | [diff] [blame] | 45 | --cmake-args) |
| 46 | ADDITIONAL_CMAKE_ARGS="${2}" |
| 47 | shift; shift |
| 48 | ;; |
Louis Dionne | cb4e59e | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 49 | --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 |
| 67 | done |
| 68 | |
Louis Dionne | 8442252 | 2019-08-06 15:28:34 +0000 | [diff] [blame] | 69 | if [[ -z ${MONOREPO_ROOT+x} ]]; then echo "--monorepo-root is a required parameter"; usage; exit 1; fi |
Louis Dionne | cb4e59e | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 70 | if [[ -z ${STD+x} ]]; then echo "--std is a required parameter"; usage; exit 1; fi |
| 71 | if [[ -z ${ARCH+x} ]]; then echo "--arch is a required parameter"; usage; exit 1; fi |
Louis Dionne | a3ec627 | 2019-02-05 16:42:37 +0000 | [diff] [blame] | 72 | if [[ "${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 Dionne | 3b1ef58 | 2019-07-19 18:47:00 +0000 | [diff] [blame] | 73 | if [[ -z ${ADDITIONAL_CMAKE_ARGS+x} ]]; then ADDITIONAL_CMAKE_ARGS=""; fi |
Louis Dionne | cb4e59e | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 74 | if [[ -z ${ADDITIONAL_LIT_ARGS+x} ]]; then ADDITIONAL_LIT_ARGS=""; fi |
| 75 | |
| 76 | |
| 77 | TEMP_DIR="$(mktemp -d)" |
| 78 | echo "Created temporary directory ${TEMP_DIR}" |
| 79 | function 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 | } |
| 87 | trap cleanup EXIT |
| 88 | |
| 89 | |
Louis Dionne | 8442252 | 2019-08-06 15:28:34 +0000 | [diff] [blame] | 90 | LLVM_BUILD_DIR="${TEMP_DIR}/llvm-build" |
| 91 | LLVM_INSTALL_DIR="${TEMP_DIR}/llvm-install" |
Louis Dionne | cb4e59e | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 92 | |
| 93 | echo "@@@ Setting up LIT flags @@@" |
| 94 | LIT_FLAGS="-sv --param=std=${STD} ${ADDITIONAL_LIT_ARGS}" |
| 95 | if [[ "${ARCH}" == "32" ]]; then |
| 96 | LIT_FLAGS+=" --param=enable_32bit=true" |
| 97 | fi |
| 98 | echo "@@@@@@" |
| 99 | |
| 100 | |
Louis Dionne | 8442252 | 2019-08-06 15:28:34 +0000 | [diff] [blame] | 101 | echo "@@@ Configuring CMake @@@" |
| 102 | mkdir -p "${LLVM_BUILD_DIR}" |
| 103 | (cd "${LLVM_BUILD_DIR}" && |
Louis Dionne | 340b725 | 2019-09-11 16:57:19 +0000 | [diff] [blame] | 104 | xcrun cmake \ |
| 105 | -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake" \ |
| 106 | -GNinja \ |
Louis Dionne | 8442252 | 2019-08-06 15:28:34 +0000 | [diff] [blame] | 107 | -DCMAKE_INSTALL_PREFIX="${LLVM_INSTALL_DIR}" \ |
Louis Dionne | a3ec627 | 2019-02-05 16:42:37 +0000 | [diff] [blame] | 108 | -DLIBCXX_ENABLE_EXCEPTIONS="${LIBCXX_EXCEPTIONS}" \ |
Louis Dionne | a3ec627 | 2019-02-05 16:42:37 +0000 | [diff] [blame] | 109 | -DLIBCXXABI_ENABLE_EXCEPTIONS=ON \ |
Louis Dionne | 3b1ef58 | 2019-07-19 18:47:00 +0000 | [diff] [blame] | 110 | ${ADDITIONAL_CMAKE_ARGS} \ |
Louis Dionne | cb4e59e | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 111 | -DLLVM_LIT_ARGS="${LIT_FLAGS}" \ |
Louis Dionne | 8442252 | 2019-08-06 15:28:34 +0000 | [diff] [blame] | 112 | -DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" \ |
Louis Dionne | 340b725 | 2019-09-11 16:57:19 +0000 | [diff] [blame] | 113 | -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" \ |
| 114 | "${MONOREPO_ROOT}/llvm" |
Louis Dionne | cb4e59e | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 115 | ) |
| 116 | echo "@@@@@@" |
| 117 | |
| 118 | |
| 119 | echo "@@@ Building libc++.dylib and libc++abi.dylib from sources (just to make sure it works) @@@" |
Louis Dionne | 8442252 | 2019-08-06 15:28:34 +0000 | [diff] [blame] | 120 | ninja -C "${LLVM_BUILD_DIR}" install-cxx install-cxxabi -v |
Louis Dionne | cb4e59e | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 121 | echo "@@@@@@" |
| 122 | |
| 123 | |
| 124 | echo "@@@ Running tests for libc++ @@@" |
| 125 | # TODO: We should run check-cxx-abilist too |
Louis Dionne | 8442252 | 2019-08-06 15:28:34 +0000 | [diff] [blame] | 126 | ninja -C "${LLVM_BUILD_DIR}" check-cxx |
Louis Dionne | cb4e59e | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 127 | echo "@@@@@@" |
| 128 | |
| 129 | |
| 130 | echo "@@@ Running tests for libc++abi @@@" |
Louis Dionne | 8442252 | 2019-08-06 15:28:34 +0000 | [diff] [blame] | 131 | ninja -C "${LLVM_BUILD_DIR}" check-cxxabi |
Louis Dionne | cb4e59e | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 132 | echo "@@@@@@" |