@@ -1200,11 +1200,48 @@ nvm_install_node_binary() {
1200
1200
return 2
1201
1201
}
1202
1202
1203
+ nvm_get_make_jobs () {
1204
+ if nvm_is_natural_num " $1 " ; then
1205
+ NVM_MAKE_JOBS=" $1 "
1206
+ echo " number of \` make\` jobs: $NVM_MAKE_JOBS "
1207
+ return
1208
+ elif [ -n " $1 " ]; then
1209
+ unset NVM_MAKE_JOBS
1210
+ echo >&2 " $1 is invalid for number of \` make\` jobs, must be a natural number"
1211
+ fi
1212
+ local NVM_OS
1213
+ NVM_OS=" $( nvm_get_os) "
1214
+ local NVM_CPU_THREADS
1215
+ if [ " _$NVM_OS " = " _linux" ]; then
1216
+ NVM_CPU_THREADS=" $( grep -c ' core id' /proc/cpuinfo) "
1217
+ elif [ " _$NVM_OS " = " _freebsd" ] || [ " _$NVM_OS " = " _darwin" ]; then
1218
+ NVM_CPU_THREADS=" $( sysctl -n hw.ncpu) "
1219
+ elif [ " _$NVM_OS " = " _sunos" ]; then
1220
+ NVM_CPU_THREADS=" $( psrinfo | wc -l) "
1221
+ fi
1222
+ if ! nvm_is_natural_num " $NVM_CPU_THREADS " ; then
1223
+ echo " Can not determine how many thread(s) we can use, set to only 1 now." >&2
1224
+ echo " Please report an issue on GitHub to help us make it better and run it faster on your computer!" >&2
1225
+ NVM_MAKE_JOBS=1
1226
+ else
1227
+ echo " Detected that you have $NVM_CPU_THREADS CPU thread(s)"
1228
+ if [ $NVM_CPU_THREADS -gt 2 ]; then
1229
+ NVM_MAKE_JOBS=$(( $NVM_CPU_THREADS - 1 ))
1230
+ echo " Set the number of jobs to $NVM_CPU_THREADS - 1 = $NVM_MAKE_JOBS jobs to speed up the build"
1231
+ else
1232
+ NVM_MAKE_JOBS=1
1233
+ echo " Number of CPU thread(s) less or equal to 2 will have only one job a time for 'make'"
1234
+ fi
1235
+ fi
1236
+ }
1237
+
1203
1238
nvm_install_node_source () {
1204
1239
local VERSION
1205
1240
VERSION=" $1 "
1241
+ local NVM_MAKE_JOBS
1242
+ NVM_MAKE_JOBS=" $2 "
1206
1243
local ADDITIONAL_PARAMETERS
1207
- ADDITIONAL_PARAMETERS=" $2 "
1244
+ ADDITIONAL_PARAMETERS=" $3 "
1208
1245
1209
1246
local NVM_ARCH
1210
1247
NVM_ARCH=" $( nvm_get_arch) "
@@ -1232,29 +1269,6 @@ nvm_install_node_source() {
1232
1269
MAKE_CXX=" CXX=c++"
1233
1270
fi
1234
1271
1235
- if [ -z " $NVM_MAKE_JOBS " ]; then
1236
- if [ " _$NVM_OS " = " _linux" ]; then
1237
- NVM_CPU_THREADS=" $( grep -c ' core id' /proc/cpuinfo) "
1238
- elif [ " _$NVM_OS " = " _freebsd" ] || [ " _$NVM_OS " = " _darwin" ]; then
1239
- NVM_CPU_THREADS=" $( sysctl -n hw.ncpu) "
1240
- elif [ " _$NVM_OS " = " _sunos" ]; then
1241
- NVM_CPU_THREADS=" $( psrinfo | wc -l) "
1242
- fi
1243
- if ! nvm_is_natural_num " $NVM_CPU_THREADS " ; then
1244
- echo " Can not determine how many thread(s) we can use, set to only 1 now." 1>&2
1245
- echo " Please report an issue on GitHub to help us make it better and run it faster on your computer!" 1>&2
1246
- NVM_MAKE_JOBS=" 1"
1247
- else
1248
- echo " Detected that you have $NVM_CPU_THREADS CPU thread(s)"
1249
- if [ $NVM_CPU_THREADS -gt 2 ]; then
1250
- NVM_MAKE_JOBS=$(( $NVM_CPU_THREADS - 1 ))
1251
- echo " Set the number of jobs to $NVM_CPU_THREADS - 1 = $NVM_MAKE_JOBS jobs to speed up the build"
1252
- else
1253
- NVM_MAKE_JOBS=1
1254
- echo " Number of CPU thread(s) less or equal to 2 will have only one job a time for 'make'"
1255
- fi
1256
- fi
1257
- fi
1258
1272
local tmpdir
1259
1273
tmpdir=" $NVM_DIR /src"
1260
1274
local tmptarball
@@ -1578,6 +1592,7 @@ nvm() {
1578
1592
1579
1593
local nobinary
1580
1594
nobinary=0
1595
+ local make_jobs
1581
1596
while [ $# -ne 0 ]
1582
1597
do
1583
1598
case " $1 " in
@@ -1587,13 +1602,7 @@ nvm() {
1587
1602
;;
1588
1603
-j)
1589
1604
shift # consume "-j"
1590
- if nvm_is_natural_num " $1 " ; then
1591
- NVM_MAKE_JOBS=$1
1592
- echo " number of \` make\` jobs: $NVM_MAKE_JOBS "
1593
- else
1594
- unset NVM_MAKE_JOBS
1595
- echo >&2 " $1 is invalid for number of \` make\` jobs, must be a natural number"
1596
- fi
1605
+ nvm_get_make_jobs " $1 "
1597
1606
shift # consume job count
1598
1607
;;
1599
1608
* )
@@ -1693,15 +1702,15 @@ nvm() {
1693
1702
fi
1694
1703
if [ " $NVM_INSTALL_SUCCESS " != true ]; then
1695
1704
if [ " $NVM_IOJS " != true ] && [ " $NVM_NODE_MERGED " != true ]; then
1696
- if nvm_install_node_source " $VERSION " " $ADDITIONAL_PARAMETERS " ; then
1705
+ if nvm_install_node_source " $VERSION " " $NVM_MAKE_JOBS " " $ ADDITIONAL_PARAMETERS" ; then
1697
1706
NVM_INSTALL_SUCCESS=true
1698
1707
fi
1699
1708
elif [ " $NVM_IOJS " = true ]; then
1700
- # nvm_install_iojs_source "$VERSION" "$ADDITIONAL_PARAMETERS"
1709
+ # nvm_install_iojs_source "$VERSION" "$NVM_MAKE_JOBS" "$ ADDITIONAL_PARAMETERS"
1701
1710
echo " Installing iojs from source is not currently supported" >&2
1702
1711
return 105
1703
1712
elif [ " $NVM_NODE_MERGED " = true ]; then
1704
- # nvm_install_merged_node_source "$VERSION" "$ADDITIONAL_PARAMETERS"
1713
+ # nvm_install_merged_node_source "$VERSION" "$NVM_MAKE_JOBS" "$ ADDITIONAL_PARAMETERS"
1705
1714
echo " Installing node v1.0 and greater from source is not currently supported" >&2
1706
1715
return 106
1707
1716
fi
0 commit comments