Provide option to define max cpus for build

By default this script uses the total number of processing units
in the system. In a lot of situations, there are multiple instances
of this script running on one system so it would be more efficient
to limit the total number of processing units each build gets.

Change-Id: I77d948a82b1b77e499e267440ec47f03b121ccd5
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/build-setup.sh b/build-setup.sh
index d62e972..19fab9f 100755
--- a/build-setup.sh
+++ b/build-setup.sh
@@ -14,6 +14,8 @@
 #  WORKSPACE          Path of the workspace directory where some intermediate
 #                     files and the images will be saved to.
 #                     Default: "~/{RandomNumber}"
+#  num_cpu            Number of cpu's to give bitbake, default is total amount
+#                     in system
 #
 # Docker Image Build Variables:
 #  BITBAKE_OPTS       Set to "-c populate_sdk" or whatever other BitBake options
@@ -61,6 +63,7 @@
 build_scripts_dir=${build_scripts_dir:-"$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"}
 http_proxy=${http_proxy:-}
 WORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}}
+num_cpu=${num_cpu:-$(nproc)}
 
 # Docker Image Build Variables:
 build_dir=${build_dir:-/tmp/openbmc}
@@ -342,6 +345,7 @@
   -v "${HOME}":"${HOME}" \
   ${mount_obmc_dir} \
   ${mount_ssc_dir} \
+  --cpus="$num_cpu" \
   -t ${img_name} \
   ${WORKSPACE}/build.sh