Louis Dionne | 62248ac | 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 | 74953e1 | 2020-04-30 12:55:01 -0400 | [diff] [blame] | 7 | $(basename ${0}) [-h|--help] --monorepo-root <MONOREPO-ROOT> --std <STD> --libcxx-exceptions <ON|OFF> [--lit-args <ARGS...>] |
Louis Dionne | 62248ac | 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 | 9bb01b2 | 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 | d8a646c | 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..). |
Louis Dionne | d8a646c | 2019-02-05 16:42:37 +0000 | [diff] [blame] | 13 | --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 | ed0a75e | 2019-07-19 18:47:00 +0000 | [diff] [blame] | 14 | [--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 Dionne | d8a646c | 2019-02-05 16:42:37 +0000 | [diff] [blame] | 16 | [--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 Dionne | 62248ac | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 18 | EOM |
| 19 | } |
| 20 | |
| 21 | while [[ $# -gt 0 ]]; do |
| 22 | case "$1" in |
Louis Dionne | 9bb01b2 | 2019-08-06 15:28:34 +0000 | [diff] [blame] | 23 | --monorepo-root) |
| 24 | MONOREPO_ROOT="${2}" |
| 25 | if [[ ! -e "${MONOREPO_ROOT}" ]]; then |
| 26 | echo "--monorepo-root '${MONOREPO_ROOT}' is not a valid directory" |
Louis Dionne | 62248ac | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 27 | usage |
| 28 | exit 1 |
| 29 | fi |
| 30 | shift; shift |
| 31 | ;; |
| 32 | --std) |
| 33 | STD="${2}" |
| 34 | shift; shift |
| 35 | ;; |
Louis Dionne | d8a646c | 2019-02-05 16:42:37 +0000 | [diff] [blame] | 36 | --libcxx-exceptions) |
| 37 | LIBCXX_EXCEPTIONS="${2}" |
| 38 | shift; shift |
| 39 | ;; |
Louis Dionne | ed0a75e | 2019-07-19 18:47:00 +0000 | [diff] [blame] | 40 | --cmake-args) |
| 41 | ADDITIONAL_CMAKE_ARGS="${2}" |
| 42 | shift; shift |
| 43 | ;; |
Louis Dionne | 62248ac | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 44 | --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 |
| 62 | done |
| 63 | |
Louis Dionne | 9bb01b2 | 2019-08-06 15:28:34 +0000 | [diff] [blame] | 64 | if [[ -z ${MONOREPO_ROOT+x} ]]; then echo "--monorepo-root is a required parameter"; usage; exit 1; fi |
Louis Dionne | 62248ac | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 65 | if [[ -z ${STD+x} ]]; then echo "--std is a required parameter"; usage; exit 1; fi |
Louis Dionne | d8a646c | 2019-02-05 16:42:37 +0000 | [diff] [blame] | 66 | 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 | ed0a75e | 2019-07-19 18:47:00 +0000 | [diff] [blame] | 67 | if [[ -z ${ADDITIONAL_CMAKE_ARGS+x} ]]; then ADDITIONAL_CMAKE_ARGS=""; fi |
Louis Dionne | 62248ac | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 68 | if [[ -z ${ADDITIONAL_LIT_ARGS+x} ]]; then ADDITIONAL_LIT_ARGS=""; fi |
| 69 | |
| 70 | |
| 71 | TEMP_DIR="$(mktemp -d)" |
| 72 | echo "Created temporary directory ${TEMP_DIR}" |
| 73 | function 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 | } |
| 81 | trap cleanup EXIT |
| 82 | |
| 83 | |
Louis Dionne | 9bb01b2 | 2019-08-06 15:28:34 +0000 | [diff] [blame] | 84 | LLVM_BUILD_DIR="${TEMP_DIR}/llvm-build" |
| 85 | LLVM_INSTALL_DIR="${TEMP_DIR}/llvm-install" |
Louis Dionne | 62248ac | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 86 | |
| 87 | echo "@@@ Setting up LIT flags @@@" |
| 88 | LIT_FLAGS="-sv --param=std=${STD} ${ADDITIONAL_LIT_ARGS}" |
Louis Dionne | 62248ac | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 89 | echo "@@@@@@" |
| 90 | |
| 91 | |
Louis Dionne | 9bb01b2 | 2019-08-06 15:28:34 +0000 | [diff] [blame] | 92 | echo "@@@ Configuring CMake @@@" |
| 93 | mkdir -p "${LLVM_BUILD_DIR}" |
| 94 | (cd "${LLVM_BUILD_DIR}" && |
Louis Dionne | 747d311 | 2019-09-11 16:57:19 +0000 | [diff] [blame] | 95 | xcrun cmake \ |
| 96 | -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake" \ |
| 97 | -GNinja \ |
Louis Dionne | 9bb01b2 | 2019-08-06 15:28:34 +0000 | [diff] [blame] | 98 | -DCMAKE_INSTALL_PREFIX="${LLVM_INSTALL_DIR}" \ |
Louis Dionne | d8a646c | 2019-02-05 16:42:37 +0000 | [diff] [blame] | 99 | -DLIBCXX_ENABLE_EXCEPTIONS="${LIBCXX_EXCEPTIONS}" \ |
Louis Dionne | d8a646c | 2019-02-05 16:42:37 +0000 | [diff] [blame] | 100 | -DLIBCXXABI_ENABLE_EXCEPTIONS=ON \ |
Louis Dionne | ed0a75e | 2019-07-19 18:47:00 +0000 | [diff] [blame] | 101 | ${ADDITIONAL_CMAKE_ARGS} \ |
Louis Dionne | 62248ac | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 102 | -DLLVM_LIT_ARGS="${LIT_FLAGS}" \ |
Louis Dionne | 9bb01b2 | 2019-08-06 15:28:34 +0000 | [diff] [blame] | 103 | -DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" \ |
Louis Dionne | 74953e1 | 2020-04-30 12:55:01 -0400 | [diff] [blame] | 104 | -DCMAKE_OSX_ARCHITECTURES="x86_64" \ |
Louis Dionne | 747d311 | 2019-09-11 16:57:19 +0000 | [diff] [blame] | 105 | "${MONOREPO_ROOT}/llvm" |
Louis Dionne | 62248ac | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 106 | ) |
| 107 | echo "@@@@@@" |
| 108 | |
| 109 | |
| 110 | echo "@@@ Building libc++.dylib and libc++abi.dylib from sources (just to make sure it works) @@@" |
Louis Dionne | 9bb01b2 | 2019-08-06 15:28:34 +0000 | [diff] [blame] | 111 | ninja -C "${LLVM_BUILD_DIR}" install-cxx install-cxxabi -v |
Louis Dionne | 62248ac | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 112 | echo "@@@@@@" |
| 113 | |
| 114 | |
| 115 | echo "@@@ Running tests for libc++ @@@" |
| 116 | # TODO: We should run check-cxx-abilist too |
Louis Dionne | 9bb01b2 | 2019-08-06 15:28:34 +0000 | [diff] [blame] | 117 | ninja -C "${LLVM_BUILD_DIR}" check-cxx |
Louis Dionne | 62248ac | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 118 | echo "@@@@@@" |
| 119 | |
| 120 | |
| 121 | echo "@@@ Running tests for libc++abi @@@" |
Louis Dionne | 9bb01b2 | 2019-08-06 15:28:34 +0000 | [diff] [blame] | 122 | ninja -C "${LLVM_BUILD_DIR}" check-cxxabi |
Louis Dionne | 62248ac | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 123 | echo "@@@@@@" |
Louis Dionne | f0928ed | 2020-04-23 13:53:14 -0400 | [diff] [blame] | 124 | |
| 125 | |
| 126 | # TODO: In the future, we should only build that way, and we should run the |
| 127 | # test suite against those. |
| 128 | echo "@@@ 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" |
| 148 | echo "@@@@@@" |