Support parameter -j to set jobs for make

Peter Dave Hello 2015-12-05 15:22:06 +08:00
parent a8e6fee001
commit 6320719dd8
1 changed files with 37 additions and 20 deletions

17
nvm.sh
View File

@ -1232,6 +1232,7 @@ nvm_install_node_source() {
MAKE_CXX="CXX=c++" MAKE_CXX="CXX=c++"
fi fi
if [ -z "$MAKE_JOBS" ]; then
if [ "_$NVM_OS" = "_linux" ]; then if [ "_$NVM_OS" = "_linux" ]; then
CPU_THREADS="$(grep -c 'core id' /proc/cpuinfo)" CPU_THREADS="$(grep -c 'core id' /proc/cpuinfo)"
elif [ "_$NVM_OS" = "_freebsd" ] || [ "_$NVM_OS" = "_darwin" ]; then elif [ "_$NVM_OS" = "_freebsd" ] || [ "_$NVM_OS" = "_darwin" ]; then
@ -1255,6 +1256,7 @@ nvm_install_node_source() {
echo "Number of CPU thread(s) less or equal to 2 will have only one job a time for 'make'" echo "Number of CPU thread(s) less or equal to 2 will have only one job a time for 'make'"
fi fi
fi fi
fi
local tmpdir local tmpdir
tmpdir="$NVM_DIR/src" tmpdir="$NVM_DIR/src"
local tmptarball local tmptarball
@ -1579,6 +1581,21 @@ nvm() {
if [ "_$1" = "_-s" ]; then if [ "_$1" = "_-s" ]; then
nobinary=1 nobinary=1
shift shift
if [ "_$1" = "_-j" ]; then
shift
local CPU_THREAD_VALID
CPU_THREAD_VALID=$(nvm_is_natural_num $1)
if [ "$CPU_THREAD_VALID" = "true" ]; then
MAKE_JOBS=$1
echo "Set number of jobs to $MAKE_JOBS for 'make' utility"
else
unset MAKE_JOBS
echo >&2 "$1 is invalid for CPU threads, should be a natural number"
fi
shift
else
unset MAKE_JOBS
fi
fi fi
provided_version="$1" provided_version="$1"