2019-01-10 00:35:55 +08:00
#!/usr/bin/env bash
set -ue
function usage( ) {
cat <<EOM
2019-08-07 04:01:28 +08:00
$( basename ${ 0 } ) [ -h| --help] --monorepo-root <MONOREPO-ROOT> --std <STD> --arch <ARCHITECTURE> [ --lit-args <ARGS...>]
2019-01-10 00:35:55 +08:00
This script is used to continually test libc++ and libc++abi trunk on MacOS.
2019-08-06 23:28:34 +08:00
--monorepo-root Full path to the root of the LLVM monorepo. Both libc++ and libc++abi from the monorepo are used.
2019-02-06 00:42:37 +08:00
--std Version of the C++ Standard to run the tests under ( c++03, c++11, etc..) .
--arch Architecture to build the tests for ( 32, 64) .
--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.
2019-07-20 02:47:00 +08:00
[ --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.
[ --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.
2019-02-06 00:42:37 +08:00
[ --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.
[ -h, --help] Print this help.
2019-01-10 00:35:55 +08:00
EOM
}
while [ [ $# -gt 0 ] ] ; do
case " $1 " in
2019-08-06 23:28:34 +08:00
--monorepo-root)
MONOREPO_ROOT = " ${ 2 } "
if [ [ ! -e " ${ MONOREPO_ROOT } " ] ] ; then
echo " --monorepo-root ' ${ MONOREPO_ROOT } ' is not a valid directory "
2019-01-10 00:35:55 +08:00
usage
exit 1
fi
shift; shift
; ;
--std)
STD = " ${ 2 } "
shift; shift
; ;
--arch)
ARCH = " ${ 2 } "
shift; shift
; ;
2019-02-06 00:42:37 +08:00
--libcxx-exceptions)
LIBCXX_EXCEPTIONS = " ${ 2 } "
shift; shift
; ;
2019-07-20 02:47:00 +08:00
--cmake-args)
ADDITIONAL_CMAKE_ARGS = " ${ 2 } "
shift; shift
; ;
2019-01-10 00:35:55 +08:00
--lit-args)
ADDITIONAL_LIT_ARGS = " ${ 2 } "
shift; shift
; ;
--no-cleanup)
NO_CLEANUP = ""
shift
; ;
-h| --help)
usage
exit 0
; ;
*)
echo " ${ 1 } is not a supported argument "
usage
exit 1
; ;
esac
done
2019-08-06 23:28:34 +08:00
if [ [ -z ${ MONOREPO_ROOT +x } ] ] ; then echo "--monorepo-root is a required parameter" ; usage; exit 1; fi
2019-01-10 00:35:55 +08:00
if [ [ -z ${ STD +x } ] ] ; then echo "--std is a required parameter" ; usage; exit 1; fi
if [ [ -z ${ ARCH +x } ] ] ; then echo "--arch is a required parameter" ; usage; exit 1; fi
2019-02-06 00:42:37 +08:00
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
2019-07-20 02:47:00 +08:00
if [ [ -z ${ ADDITIONAL_CMAKE_ARGS +x } ] ] ; then ADDITIONAL_CMAKE_ARGS = "" ; fi
2019-01-10 00:35:55 +08:00
if [ [ -z ${ ADDITIONAL_LIT_ARGS +x } ] ] ; then ADDITIONAL_LIT_ARGS = "" ; fi
TEMP_DIR = " $( mktemp -d) "
echo " Created temporary directory ${ TEMP_DIR } "
function cleanup {
if [ [ -z ${ NO_CLEANUP +x } ] ] ; then
echo " Removing temporary directory ${ TEMP_DIR } "
rm -rf " ${ TEMP_DIR } "
else
echo " Temporary directory is at ' ${ TEMP_DIR } ', make sure to clean it up yourself "
fi
}
trap cleanup EXIT
2019-08-06 23:28:34 +08:00
LLVM_BUILD_DIR = " ${ TEMP_DIR } /llvm-build "
LLVM_INSTALL_DIR = " ${ TEMP_DIR } /llvm-install "
2019-01-10 00:35:55 +08:00
echo "@@@ Setting up LIT flags @@@"
LIT_FLAGS = " -sv --param=std= ${ STD } ${ ADDITIONAL_LIT_ARGS } "
if [ [ " ${ ARCH } " = = "32" ] ] ; then
LIT_FLAGS += " --param=enable_32bit=true"
fi
echo "@@@@@@"
2019-08-06 23:28:34 +08:00
echo "@@@ Configuring CMake @@@"
mkdir -p " ${ LLVM_BUILD_DIR } "
( cd " ${ LLVM_BUILD_DIR } " &&
2019-09-12 00:57:19 +08:00
xcrun cmake \
-C " ${ MONOREPO_ROOT } /libcxx/cmake/caches/Apple.cmake " \
-GNinja \
2019-08-06 23:28:34 +08:00
-DCMAKE_INSTALL_PREFIX= " ${ LLVM_INSTALL_DIR } " \
2019-02-06 00:42:37 +08:00
-DLIBCXX_ENABLE_EXCEPTIONS= " ${ LIBCXX_EXCEPTIONS } " \
-DLIBCXXABI_ENABLE_EXCEPTIONS= ON \
2019-07-20 02:47:00 +08:00
${ ADDITIONAL_CMAKE_ARGS } \
2019-01-10 00:35:55 +08:00
-DLLVM_LIT_ARGS= " ${ LIT_FLAGS } " \
2019-08-06 23:28:34 +08:00
-DLLVM_ENABLE_PROJECTS= "libcxx;libcxxabi" \
2019-09-12 00:57:19 +08:00
-DCMAKE_OSX_ARCHITECTURES= "i386;x86_64" \
" ${ MONOREPO_ROOT } /llvm "
2019-01-10 00:35:55 +08:00
)
echo "@@@@@@"
echo "@@@ Building libc++.dylib and libc++abi.dylib from sources (just to make sure it works) @@@"
2019-08-06 23:28:34 +08:00
ninja -C " ${ LLVM_BUILD_DIR } " install-cxx install-cxxabi -v
2019-01-10 00:35:55 +08:00
echo "@@@@@@"
echo "@@@ Running tests for libc++ @@@"
# TODO: We should run check-cxx-abilist too
2019-08-06 23:28:34 +08:00
ninja -C " ${ LLVM_BUILD_DIR } " check-cxx
2019-01-10 00:35:55 +08:00
echo "@@@@@@"
echo "@@@ Running tests for libc++abi @@@"
2019-08-06 23:28:34 +08:00
ninja -C " ${ LLVM_BUILD_DIR } " check-cxxabi
2019-01-10 00:35:55 +08:00
echo "@@@@@@"