From d6c95ae6ffb50bba9b110c4f86c17c054c305e07 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Thu, 23 Apr 2020 13:53:14 -0400 Subject: [PATCH] [libc++] Update scripts to build libc++/libc++abi for Apple Also, make sure we test them. --- libcxx/utils/ci/apple-install-libcxx.sh | 57 ++++++++++------------ libcxx/utils/ci/apple-install-libcxxabi.sh | 57 ++++++++++------------ libcxx/utils/ci/macos-trunk.sh | 27 +++++++++- 3 files changed, 78 insertions(+), 63 deletions(-) diff --git a/libcxx/utils/ci/apple-install-libcxx.sh b/libcxx/utils/ci/apple-install-libcxx.sh index 1337ca2c271f1..b10f0a1578ba6 100755 --- a/libcxx/utils/ci/apple-install-libcxx.sh +++ b/libcxx/utils/ci/apple-install-libcxx.sh @@ -10,33 +10,38 @@ set -e PROGNAME="$(basename "${0}")" + +function error() { printf "error: %s\n" "$*"; exit 1; } + function usage() { cat < --build-dir --install-dir --symbols-dir --sdk --architectures --version --cache +${PROGNAME} [options] ---llvm-root Full path to the root of the LLVM monorepo. Only the libcxx - and libcxxabi directories are required. +[-h|--help] Display this help and exit. ---build-dir Directory to use for building. This will contain intermediate - build products. +--llvm-root Full path to the root of the LLVM monorepo. Only the libcxx + and libcxxabi directories are required. ---install-dir Directory to install the library to. +--build-dir Full path to the directory to use for building. This will + contain intermediate build products. ---symbols-dir Directory to install the .dSYM bundle to. +--install-dir Full path to the directory to install the library to. ---sdk SDK used for building the library. This represents the target - platform that the library will run on. You can get a list of - SDKs with \`xcodebuild -showsdks\`. +--symbols-dir Full path to the directory to install the .dSYM bundle to. ---architectures A whitespace separated list of architectures to build for. - The library will be built for each architecture independently, - and a universal binary containing all architectures will be - created from that. +--sdk SDK used for building the library. This represents + the target platform that the library will run on. + You can get a list of SDKs with \`xcodebuild -showsdks\`. ---version The version of the library to encode in the dylib. +--architectures "..." A whitespace separated list of architectures to build for. + The library will be built for each architecture independently, + and a universal binary containing all architectures will be + created from that. ---cache The CMake cache to use to control how the library gets built. +--version X[.Y[.Z]] The version of the library to encode in the dylib. + +--cache The CMake cache to use to control how the library gets built. EOF } @@ -67,15 +72,8 @@ while [[ $# -gt 0 ]]; do shift; shift ;; --architectures) - architectures="" - shift - while [[ $# -gt 0 ]]; do - if [[ "${1}" == "-"* ]]; then - break - fi - architectures+=" ${1}" - shift - done + architectures="${2}" + shift; shift ;; --version) version="${2}" @@ -86,19 +84,16 @@ while [[ $# -gt 0 ]]; do shift; shift ;; *) - echo "Unknown argument '${1}'" - exit 1 + error "Unknown argument '${1}'" ;; esac done for arg in llvm_root build_dir symbols_dir install_dir sdk architectures version cache; do if [ -z ${!arg+x} ]; then - echo "Missing required argument '--${arg//_/-}'" - exit 1 + error "Missing required argument '--${arg//_/-}'" elif [ "${!arg}" == "" ]; then - echo "Argument to --${arg//_/-} must not be empty" - exit 1 + error "Argument to --${arg//_/-} must not be empty" fi done diff --git a/libcxx/utils/ci/apple-install-libcxxabi.sh b/libcxx/utils/ci/apple-install-libcxxabi.sh index cf1e462b32258..04173b2adbeb3 100755 --- a/libcxx/utils/ci/apple-install-libcxxabi.sh +++ b/libcxx/utils/ci/apple-install-libcxxabi.sh @@ -10,33 +10,38 @@ set -e PROGNAME="$(basename "${0}")" + +function error() { printf "error: %s\n" "$*"; exit 1; } + function usage() { cat < --build-dir --install-dir --symbols-dir --sdk --architectures --version --cache +${PROGNAME} [options] ---llvm-root Full path to the root of the LLVM monorepo. Only the libcxx - and libcxxabi directories are required. +[-h|--help] Display this help and exit. ---build-dir Directory to use for building. This will contain intermediate - build products. +--llvm-root Full path to the root of the LLVM monorepo. Only the libcxx + and libcxxabi directories are required. ---install-dir Directory to install the library to. +--build-dir Full path to the directory to use for building. This will + contain intermediate build products. ---symbols-dir Directory to install the .dSYM bundle to. +--install-dir Full path to the directory to install the library to. ---sdk SDK used for building the library. This represents the target - platform that the library will run on. You can get a list of - SDKs with \`xcodebuild -showsdks\`. +--symbols-dir Full path to the directory to install the .dSYM bundle to. ---architectures A whitespace separated list of architectures to build for. - The library will be built for each architecture independently, - and a universal binary containing all architectures will be - created from that. +--sdk SDK used for building the library. This represents + the target platform that the library will run on. + You can get a list of SDKs with \`xcodebuild -showsdks\`. ---version The version of the library to encode in the dylib. +--architectures "..." A whitespace separated list of architectures to build for. + The library will be built for each architecture independently, + and a universal binary containing all architectures will be + created from that. ---cache The CMake cache to use to control how the library gets built. +--version X[.Y[.Z]] The version of the library to encode in the dylib. + +--cache The CMake cache to use to control how the library gets built. EOF } @@ -67,15 +72,8 @@ while [[ $# -gt 0 ]]; do shift; shift ;; --architectures) - architectures="" - shift - while [[ $# -gt 0 ]]; do - if [[ "${1}" == "-"* ]]; then - break - fi - architectures+=" ${1}" - shift - done + architectures="${2}" + shift; shift ;; --version) version="${2}" @@ -86,19 +84,16 @@ while [[ $# -gt 0 ]]; do shift; shift ;; *) - echo "Unknown argument '${1}'" - exit 1 + error "Unknown argument '${1}'" ;; esac done for arg in llvm_root build_dir symbols_dir install_dir sdk architectures version cache; do if [ -z ${!arg+x} ]; then - echo "Missing required argument '--${arg//_/-}'" - exit 1 + error "Missing required argument '--${arg//_/-}'" elif [ "${!arg}" == "" ]; then - echo "Argument to --${arg//_/-} must not be empty" - exit 1 + error "Argument to --${arg//_/-} must not be empty" fi done diff --git a/libcxx/utils/ci/macos-trunk.sh b/libcxx/utils/ci/macos-trunk.sh index 7a5ee75e2b5e5..ea6a9b435b5a5 100755 --- a/libcxx/utils/ci/macos-trunk.sh +++ b/libcxx/utils/ci/macos-trunk.sh @@ -4,7 +4,7 @@ set -ue function usage() { cat < --std --arch [--lit-args ] +$(basename ${0}) [-h|--help] --monorepo-root --std --arch --libcxx-exceptions [--lit-args ] This script is used to continually test libc++ and libc++abi trunk on MacOS. @@ -130,3 +130,28 @@ echo "@@@@@@" echo "@@@ Running tests for libc++abi @@@" ninja -C "${LLVM_BUILD_DIR}" check-cxxabi echo "@@@@@@" + + +# TODO: In the future, we should only build that way, and we should run the +# test suite against those. +echo "@@@ Building libc++ and libc++abi using the Apple script (to make sure they work) @@@" +"${MONOREPO_ROOT}/libcxx/utils/ci/apple-install-libcxx.sh" \ + --llvm-root "${MONOREPO_ROOT}" \ + --build-dir "${LLVM_BUILD_DIR}/apple-build-cxx" \ + --install-dir "${LLVM_BUILD_DIR}/apple-install-cxx" \ + --symbols-dir "${LLVM_BUILD_DIR}/apple-symbols-cxx" \ + --sdk macosx \ + --architectures "x86_64" \ + --version 999.99.99 \ + --cache "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake" + +"${MONOREPO_ROOT}/libcxx/utils/ci/apple-install-libcxxabi.sh" \ + --llvm-root "${MONOREPO_ROOT}" \ + --build-dir "${LLVM_BUILD_DIR}/apple-build-cxxabi" \ + --install-dir "${LLVM_BUILD_DIR}/apple-install-cxxabi" \ + --symbols-dir "${LLVM_BUILD_DIR}/apple-symbols-cxxabi" \ + --sdk macosx \ + --architectures "x86_64" \ + --version 999.99.99 \ + --cache "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake" +echo "@@@@@@"