qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: berrange@redhat.com, imammedo@redhat.com, kraxel@redhat.com,
	mst@redhat.com, philmd@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 05/10] roms/edk2-funcs.sh: add the qemu_edk2_get_thread_count() function
Date: Sat,  9 Mar 2019 01:48:21 +0100	[thread overview]
Message-ID: <20190309004826.9027-6-lersek@redhat.com> (raw)
In-Reply-To: <20190309004826.9027-1-lersek@redhat.com>

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>
---
 roms/edk2-funcs.sh | 25 ++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/roms/edk2-funcs.sh b/roms/edk2-funcs.sh
index 22a5dc8f6ab6..7fc62f074c59 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
+}
-- 
2.19.1.3.g30247aa5d201

  parent reply	other threads:[~2019-03-09  0:49 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-09  0:48 [Qemu-devel] [PATCH 00/10] bundle edk2 platform firmware with QEMU Laszlo Ersek
2019-03-09  0:48 ` [Qemu-devel] [PATCH 01/10] roms: lift "edk2-funcs.sh" from "tests/uefi-test-tools/build.sh" Laszlo Ersek
2019-03-10 15:17   ` Philippe Mathieu-Daudé
2019-03-10 17:23     ` Philippe Mathieu-Daudé
2019-03-11 12:07   ` Eric Blake
2019-03-11 12:11     ` Eric Blake
2019-03-09  0:48 ` [Qemu-devel] [PATCH 02/10] roms/edk2-funcs.sh: require gcc-4.8+ for building i386 and x86_64 Laszlo Ersek
2019-03-10 15:11   ` Philippe Mathieu-Daudé
2019-03-09  0:48 ` [Qemu-devel] [PATCH 03/10] tests/uefi-test-tools/build.sh: work around TianoCore#1607 Laszlo Ersek
2019-03-09  0:48 ` [Qemu-devel] [PATCH 04/10] roms/edk2: advance to tag edk2-stable201903 Laszlo Ersek
2019-03-10 22:10   ` Philippe Mathieu-Daudé
2019-03-09  0:48 ` Laszlo Ersek [this message]
2019-03-10 15:13   ` [Qemu-devel] [PATCH 05/10] roms/edk2-funcs.sh: add the qemu_edk2_get_thread_count() function Philippe Mathieu-Daudé
2019-03-09  0:48 ` [Qemu-devel] [PATCH 06/10] roms/Makefile: replace the $(EFIROM) target with "edk2-basetools" Laszlo Ersek
2019-03-09  1:32   ` Philippe Mathieu-Daudé
2019-03-09  1:53     ` Philippe Mathieu-Daudé
2019-03-10 15:16       ` Philippe Mathieu-Daudé
2019-03-09  0:48 ` [Qemu-devel] [PATCH 07/10] roms: build edk2 firmware binaries and variable store templates Laszlo Ersek
2019-03-09 16:48   ` Philippe Mathieu-Daudé
2019-03-10 15:10     ` Philippe Mathieu-Daudé
2019-03-11 12:09       ` Eric Blake
2019-03-10 11:26   ` Philippe Mathieu-Daudé
2019-03-09  0:48 ` [Qemu-devel] [PATCH 08/10] pc-bios: add " Laszlo Ersek
2019-03-09  0:48 ` [Qemu-devel] [PATCH 09/10] pc-bios: document the edk2 firmware images; add firmware descriptors Laszlo Ersek
2019-03-09  0:48 ` [Qemu-devel] [PATCH 10/10] Makefile: install the edk2 firmware images and their descriptors Laszlo Ersek
2019-03-09  1:20 ` [Qemu-devel] [PATCH 00/10] bundle edk2 platform firmware with QEMU Philippe Mathieu-Daudé
2019-03-11 10:28   ` Daniel P. Berrangé
2019-03-11 12:57     ` Michael S. Tsirkin
2019-03-11 13:00       ` Daniel P. Berrangé
2019-03-11 13:04         ` Michael S. Tsirkin
2019-03-11 13:15       ` Philippe Mathieu-Daudé
2019-03-09 13:10 ` Michal Prívozník
2019-03-11 10:23   ` Daniel P. Berrangé
2019-03-10  3:56 ` Michael S. Tsirkin
2019-03-10 11:21   ` Philippe Mathieu-Daudé
2019-03-11 10:35     ` Daniel P. Berrangé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190309004826.9027-6-lersek@redhat.com \
    --to=lersek@redhat.com \
    --cc=berrange@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=mst@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).