From 5cf27fc5e85893c193933621d5c32e7cc75cc754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20Frohm=C3=BCller?= Date: Sun, 4 Dec 2022 22:28:25 +0100 Subject: [PATCH] More minor improvements to scripts. --- build.sh | 10 +++++++--- install.sh | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/build.sh b/build.sh index b08fff2..19a095f 100755 --- a/build.sh +++ b/build.sh @@ -1,7 +1,7 @@ [ ! -d build ] && mkdir build echo "Configuring..." -cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./Release +cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./Release $@ if [ $? -ne 0 ]; then echo "CMake failed. Aborting." @@ -10,9 +10,13 @@ else echo "CMake succeeded." fi -echo "Building..." +if [ -z "$THREADS" ]; then + THREADS=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1) +fi + +echo "Building with $THREADS threads..." cd build -make +make -j$THREADS if [ $? -ne 0 ]; then echo "Build failed. Aborting." diff --git a/install.sh b/install.sh index 5e512eb..1c05180 100755 --- a/install.sh +++ b/install.sh @@ -1,7 +1,7 @@ [ ! -d build ] && mkdir build echo "Configuring..." -cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/ +cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/ $@ if [ $? -ne 0 ]; then echo "CMake failed. Aborting." @@ -10,9 +10,13 @@ else echo "CMake succeeded." fi -echo "Building..." +if [ -z "$THREADS" ]; then + THREADS=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1) +fi + +echo "Building with $THREADS threads..." cd build -make +make -j$THREADS if [ $? -ne 0 ]; then echo "Build failed. Aborting."