Skip to content
Myr

Enable multiple jobs for when build from source

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Peter Dave Hello · committed by Peter Dave Hello · parent f851716 · Browse files · 1 file+36 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+36 added−2 removed

  • other:+36 added−2 removed

1 file+36 added−2 removed

modified:nvm.sh+36 added-2 removed
1229 unmodified lines
1230 if [ "_$NVM_OS" = "_freebsd" ]; then1231 make='gmake'1232 MAKE_CXX="CXX=c++"1233 fi12341235 if [ "_$NVM_OS" = "_linux" ]; then1236 CPU_THREADS="$(grep -c 'core id' /proc/cpuinfo)"1237 elif [ "_$NVM_OS" = "_freebsd" ] || [ "_$NVM_OS" = "_darwin" ]; then1238 CPU_THREADS="$(sysctl -n hw.ncpu)"1239 elif [ "_$NVM_OS" = "_sunos" ]; then1240 CPU_THREADS="$(psrinfo | wc -l)"1241 fi1242 local CPU_THREAD_VALID1243 CPU_THREAD_VALID=$(nvm_is_natural_num $CPU_THREADS)1244 if [ -z "$CPU_THREADS" ] || [ "$CPU_THREAD_VALID" != "true" ] ; then1245 echo "Can not determine how many thread(s) we can use, set to only 1 now." 1>&21246 echo "Please report an issue on GitHub to help us make it better and run it faster on your computer!" 1>&21247 MAKE_JOBS="1"1248 else1249 echo "Detected that you have $CPU_THREADS CPU thread(s)"1250 if [ $CPU_THREADS -gt 2 ]; then1251 MAKE_JOBS=$(($CPU_THREADS - 1))1252 echo "Set the number of jobs to $CPU_THREADS - 1 = $MAKE_JOBS jobs to speed up the build"1253 else1254 MAKE_JOBS=11255 echo "Number of CPU thread(s) less or equal to 2 will have only one job a time for 'make'"1256 fi1257 fi1258 local tmpdir1259 tmpdir="$NVM_DIR/src"1260 local tmptarball1261 tmptarball="$tmpdir/node-$VERSION.tar.gz"
13 unmodified lines
1275 nvm_checksum "$tmptarball" "$sum" && \1276 command tar -xzf "$tmptarball" -C "$tmpdir" && \1277 cd "$tmpdir/node-$VERSION" && \1278 ./configure --prefix="$VERSION_PATH" $ADDITIONAL_PARAMETERS && \1255 $make $MAKE_CXX && \1279 $make -j $MAKE_JOBS $MAKE_CXX && \1280 command rm -f "$VERSION_PATH" 2>/dev/null && \1257 $make $MAKE_CXX install1281 $make -j $MAKE_JOBS $MAKE_CXX install1282 )1283 then1284 if ! nvm_has "npm" ; then1285 echo "Installing npm..."
167 unmodified lines
1453 fi1454 echo "$SANITIZED_PATH" | command sed "s#$HOME#\$HOME#g"1455}14561457nvm_is_natural_num() {1458 echo $1 | command egrep -q '^[0-9]{1,}$' &> /dev/null1459 local IS_NATURAL_NUM=$?1460 if [ "$IS_NATURAL_NUM" = "0" ]; then1461 echo true1462 else1463 echo false1464 fi1465}14661467nvm() {1468 if [ $# -lt 1 ]; then1469 nvm help1470 return
846 unmodified lines