fix CPU_THREADS/CPU_THREAD_VALID/MAKE_JOBS prefix
parent
6320719dd8
commit
e78dc5110e
42
nvm.sh
42
nvm.sh
|
@ -1232,27 +1232,27 @@ nvm_install_node_source() {
|
||||||
MAKE_CXX="CXX=c++"
|
MAKE_CXX="CXX=c++"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$MAKE_JOBS" ]; then
|
if [ -z "$NVM_MAKE_JOBS" ]; then
|
||||||
if [ "_$NVM_OS" = "_linux" ]; then
|
if [ "_$NVM_OS" = "_linux" ]; then
|
||||||
CPU_THREADS="$(grep -c 'core id' /proc/cpuinfo)"
|
NVM_CPU_THREADS="$(grep -c 'core id' /proc/cpuinfo)"
|
||||||
elif [ "_$NVM_OS" = "_freebsd" ] || [ "_$NVM_OS" = "_darwin" ]; then
|
elif [ "_$NVM_OS" = "_freebsd" ] || [ "_$NVM_OS" = "_darwin" ]; then
|
||||||
CPU_THREADS="$(sysctl -n hw.ncpu)"
|
NVM_CPU_THREADS="$(sysctl -n hw.ncpu)"
|
||||||
elif [ "_$NVM_OS" = "_sunos" ]; then
|
elif [ "_$NVM_OS" = "_sunos" ]; then
|
||||||
CPU_THREADS="$(psrinfo | wc -l)"
|
NVM_CPU_THREADS="$(psrinfo | wc -l)"
|
||||||
fi
|
fi
|
||||||
local CPU_THREAD_VALID
|
local NVM_CPU_THREAD_VALID
|
||||||
CPU_THREAD_VALID=$(nvm_is_natural_num $CPU_THREADS)
|
NVM_CPU_THREAD_VALID=$(nvm_is_natural_num $NVM_CPU_THREADS)
|
||||||
if [ -z "$CPU_THREADS" ] || [ "$CPU_THREAD_VALID" != "true" ] ; then
|
if [ -z "$NVM_CPU_THREADS" ] || [ "$NVM_CPU_THREAD_VALID" != "true" ] ; then
|
||||||
echo "Can not determine how many thread(s) we can use, set to only 1 now." 1>&2
|
echo "Can not determine how many thread(s) we can use, set to only 1 now." 1>&2
|
||||||
echo "Please report an issue on GitHub to help us make it better and run it faster on your computer!" 1>&2
|
echo "Please report an issue on GitHub to help us make it better and run it faster on your computer!" 1>&2
|
||||||
MAKE_JOBS="1"
|
NVM_MAKE_JOBS="1"
|
||||||
else
|
else
|
||||||
echo "Detected that you have $CPU_THREADS CPU thread(s)"
|
echo "Detected that you have $NVM_CPU_THREADS CPU thread(s)"
|
||||||
if [ $CPU_THREADS -gt 2 ]; then
|
if [ $NVM_CPU_THREADS -gt 2 ]; then
|
||||||
MAKE_JOBS=$(($CPU_THREADS - 1))
|
NVM_MAKE_JOBS=$(($NVM_CPU_THREADS - 1))
|
||||||
echo "Set the number of jobs to $CPU_THREADS - 1 = $MAKE_JOBS jobs to speed up the build"
|
echo "Set the number of jobs to $NVM_CPU_THREADS - 1 = $NVM_MAKE_JOBS jobs to speed up the build"
|
||||||
else
|
else
|
||||||
MAKE_JOBS=1
|
NVM_MAKE_JOBS=1
|
||||||
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
|
||||||
|
@ -1278,9 +1278,9 @@ nvm_install_node_source() {
|
||||||
command tar -xzf "$tmptarball" -C "$tmpdir" && \
|
command tar -xzf "$tmptarball" -C "$tmpdir" && \
|
||||||
cd "$tmpdir/node-$VERSION" && \
|
cd "$tmpdir/node-$VERSION" && \
|
||||||
./configure --prefix="$VERSION_PATH" $ADDITIONAL_PARAMETERS && \
|
./configure --prefix="$VERSION_PATH" $ADDITIONAL_PARAMETERS && \
|
||||||
$make -j $MAKE_JOBS $MAKE_CXX && \
|
$make -j $NVM_MAKE_JOBS $MAKE_CXX && \
|
||||||
command rm -f "$VERSION_PATH" 2>/dev/null && \
|
command rm -f "$VERSION_PATH" 2>/dev/null && \
|
||||||
$make -j $MAKE_JOBS $MAKE_CXX install
|
$make -j $NVM_MAKE_JOBS $MAKE_CXX install
|
||||||
)
|
)
|
||||||
then
|
then
|
||||||
if ! nvm_has "npm" ; then
|
if ! nvm_has "npm" ; then
|
||||||
|
@ -1583,18 +1583,18 @@ nvm() {
|
||||||
shift
|
shift
|
||||||
if [ "_$1" = "_-j" ]; then
|
if [ "_$1" = "_-j" ]; then
|
||||||
shift
|
shift
|
||||||
local CPU_THREAD_VALID
|
local NVM_CPU_THREAD_VALID
|
||||||
CPU_THREAD_VALID=$(nvm_is_natural_num $1)
|
NVM_CPU_THREAD_VALID=$(nvm_is_natural_num $1)
|
||||||
if [ "$CPU_THREAD_VALID" = "true" ]; then
|
if [ "$NVM_CPU_THREAD_VALID" = "true" ]; then
|
||||||
MAKE_JOBS=$1
|
NVM_MAKE_JOBS=$1
|
||||||
echo "Set number of jobs to $MAKE_JOBS for 'make' utility"
|
echo "Set number of jobs to $MAKE_JOBS for 'make' utility"
|
||||||
else
|
else
|
||||||
unset MAKE_JOBS
|
unset NVM_MAKE_JOBS
|
||||||
echo >&2 "$1 is invalid for CPU threads, should be a natural number"
|
echo >&2 "$1 is invalid for CPU threads, should be a natural number"
|
||||||
fi
|
fi
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
unset MAKE_JOBS
|
unset NVM_MAKE_JOBS
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue