74 lines
2.7 KiB
Bash
74 lines
2.7 KiB
Bash
# 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
|
|
|
|
# The build function is executed in the source directory
|
|
# This function is used to compile the source code
|
|
build() {
|
|
export CC=gcc CXX=g++
|
|
cmake -B build -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_BINUTILS_INCDIR=/usr/include \
|
|
-DLLVM_INCLUDE_BENCHMARKS=OFF \
|
|
-DCLANG_DEFAULT_PIE_ON_LINUX=ON \
|
|
-Wno-dev -G Ninja
|
|
cmake --build build
|
|
}
|
|
|
|
_pick() {
|
|
local p="$1" f d; shift
|
|
for f; do
|
|
[ -d "$BPM_WORKDIR"/output_"$p" ] || { echo "Split package $p not found"; exit 1; }
|
|
d="$BPM_WORKDIR"/output_"$p"/"${f#$BPM_OUTPUT}"
|
|
mkdir -p "$(dirname "$d")"
|
|
mv "$f" "$d"
|
|
rmdir -p --ignore-fail-on-non-empty "$(dirname "$f")"
|
|
done
|
|
}
|
|
|
|
# The package function is executed in the source directory
|
|
# This function is used to move the compiled files into the output directory
|
|
package_llvm() {
|
|
DESTDIR="$BPM_OUTPUT" cmake --install build
|
|
|
|
# Install missing binary
|
|
install -Dm755 "$BPM_SOURCE"/build/bin/FileCheck "$BPM_OUTPUT"/usr/bin/FileCheck
|
|
|
|
cd "$BPM_OUTPUT"
|
|
|
|
# Move clang files into split package
|
|
_pick clang usr/bin/{amdgpu-arch,analyze-build,c-index-test,diagtool,git-clang-format,hmaptool,intercept-build,nvptx-arch,scan-build,scan-build-py,scan-view}
|
|
_pick clang usr/bin/clang*
|
|
_pick clang usr/lib/libclang*
|
|
_pick clang usr/lib/cmake/clang
|
|
_pick clang usr/include/clang-c/
|
|
_pick clang usr/include/clang
|
|
_pick clang usr/lib/clang
|
|
_pick clang usr/share/clang
|
|
_pick clang usr/share/man/man1/scan-build.1
|
|
_pick clang usr/share/scan-build
|
|
_pick clang usr/share/scan-view
|
|
|
|
# Move runtime libraries into split package
|
|
for lib in libLLVM libLLVM-"${BPM_PKG_VERSION%%.*}" libLTO libRemarks; do
|
|
_pick llvm-libs "$BPM_OUTPUT"/usr/lib/"$lib".so*
|
|
done
|
|
|
|
# Install package license
|
|
install -Dm644 "$BPM_SOURCE"/LICENSE.TXT "$BPM_OUTPUT"/usr/share/licenses/llvm/LICENSE.TXT
|
|
}
|
|
|
|
package_llvm-libs() {
|
|
# Install package license
|
|
install -Dm644 "$BPM_SOURCE"/LICENSE.TXT "$BPM_OUTPUT"/usr/share/licenses/llvm-libs/LICENSE.TXT
|
|
}
|
|
|
|
package_clang() {
|
|
# Install package license
|
|
install -Dm644 "$BPM_SOURCE"/LICENSE.TXT "$BPM_OUTPUT"/usr/share/licenses/clang/LICENSE.TXT
|
|
}
|