aboutsummaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2026-01-12 21:29:39 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2026-01-12 21:29:39 +0100
commit74299c8919cb2e2f6e1678817529e3a730cf6b81 (patch)
treed4597faa626ea18eca53b58db9037ffa071a66b9 /build.sh
parent9a013b7c68f94e6be0fe8748c9012a441fe0273f (diff)
downloadnissy-core-74299c8919cb2e2f6e1678817529e3a730cf6b81.tar.gz
nissy-core-74299c8919cb2e2f6e1678817529e3a730cf6b81.zip
Automatically detect number of threads for unix systems
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh19
1 files changed, 16 insertions, 3 deletions
diff --git a/build.sh b/build.sh
index 642f5ca..e4da0b7 100755
--- a/build.sh
+++ b/build.sh
@@ -43,10 +43,23 @@ NODE=${NODE-${NISSY_BUILD_NODE:-"node"}}
43# The default value is 16. 43# The default value is 16.
44THREADS=${THREADS-${NISSY_BUILD_THREADS}} 44THREADS=${THREADS-${NISSY_BUILD_THREADS}}
45 45
46portable_nproc() {
47 OS="$(uname -s)"
48 case "$OS" in
49 "Linux")
50 nproc
51 ;;
52 "Darwin" | "*BSD")
53 sysctl -n hw.ncpu
54 ;;
55 *)
56 echo "32" # A safe, large default
57 ;;
58 esac
59}
60
46detectthreads() { 61detectthreads() {
47 # TODO: detect based on system 62 echo "$(portable_nproc)"
48 # Is 'getconf NPROCESSORD_ONLN' portable? Is it threads or cores?
49 echo "16"
50} 63}
51 64
52[ -z "$THREADS" ] && THREADS="$(detectthreads)" 65[ -z "$THREADS" ] && THREADS="$(detectthreads)"

Generated with cgit - Back to sebastiano.tronto.net