1a8c51b3fSopenharmony_ci#!/usr/bin/env bash
2a8c51b3fSopenharmony_ci
3a8c51b3fSopenharmony_ci# Install a newer CMake version
4a8c51b3fSopenharmony_cicurl -sSL https://cmake.org/files/v3.6/cmake-3.6.1-Linux-x86_64.sh -o install-cmake.sh
5a8c51b3fSopenharmony_cichmod +x install-cmake.sh
6a8c51b3fSopenharmony_cisudo ./install-cmake.sh --prefix=/usr/local --skip-license
7a8c51b3fSopenharmony_ci
8a8c51b3fSopenharmony_ci# Checkout LLVM sources
9a8c51b3fSopenharmony_cigit clone --depth=1 https://github.com/llvm-mirror/llvm.git llvm-source
10a8c51b3fSopenharmony_cigit clone --depth=1 https://github.com/llvm-mirror/libcxx.git llvm-source/projects/libcxx
11a8c51b3fSopenharmony_cigit clone --depth=1 https://github.com/llvm-mirror/libcxxabi.git llvm-source/projects/libcxxabi
12a8c51b3fSopenharmony_ci
13a8c51b3fSopenharmony_ci# Setup libc++ options
14a8c51b3fSopenharmony_ciif [ -z "$BUILD_32_BITS" ]; then
15a8c51b3fSopenharmony_ci  export BUILD_32_BITS=OFF && echo disabling 32 bit build
16a8c51b3fSopenharmony_cifi
17a8c51b3fSopenharmony_ci
18a8c51b3fSopenharmony_ci# Build and install libc++ (Use unstable ABI for better sanitizer coverage)
19a8c51b3fSopenharmony_cimkdir llvm-build && cd llvm-build
20a8c51b3fSopenharmony_cicmake -DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${COMPILER} \
21a8c51b3fSopenharmony_ci      -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/usr \
22a8c51b3fSopenharmony_ci      -DLIBCXX_ABI_UNSTABLE=ON \
23a8c51b3fSopenharmony_ci      -DLLVM_USE_SANITIZER=${LIBCXX_SANITIZER} \
24a8c51b3fSopenharmony_ci      -DLLVM_BUILD_32_BITS=${BUILD_32_BITS} \
25a8c51b3fSopenharmony_ci      ../llvm-source
26a8c51b3fSopenharmony_cimake cxx -j2
27a8c51b3fSopenharmony_cisudo make install-cxxabi install-cxx
28a8c51b3fSopenharmony_cicd ../
29