aboutsummaryrefslogtreecommitdiff
path: root/roms
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2019-03-07 13:15:20 +0100
committerLaszlo Ersek <lersek@redhat.com>2019-04-17 15:38:35 +0200
commitfd75d2c2ee5c2b4ee965561f214273e63722f413 (patch)
tree2e447298e692d04e4b006c0e9e3569381d1ce063 /roms
parentb9a4c15164876ed292018f34d4b22bc7d5eb1de7 (diff)
roms/edk2-funcs.sh: add the qemu_edk2_get_thread_count() function
The edk2 "build" utility natively supports building modules (that is, INF files) in parallel. The feature is not useful when building a single module (with the "-m" option), but it is useful for platform firmware builds (which include many modules). Add a function that determines the "-n" option argument for "build", from the MAKEFLAGS variable (i.e. based on the presence of a make job server). Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Tested-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Diffstat (limited to 'roms')
-rw-r--r--roms/edk2-funcs.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/roms/edk2-funcs.sh b/roms/edk2-funcs.sh
index d1cb1e4a11..a9fae7ee89 100644
--- a/roms/edk2-funcs.sh
+++ b/roms/edk2-funcs.sh
@@ -226,3 +226,28 @@ qemu_edk2_set_cross_env()
eval "export $cross_prefix_var=\$cross_prefix"
}
+
+
+# Determine the "-n" option argument (that is, the number of modules to build
+# in parallel) for the edk2 "build" utility. Print the result to the standard
+# output.
+#
+# Parameters:
+# $1: the value of the MAKEFLAGS variable
+qemu_edk2_get_thread_count()
+{
+ local makeflags="$1"
+
+ if [[ "$makeflags" == *--jobserver-auth=* ]] ||
+ [[ "$makeflags" == *--jobserver-fds=* ]]; then
+ # If there is a job server, allow the edk2 "build" utility to parallelize
+ # as many module builds as there are logical CPUs in the system. The "make"
+ # instances forked by "build" are supposed to limit themselves through the
+ # job server. The zero value below causes the edk2 "build" utility to fetch
+ # the logical CPU count with Python's multiprocessing.cpu_count() method.
+ printf '0\n'
+ else
+ # Build a single module at a time.
+ printf '1\n'
+ fi
+}