Initial commit
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
# 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 prepare function is executed in the root of the temp directory
|
||||
# This function is used for putting downloaded files to the correct location or applying patches
|
||||
prepare() {
|
||||
cd "$BPM_SOURCE"/tools
|
||||
patch -Np1 -i "$BPM_WORKDIR"/enable-fstack-protector-strong-by-default.patch
|
||||
}
|
||||
|
||||
# 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/lib/llvm${BPM_PKG_VERSION%%.*} \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_SKIP_INSTALL_RPATH=ON \
|
||||
-DLLVM_ENABLE_FFI=ON \
|
||||
-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_llvm21() {
|
||||
DESTDIR="$BPM_OUTPUT" cmake --install build
|
||||
|
||||
cd "$BPM_OUTPUT"
|
||||
|
||||
# Move compiler-rt files into split package
|
||||
_pick compiler-rt${BPM_PKG_VERSION%%.*} usr/lib/llvm${BPM_PKG_VERSION%%.*}/lib/clang/${BPM_PKG_VERSION%%.*}/bin/hwasan_symbolize
|
||||
_pick compiler-rt${BPM_PKG_VERSION%%.*} usr/lib/llvm${BPM_PKG_VERSION%%.*}/lib/clang/${BPM_PKG_VERSION%%.*}/include/fuzzer
|
||||
_pick compiler-rt${BPM_PKG_VERSION%%.*} usr/lib/llvm${BPM_PKG_VERSION%%.*}/lib/clang/${BPM_PKG_VERSION%%.*}/include/orc
|
||||
_pick compiler-rt${BPM_PKG_VERSION%%.*} usr/lib/llvm${BPM_PKG_VERSION%%.*}/lib/clang/${BPM_PKG_VERSION%%.*}/include/profile
|
||||
_pick compiler-rt${BPM_PKG_VERSION%%.*} usr/lib/llvm${BPM_PKG_VERSION%%.*}/lib/clang/${BPM_PKG_VERSION%%.*}/include/sanitizer
|
||||
_pick compiler-rt${BPM_PKG_VERSION%%.*} usr/lib/llvm${BPM_PKG_VERSION%%.*}/lib/clang/${BPM_PKG_VERSION%%.*}/include/xray
|
||||
_pick compiler-rt${BPM_PKG_VERSION%%.*} usr/lib/llvm${BPM_PKG_VERSION%%.*}/lib/clang/${BPM_PKG_VERSION%%.*}/lib
|
||||
_pick compiler-rt${BPM_PKG_VERSION%%.*} usr/lib/llvm${BPM_PKG_VERSION%%.*}/lib/clang/${BPM_PKG_VERSION%%.*}/share
|
||||
|
||||
# Move clang files into split package
|
||||
_pick clang${BPM_PKG_VERSION%%.*} usr/lib/llvm${BPM_PKG_VERSION%%.*}/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${BPM_PKG_VERSION%%.*} usr/lib/llvm${BPM_PKG_VERSION%%.*}/bin/clang*
|
||||
_pick clang${BPM_PKG_VERSION%%.*} usr/lib/llvm${BPM_PKG_VERSION%%.*}/lib/libclang*
|
||||
_pick clang${BPM_PKG_VERSION%%.*} usr/lib/llvm${BPM_PKG_VERSION%%.*}/lib/cmake/clang
|
||||
_pick clang${BPM_PKG_VERSION%%.*} usr/lib/llvm${BPM_PKG_VERSION%%.*}/include/clang-c/
|
||||
_pick clang${BPM_PKG_VERSION%%.*} usr/lib/llvm${BPM_PKG_VERSION%%.*}/include/clang
|
||||
_pick clang${BPM_PKG_VERSION%%.*} usr/lib/llvm${BPM_PKG_VERSION%%.*}/lib/clang
|
||||
_pick clang${BPM_PKG_VERSION%%.*} usr/lib/llvm${BPM_PKG_VERSION%%.*}/share/clang
|
||||
_pick clang${BPM_PKG_VERSION%%.*} usr/lib/llvm${BPM_PKG_VERSION%%.*}/share/man/man1/scan-build.1
|
||||
_pick clang${BPM_PKG_VERSION%%.*} usr/lib/llvm${BPM_PKG_VERSION%%.*}/share/scan-build
|
||||
_pick clang${BPM_PKG_VERSION%%.*} usr/lib/llvm${BPM_PKG_VERSION%%.*}/share/scan-view
|
||||
|
||||
# Move runtime libraries into split package
|
||||
for lib in libLLVM libLLVM-"${BPM_PKG_VERSION%%.*}"; do
|
||||
_pick llvm${BPM_PKG_VERSION%%.*}-libs usr/lib/llvm${BPM_PKG_VERSION%%.*}/lib/"$lib".so*
|
||||
done
|
||||
|
||||
# Create versioned symlinks from /usr/bin/ to /usr/lib/llvm*/bin/
|
||||
install -d "$BPM_OUTPUT"/usr/bin
|
||||
local _binary
|
||||
for _binary in "$BPM_OUTPUT"/usr/lib/llvm${BPM_PKG_VERSION%%.*}/bin/*; do
|
||||
local _basename=${_binary##*/}
|
||||
ln -s ../lib/llvm${BPM_PKG_VERSION%%.*}/bin/"$_basename" "$BPM_OUTPUT"/usr/bin/"$_basename"-${BPM_PKG_VERSION%%.*}
|
||||
done
|
||||
|
||||
# Install package license
|
||||
install -Dm644 "$BPM_SOURCE"/LICENSE.TXT "$BPM_OUTPUT"/usr/share/licenses/llvm${BPM_PKG_VERSION%%.*}/LICENSE.TXT
|
||||
}
|
||||
|
||||
package_llvm21-libs() {
|
||||
# Symlink libraries
|
||||
for lib in libLLVM.so.${BPM_PKG_VERSION%.*} libLLVM-${BPM_PKG_VERSION%%.*}.so; do
|
||||
ln -s llvm${BPM_PKG_VERSION%%.*}/lib/"$lib" "$BPM_OUTPUT"/usr/lib/"$lib"
|
||||
done
|
||||
|
||||
# Install package license
|
||||
install -Dm644 "$BPM_SOURCE"/LICENSE.TXT "$BPM_OUTPUT"/usr/share/licenses/llvm${BPM_PKG_VERSION%%.*}-libs/LICENSE.TXT
|
||||
}
|
||||
|
||||
package_compiler-rt21() {
|
||||
# Install package license
|
||||
install -Dm644 "$BPM_SOURCE"/LICENSE.TXT "$BPM_OUTPUT"/usr/share/licenses/compiler-rt${BPM_PKG_VERSION%%.*}/LICENSE.TXT
|
||||
}
|
||||
|
||||
package_clang21() {
|
||||
# Symlink libraries
|
||||
for lib in libclang-cpp.so.${BPM_PKG_VERSION%.*} libclang.so.${BPM_PKG_VERSION%.*}; do
|
||||
ln -s llvm${BPM_PKG_VERSION%%.*}/lib/"$lib" "$BPM_OUTPUT"/usr/lib/"$lib"
|
||||
done
|
||||
|
||||
# Install package license
|
||||
install -Dm644 "$BPM_SOURCE"/LICENSE.TXT "$BPM_OUTPUT"/usr/share/licenses/clang${BPM_PKG_VERSION%%.*}/LICENSE.TXT
|
||||
}
|
||||
Reference in New Issue
Block a user