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 |
| 7 | $(basename ${0}) [-h|--help] --libcxx-root <LIBCXX-ROOT> --libcxxabi-root <LIBCXXABI-ROOT> --std <STD> --arch <ARCHITECTURE> [--lit-args <ARGS...>] |
| 8 | |
| 9 | This script is used to continually test libc++ and libc++abi trunk on MacOS. |
| 10 | |
Louis Dionne | d8a646c | 2019-02-05 16:42:37 +0000 | [diff] [blame] | 11 | --libcxx-root Full path to the root of the libc++ repository to test. |
| 12 | --libcxxabi-root Full path to the root of the libc++abi repository to test. |
| 13 | --std Version of the C++ Standard to run the tests under (c++03, c++11, etc..). |
| 14 | --arch Architecture to build the tests for (32, 64). |
| 15 | --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. |
| 16 | [--lit-args] Additional arguments to pass to lit (optional). If there are multiple arguments, quote them to pass them as a single argument to this script. |
| 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 | 62248ac | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 19 | EOM |
| 20 | } |
| 21 | |
| 22 | while [[ $# -gt 0 ]]; do |
| 23 | case "$1" in |
| 24 | --libcxx-root) |
| 25 | LIBCXX_ROOT="${2}" |
| 26 | if [[ ! -e "${LIBCXX_ROOT}" ]]; then |
| 27 | echo "--libcxx-root '${LIBCXX_ROOT}' is not a valid directory" |
| 28 | usage |
| 29 | exit 1 |
| 30 | fi |
| 31 | shift; shift |
| 32 | ;; |
| 33 | --libcxxabi-root) |
| 34 | LIBCXXABI_ROOT="${2}" |
| 35 | if [[ ! -e "${LIBCXXABI_ROOT}" ]]; then |
| 36 | echo "--libcxxabi-root '${LIBCXXABI_ROOT}' is not a valid directory" |
| 37 | usage |
| 38 | exit 1 |
| 39 | fi |
| 40 | shift; shift |
| 41 | ;; |
| 42 | --std) |
| 43 | STD="${2}" |
| 44 | shift; shift |
| 45 | ;; |
| 46 | --arch) |
| 47 | ARCH="${2}" |
| 48 | shift; shift |
| 49 | ;; |
Louis Dionne | d8a646c | 2019-02-05 16:42:37 +0000 | [diff] [blame] | 50 | --libcxx-exceptions) |
| 51 | LIBCXX_EXCEPTIONS="${2}" |
| 52 | shift; shift |
| 53 | ;; |
Louis Dionne | 62248ac | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 54 | --lit-args) |
| 55 | ADDITIONAL_LIT_ARGS="${2}" |
| 56 | shift; shift |
| 57 | ;; |
| 58 | --no-cleanup) |
| 59 | NO_CLEANUP="" |
| 60 | shift |
| 61 | ;; |
| 62 | -h|--help) |
| 63 | usage |
| 64 | exit 0 |
| 65 | ;; |
| 66 | *) |
| 67 | echo "${1} is not a supported argument" |
| 68 | usage |
| 69 | exit 1 |
| 70 | ;; |
| 71 | esac |
| 72 | done |
| 73 | |
| 74 | if [[ -z ${LIBCXX_ROOT+x} ]]; then echo "--libcxx-root is a required parameter"; usage; exit 1; fi |
| 75 | if [[ -z ${LIBCXXABI_ROOT+x} ]]; then echo "--libcxxabi-root is a required parameter"; usage; exit 1; fi |
| 76 | if [[ -z ${STD+x} ]]; then echo "--std is a required parameter"; usage; exit 1; fi |
| 77 | if [[ -z ${ARCH+x} ]]; then echo "--arch is a required parameter"; usage; exit 1; fi |
Louis Dionne | d8a646c | 2019-02-05 16:42:37 +0000 | [diff] [blame] | 78 | 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 | 62248ac | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 79 | if [[ -z ${ADDITIONAL_LIT_ARGS+x} ]]; then ADDITIONAL_LIT_ARGS=""; fi |
| 80 | |
| 81 | |
| 82 | TEMP_DIR="$(mktemp -d)" |
| 83 | echo "Created temporary directory ${TEMP_DIR}" |
| 84 | function cleanup { |
| 85 | if [[ -z ${NO_CLEANUP+x} ]]; then |
| 86 | echo "Removing temporary directory ${TEMP_DIR}" |
| 87 | rm -rf "${TEMP_DIR}" |
| 88 | else |
| 89 | echo "Temporary directory is at '${TEMP_DIR}', make sure to clean it up yourself" |
| 90 | fi |
| 91 | } |
| 92 | trap cleanup EXIT |
| 93 | |
| 94 | |
| 95 | LLVM_ROOT="${TEMP_DIR}/llvm" |
| 96 | LIBCXX_BUILD_DIR="${TEMP_DIR}/libcxx-build" |
| 97 | LIBCXX_INSTALL_DIR="${TEMP_DIR}/libcxx-install" |
| 98 | LIBCXXABI_BUILD_DIR="${TEMP_DIR}/libcxxabi-build" |
| 99 | LIBCXXABI_INSTALL_DIR="${TEMP_DIR}/libcxxabi-install" |
| 100 | |
Louis Dionne | 62248ac | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 101 | |
| 102 | echo "@@@ Downloading LLVM tarball of master (only used for CMake configuration) @@@" |
| 103 | mkdir "${LLVM_ROOT}" |
Louis Dionne | a56a215 | 2019-03-20 15:40:56 +0000 | [diff] [blame] | 104 | LLVM_TARBALL_URL="https://github.com/llvm-mirror/llvm/archive/master.tar.gz" |
Louis Dionne | 62248ac | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 105 | curl -L "${LLVM_TARBALL_URL}" | tar -xz --strip-components=1 -C "${LLVM_ROOT}" |
| 106 | echo "@@@@@@" |
| 107 | |
| 108 | |
| 109 | echo "@@@ Setting up LIT flags @@@" |
| 110 | LIT_FLAGS="-sv --param=std=${STD} ${ADDITIONAL_LIT_ARGS}" |
| 111 | if [[ "${ARCH}" == "32" ]]; then |
| 112 | LIT_FLAGS+=" --param=enable_32bit=true" |
| 113 | fi |
| 114 | echo "@@@@@@" |
| 115 | |
| 116 | |
| 117 | echo "@@@ Configuring CMake for libc++ @@@" |
| 118 | mkdir -p "${LIBCXX_BUILD_DIR}" |
| 119 | (cd "${LIBCXX_BUILD_DIR}" && |
| 120 | xcrun cmake "${LIBCXX_ROOT}" -GNinja \ |
| 121 | -DLLVM_PATH="${LLVM_ROOT}" \ |
| 122 | -DCMAKE_INSTALL_PREFIX="${LIBCXX_INSTALL_DIR}" \ |
Louis Dionne | d8a646c | 2019-02-05 16:42:37 +0000 | [diff] [blame] | 123 | -DLIBCXX_ENABLE_EXCEPTIONS="${LIBCXX_EXCEPTIONS}" \ |
Louis Dionne | 68e3d0a | 2019-04-16 20:46:03 +0000 | [diff] [blame] | 124 | -DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS=OFF \ |
Louis Dionne | 62248ac | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 125 | -DLLVM_LIT_ARGS="${LIT_FLAGS}" \ |
| 126 | -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" # Build a universal dylib |
| 127 | ) |
| 128 | echo "@@@@@@" |
| 129 | |
| 130 | |
| 131 | echo "@@@ Configuring CMake for libc++abi @@@" |
| 132 | mkdir -p "${LIBCXXABI_BUILD_DIR}" |
| 133 | (cd "${LIBCXXABI_BUILD_DIR}" && |
| 134 | xcrun cmake "${LIBCXXABI_ROOT}" -GNinja \ |
| 135 | -DLIBCXXABI_LIBCXX_PATH="${LIBCXX_ROOT}" \ |
| 136 | -DLLVM_PATH="${LLVM_ROOT}" \ |
| 137 | -DCMAKE_INSTALL_PREFIX="${LIBCXXABI_INSTALL_DIR}" \ |
Louis Dionne | d8a646c | 2019-02-05 16:42:37 +0000 | [diff] [blame] | 138 | -DLIBCXXABI_ENABLE_EXCEPTIONS=ON \ |
Louis Dionne | 68e3d0a | 2019-04-16 20:46:03 +0000 | [diff] [blame] | 139 | -DLIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS=ON \ |
Louis Dionne | 62248ac | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 140 | -DLLVM_LIT_ARGS="${LIT_FLAGS}" \ |
| 141 | -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" # Build a universal dylib |
| 142 | ) |
| 143 | echo "@@@@@@" |
| 144 | |
| 145 | |
| 146 | echo "@@@ Building libc++.dylib and libc++abi.dylib from sources (just to make sure it works) @@@" |
Louis Dionne | 8baf80e | 2019-04-16 21:16:58 +0000 | [diff] [blame] | 147 | ninja -C "${LIBCXX_BUILD_DIR}" install-cxx -v |
| 148 | ninja -C "${LIBCXXABI_BUILD_DIR}" install-cxxabi -v |
Louis Dionne | 62248ac | 2019-01-09 16:35:55 +0000 | [diff] [blame] | 149 | echo "@@@@@@" |
| 150 | |
| 151 | |
| 152 | echo "@@@ Running tests for libc++ @@@" |
| 153 | # TODO: We should run check-cxx-abilist too |
| 154 | ninja -C "${LIBCXX_BUILD_DIR}" check-cxx |
| 155 | echo "@@@@@@" |
| 156 | |
| 157 | |
| 158 | echo "@@@ Running tests for libc++abi @@@" |
| 159 | ninja -C "${LIBCXXABI_BUILD_DIR}" check-cxxabi |
| 160 | echo "@@@@@@" |