Skip to content

Commit 99c0e9e

Browse files
red-magicCarterLi
andauthored
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 <[email protected]>
1 parent af09de3 commit 99c0e9e

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

run.sh

+16-12
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,22 @@ set -e
55
mkdir -p build/
66
cd build/
77

8-
if [ -z "${CMAKE_BUILD_TYPE}" ]; then
9-
CMAKE_BUILD_TYPE=Release
10-
fi
11-
cmake "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" ..
8+
cmake ..
129

13-
if [ -z "$OSTYPE" ] || [ "$OSTYPE" = "linux-gnu" ]; then
14-
cmake_build_args="-j$(nproc)"
15-
elif [ "$OSTYPE" = "darwin" ]; then
16-
cmake_build_args="-j$(sysctl -n hw.ncpu)"
17-
else
18-
cmake_build_args=""
19-
fi
20-
cmake --build . --target fastfetch ${cmake_build_args}
10+
kernel_name="$(uname -s)"
11+
12+
case "${kernel_name}" in
13+
"Linux" | "MINGW"*)
14+
cmake_build_args="-j$(nproc)"
15+
;;
16+
"Darwin" | *"BSD" | "DragonFly")
17+
cmake_build_args="-j$(sysctl -n hw.ncpu)"
18+
;;
19+
*)
20+
cmake_build_args=""
21+
;;
22+
esac
23+
24+
cmake --build . --target fastfetch "${cmake_build_args}"
2125

2226
./fastfetch "$@"

0 commit comments

Comments
 (0)