diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2026-01-12 21:29:39 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2026-01-12 21:29:39 +0100 |
| commit | 74299c8919cb2e2f6e1678817529e3a730cf6b81 (patch) | |
| tree | d4597faa626ea18eca53b58db9037ffa071a66b9 /build.sh | |
| parent | 9a013b7c68f94e6be0fe8748c9012a441fe0273f (diff) | |
| download | nissy-core-74299c8919cb2e2f6e1678817529e3a730cf6b81.tar.gz nissy-core-74299c8919cb2e2f6e1678817529e3a730cf6b81.zip | |
Automatically detect number of threads for unix systems
Diffstat (limited to 'build.sh')
| -rwxr-xr-x | build.sh | 19 |
1 files changed, 16 insertions, 3 deletions
| @@ -43,10 +43,23 @@ NODE=${NODE-${NISSY_BUILD_NODE:-"node"}} | |||
| 43 | # The default value is 16. | 43 | # The default value is 16. |
| 44 | THREADS=${THREADS-${NISSY_BUILD_THREADS}} | 44 | THREADS=${THREADS-${NISSY_BUILD_THREADS}} |
| 45 | 45 | ||
| 46 | portable_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 | |||
| 46 | detectthreads() { | 61 | detectthreads() { |
| 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)" |
