# 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}/llvm-${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" DOWNLOAD_THIRD_PARTY="https://github.com/llvm/llvm-project/releases/download/llvmorg-${BPM_PKG_VERSION}/third-party-${BPM_PKG_VERSION}.src.tar.xz" FILENAME="${DOWNLOAD##*/}" FILENAME_CMAKE_MODULES="${DOWNLOAD_CMAKE_MODULES##*/}" FILENAME_THIRD_PARTY="${DOWNLOAD_THIRD_PARTY##*/}" # 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_CMAKE_MODULES" wget "$DOWNLOAD_THIRD_PARTY" tar -xvf "$FILENAME" --strip-components=1 -C "$BPM_SOURCE" mkdir {cmake,third-party} tar -xvf "$FILENAME_CMAKE_MODULES" --strip-components=1 -C cmake tar -xvf "$FILENAME_THIRD_PARTY" --strip-components=1 -C third-party } # The build function is executed in the source directory # This function is used to compile the source code build() { mkdir -v build cd build CC=gcc CXX=g++ \ cmake -DCMAKE_INSTALL_PREFIX=/usr \ -DLLVM_ENABLE_FFI=ON \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_BUILD_LLVM_DYLIB=ON \ -DLLVM_LINK_LLVM_DYLIB=ON \ -DLLVM_ENABLE_RTTI=ON \ -DLLVM_TARGETS_TO_BUILD="host" \ -DLLVM_BINUTILS_INCDIR=/usr/include \ -DLLVM_INCLUDE_BENCHMARKS=OFF \ -Wno-dev -G Ninja .. ninja } # 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 cp bin/FileCheck "$BPM_OUTPUT"/usr/bin }