# This is the source.sh script. It is executed by BPM in a temporary directory when compiling a source package # BPM Expects the source code to be extracted into the automatically created 'source' directory which can be accessed using $BPM_SOURCE # BPM Expects the output files to be present in the automatically created 'output' directory which can be accessed using $BPM_OUTPUT DOWNLOAD="https://github.com/llvm/llvm-project/releases/download/llvmorg-${BPM_PKG_VERSION}/lld-${BPM_PKG_VERSION}.src.tar.xz" DOWNLOAD_LLVM="https://github.com/llvm/llvm-project/releases/download/llvmorg-${BPM_PKG_VERSION}/llvm-${BPM_PKG_VERSION}.src.tar.xz" DOWNLOAD_LIBUNWIND="https://github.com/llvm/llvm-project/releases/download/llvmorg-${BPM_PKG_VERSION}/libunwind-${BPM_PKG_VERSION}.src.tar.xz" DOWNLOAD_CMAKE_MODULES="https://github.com/llvm/llvm-project/releases/download/llvmorg-${BPM_PKG_VERSION}/cmake-${BPM_PKG_VERSION}.src.tar.xz" FILENAME="${DOWNLOAD##*/}" FILENAME_LLVM="${DOWNLOAD_LLVM##*/}" FILENAME_LIBUNWIND="${DOWNLOAD_LIBUNWIND##*/}" FILENAME_CMAKE_MODULES="${DOWNLOAD_CMAKE_MODULES##*/}" # The prepare function is executed in the root of the temp directory # This function is used for downloading files and putting them into the correct location prepare() { wget "$DOWNLOAD" wget "$DOWNLOAD_LLVM" wget "$DOWNLOAD_LIBUNWIND" wget "$DOWNLOAD_CMAKE_MODULES" tar -xvf "$FILENAME" --strip-components=1 -C "$BPM_SOURCE" tar -xvf "$FILENAME_LLVM" tar -xvf "$FILENAME_LIBUNWIND" tar -xvf "$FILENAME_CMAKE_MODULES" mv llvm-${BPM_PKG_VERSION}.src llvm mv libunwind-${BPM_PKG_VERSION}.src libunwind mv cmake-${BPM_PKG_VERSION}.src cmake cd "$BPM_SOURCE" # Fix to https://github.com/llvmenv/llvmenv/issues/115 ln -s ../../libunwind/include/mach-o MachO/mach-o } # The build function is executed in the source directory # This function is used to compile the source code build() { mkdir build cd build cmake -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ -DCMAKE_INSTALL_DOCDIR=share/doc \ -DCMAKE_SKIP_RPATH=ON \ -DBUILD_SHARED_LIBS=ON \ -DLLVM_BUILD_DOCS=ON \ -DLLVM_INCLUDE_TESTS=ON \ -DLLVM_LINK_LLVM_DYLIB=ON \ -DLLVM_MAIN_SRC_DIR="${BPM_SOURCE}/llvm" \ -G Ninja .. ninja } # The check function is executed in the source directory # This function is used to run tests to verify the package has been compiled correctly check() { cd build ninja check-lld } # The package function is executed in the source directory # This function is used to move the compiled files into the output directory package() { cd build DESTDIR="$BPM_OUTPUT" ninja install install -Dm644 "$BPM_SOURCE"/LICENSE.TXT "$BPM_OUTPUT"/usr/share/licenses/lld/LICENSE.TXT }