run.sh: Improve compatibility with other systems (#1332)

* run.sh: Improve compatibility with other systems

For example $OSTYPE is empty in OpenBSD and the script fallsback to Linux option, with nproc isn't present it fails to build.

* Update run.sh

---------

Co-authored-by: Carter Li <CarterLi@users.noreply.github.com>
This commit is contained in:
red-magic 2024-10-10 21:38:49 +06:00 committed by GitHub
parent af09de319b
commit 99c0e9e719
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

28
run.sh
View File

@ -5,18 +5,22 @@ set -e
mkdir -p build/ mkdir -p build/
cd build/ cd build/
if [ -z "${CMAKE_BUILD_TYPE}" ]; then cmake ..
CMAKE_BUILD_TYPE=Release
fi
cmake "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" ..
if [ -z "$OSTYPE" ] || [ "$OSTYPE" = "linux-gnu" ]; then kernel_name="$(uname -s)"
cmake_build_args="-j$(nproc)"
elif [ "$OSTYPE" = "darwin" ]; then case "${kernel_name}" in
cmake_build_args="-j$(sysctl -n hw.ncpu)" "Linux" | "MINGW"*)
else cmake_build_args="-j$(nproc)"
cmake_build_args="" ;;
fi "Darwin" | *"BSD" | "DragonFly")
cmake --build . --target fastfetch ${cmake_build_args} cmake_build_args="-j$(sysctl -n hw.ncpu)"
;;
*)
cmake_build_args=""
;;
esac
cmake --build . --target fastfetch "${cmake_build_args}"
./fastfetch "$@" ./fastfetch "$@"