summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xPKGBUILD13
-rwxr-xr-xcompile.bash128
2 files changed, 85 insertions, 56 deletions
diff --git a/PKGBUILD b/PKGBUILD
index 2e217c6dcbbf..ccb8f386b0dc 100755
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -26,12 +26,12 @@ optdepends=(
'nvidia-utils: NVIDIA support')
provides=('alchemy-viewer')
replaces=('alchemy-next-viewer-git')
-options=(!emptydirs !makeflags !strip !lto)
+options+=(!emptydirs !buildflags !strip !lto)
install=alchemy.install
source=("${pkgname}"::'git+https://git.alchemyviewer.org/alchemy/alchemy-next.git#branch='"${AL_BRANCH_OVERRIDE:-main}"
'compile.bash')
b2sums=('SKIP'
- '67d8687b690f40a391b3374c1c7bb8d3ff9ea488b9b67742b92079c00ff43e091a80e281fcf81a62dd0b8c4f35aedc385593ac48f6dce0298440285c296058ed')
+ '3e2b3c952ddb353e159f9f65565fb6838428e39bda0fa062019cfde9158d36f6aaff71a52b13e39fe25e8cd98f8a11097f0d59b152c58dedbb951aae3f9c71f6')
pkgver() {
cd "${pkgname}" || exit 1
@@ -43,11 +43,18 @@ pkgver() {
prepare() {
cd "${pkgname}" || exit 1
+ ../../compile.bash prepare
}
build() {
cd "${pkgname}" || exit 1
- ../../compile.bash "${OPTIONS}"
+ # I could not find the documentation on how to handle BUILDENV/OPTION in
+ # makepkg.conf. If you are reading this and know where it is,
+ # please send it my way.
+ if ! command -v ccache > /dev/null 2>&1; then
+ export AL_NOCCACHE=1
+ fi
+ ../../compile.bash build
}
package() {
diff --git a/compile.bash b/compile.bash
index 795dfb9f3301..4e915121d973 100755
--- a/compile.bash
+++ b/compile.bash
@@ -1,60 +1,82 @@
#!/usr/bin/env bash
set -e
-virtualenv ".venv" -p python3
-. ".venv/bin/activate"
-echo "Installing autobuild..."
-pip install --upgrade certifi --quiet
-pip3 install --upgrade llbase --quiet
-if command -v autobuild >/dev/null 2>&1 && [[ "$(autobuild --version)" == "autobuild 9.0.0" ]]; then
- pip3 uninstall --yes autobuild --quiet
-fi
-pip3 install --no-cache --upgrade autobuild --quiet
-# we have a lot of files, relax ulimit to help performance
-ulimit -n 20000
-build_jobs=$(nproc)
-if [[ ${build_jobs} -gt 1 ]]; then
- # The viewer requires an average of 4GB of memory per core to link
- mempercorekb=$((4 * 1048576))
- requiredmemorykb=$(($(nproc) * mempercorekb))
- # Source: Total Used Free
- free_output="$(free --kilo --total | tr -s ' ')"
- totalmemorykb=$(grep Total <<< "$free_output" | cut -d ' ' -f 2)
- freememorykb=$(grep Total <<< "$free_output" | cut -d ' ' -f 4)
- #echo "Total memory: $totalmemorykb (includes swap)"
- #echo "Free memory: $freememorykb"
- #echo "Required memory: $requiredmemorykb"
- if [[ ${requiredmemorykb} -gt ${totalmemorykb} ]]; then
- echo "Not enough physical memory to build with all cores, adjusting"
- echo "Estimated required memory to build with all cores: $((requiredmemorykb/1024/1024)) GB"
- if [[ ${requiredmemorykb} -gt ${freememorykb} ]]; then
- jobs=1
- echo "Allocating build jobs according to available memory (${freememorykb}/${requiredmemorykb})..."
- while [[ $((jobs * mempercorekb)) -lt ${freememorykb} ]]; do
- jobs=$((jobs+1))
- echo -e "${jobs}...$(((jobs * mempercorekb)/1024/1024))GB"
- done
- build_jobs=${jobs}
- fi
- fi
-fi
-if pacman -Qq ccache &> /dev/null; then
- export PATH="/usr/lib/ccache/bin/:$PATH"
- export CCACHE_SLOPPINESS="file_macro,locale,time_macros"
- export CCACHE_NOHASHDIR="true"
-fi
-export AUTOBUILD_CPU_COUNT=$build_jobs
-prefix_cmd=
if command -v schedtool >/dev/null 2>&1; then
prefix_cmd='schedtool -B -n1 -e'
fi
-$prefix_cmd ionice -n 1 autobuild configure -A 64 -c ReleaseOS -- \
- -DLL_TESTS:BOOL=OFF \
- -DDISABLE_FATAL_WARNINGS=ON \
- -DUSE_LTO:BOOL=OFF \
- -DDCMAKE_CXX_FLAGS="-march=x86-64-v2 -mtune=native" \
- -DVIEWER_CHANNEL="Alchemy Test"
-unset prefix_cmd
+prefix_cmd="${prefix_cmd} ionice -n 1"
+
+prepare() {
+ virtualenv ".venv" -p python3
+ . ".venv/bin/activate"
+ echo "Installing autobuild..."
+ pip install --upgrade certifi --quiet
+ pip3 install --upgrade llbase --quiet
+ if command -v autobuild >/dev/null 2>&1 && [[ "$(autobuild --version)" == "autobuild 9.0.0" ]]; then
+ pip3 uninstall --yes autobuild --quiet
+ fi
+ pip3 install --no-cache --upgrade autobuild --quiet
+}
-echo "Building with ${AUTOBUILD_CPU_COUNT} jobs (adjusted)"
-$prefix_cmd ionice -n 1 autobuild build -A64 -c ReleaseOS --no-configure
+build() {
+ . ".venv/bin/activate"
+ # we have a lot of files, relax ulimit to help performance
+ ulimit -n 20000
+ build_jobs=$(nproc)
+ if [[ ${build_jobs} -gt 1 ]]; then
+ # The viewer requires an average of 4GB of memory per core to link
+ mempercorekb=$((4 * 1048576))
+ requiredmemorykb=$(($(nproc) * mempercorekb))
+ # Source: Total Used Free
+ free_output="$(free --kilo --total | tr -s ' ')"
+ totalmemorykb=$(grep Total <<< "$free_output" | cut -d ' ' -f 2)
+ freememorykb=$(grep Total <<< "$free_output" | cut -d ' ' -f 4)
+ #echo "Total memory: $totalmemorykb (includes swap)"
+ #echo "Free memory: $freememorykb"
+ #echo "Required memory: $requiredmemorykb"
+ if [[ ${requiredmemorykb} -gt ${totalmemorykb} ]]; then
+ echo "Not enough physical memory to build with all cores, adjusting"
+ echo "Estimated required memory to build with all cores: $((requiredmemorykb/1024/1024)) GB"
+ if [[ ${requiredmemorykb} -gt ${freememorykb} ]]; then
+ jobs=1
+ echo "Allocating build jobs according to available memory (${freememorykb}/${requiredmemorykb})..."
+ while [[ $((jobs * mempercorekb)) -lt ${freememorykb} ]]; do
+ jobs=$((jobs+1))
+ echo -e "${jobs}...$(((jobs * mempercorekb)/1024/1024))GB"
+ done
+ build_jobs=${jobs}
+ fi
+ fi
+ fi
+ if pacman -Qq ccache &> /dev/null; then
+ export PATH="/usr/lib/ccache/bin/:$PATH"
+ export CCACHE_SLOPPINESS="file_macro,locale,time_macros"
+ export CCACHE_NOHASHDIR="true"
+ fi
+ export AUTOBUILD_CPU_COUNT=$build_jobs
+
+ AL_ARCH_FLAGS=${AL_ARCH_FLAGS:-'-march=x86-64-v2 -mtune=native'}
+ AL_CMAKE_CONFIG=(
+ -DLL_TESTS:BOOL=OFF
+ -DDISABLE_FATAL_WARNINGS=ON
+ -DUSE_LTO:BOOL=OFF
+ -DVIEWER_CHANNEL="Alchemy Test"
+ -DCMAKE_C_FLAGS="$AL_ARCH_FLAGS"
+ -DCMAKE_CXX_FLAGS="$AL_ARCH_FLAGS"
+ )
+ if [[ -z "$AL_NO_CCACHE" ]]; then
+ ccache --set-config=sloppiness=file_macro,locale,time_macros
+ AL_CMAKE_CONFIG+=(-DCMAKE_CXX_COMPILER_LAUNCHER=ccache)
+ fi
+ $prefix_cmd autobuild configure -A 64 -c ReleaseOS -- "${AL_CMAKE_CONFIG[@]}"
+
+ echo "Building with ${AUTOBUILD_CPU_COUNT} jobs (adjusted)"
+ $prefix_cmd autobuild build -A64 -c ReleaseOS --no-configure
+}
+if [[ -n "$1" ]]; then
+ $1
+else
+ echo "Running unattended batch build..."
+ prepare
+ build
+fi