build_all.sh update (#13320)

* Don't overload the system, don't crash when you can't determine the CPU count and don't rely on bash

* Extract to variable

* Limit number of spawned jobs for systems with weak IO

* Use proper arithmetic braces
This commit is contained in:
Clyybber 2020-02-04 21:26:38 +01:00 • committed by GitHub
commit ab525cc48a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,7 +23,7 @@ build_nim_csources_via_script(){
build_nim_csources(){ build_nim_csources(){
# avoid changing dir in case of failure # avoid changing dir in case of failure
( (
if [[ $# -ne 0 ]]; then if [ $# -ne 0 ]; then
# some args were passed (eg: `--cpu i386`), need to call build.sh # some args were passed (eg: `--cpu i386`), need to call build.sh
build_nim_csources_via_script "$@" build_nim_csources_via_script "$@"
else else
@ -33,7 +33,8 @@ build_nim_csources(){
if [ "$unamestr" = 'FreeBSD' ]; then if [ "$unamestr" = 'FreeBSD' ]; then
makeX=gmake makeX=gmake
fi fi
which $makeX && echo_run $makeX -C csources -j -l 80 || build_nim_csources_via_script nCPU=$(nproc 2>/dev/null || sysctl -n hw.logicalcpu 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || 1)
which $makeX && echo_run $makeX -C csources -j $((nCPU + 2)) -l $nCPU || build_nim_csources_via_script
fi fi
) )
# keep $nim_csources in case needed to investigate bootstrap issues # keep $nim_csources in case needed to investigate bootstrap issues