Browse Source

Enable make image multicore

bryan 2 years ago
parent
commit
ba2382ba4c
1 changed files with 8 additions and 5 deletions
  1. 8 5
      openwrtbuilder

+ 8 - 5
openwrtbuilder

@@ -263,8 +263,6 @@ sshBackup() {
 makeImage() {
     debug "${FUNCNAME[0]}"
 
-    declare _nprocs
-
     # Reuse the existing output
     if [[ -d "${P_ARR[out_bin_dir]}" ]]; then
         if askOk "${P_ARR[out_bin_dir]} exists. Rebuild?"; then
@@ -276,9 +274,14 @@ makeImage() {
 
     [[ ! -d "${P_ARR[out_bin_dir]}" ]] && mkdir -p "${P_ARR[out_bin_dir]}"
 
-    # build image
-    debug "make image BIN_DIR=${P_ARR[out_bin_dir]} PROFILE=${P_ARR[profile]} PACKAGES=${P_ARR[packages]} FILES=$FILESDIR --directory=${P_ARR[source_dir]} > make.log"
-    if ! make image BIN_DIR="${P_ARR[out_bin_dir]}" PROFILE="${P_ARR[profile]}" PACKAGES="${P_ARR[packages]}" FILES="$FILESDIR" --directory="${P_ARR[source_dir]}" > make.log; then
+    if ! make image \
+            BIN_DIR="${P_ARR[out_bin_dir]}" \
+            PROFILE="${P_ARR[profile]}" \
+            PACKAGES="${P_ARR[packages]}" \
+            FILES="$FILESDIR" \
+            --directory="${P_ARR[source_dir]}" \
+            --jobs=$(( $(nproc) - 1 )) \
+            > make.log; then
         echo "Make image failed!"
         exit 1
     fi