summaryrefslogtreecommitdiffstats
path: root/BaseTools/Edk2ToolsBuild.py
diff options
context:
space:
mode:
authorSean Brogan <sean.brogan@microsoft.com>2020-04-03 01:04:52 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-04-07 01:22:04 +0000
commit48f0e94921d83b8204f1025412e071b000394f04 (patch)
treeb027c482df75de3a0eca4707ec6b8fa3557cdcf5 /BaseTools/Edk2ToolsBuild.py
parentee026ea78b0e32a9ffbaf0040afe91de8ae2179c (diff)
downloadedk2-48f0e94921d83b8204f1025412e071b000394f04.tar.gz
edk2-48f0e94921d83b8204f1025412e071b000394f04.tar.bz2
edk2-48f0e94921d83b8204f1025412e071b000394f04.zip
BaseTools: Update Edk2ToolsBuild.py to use multiple threads on Linux
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2640 Azure Pipelines agents have 2 threads. This commit has been shown to reduce the build time in half on those agents. Cc: Bob C Feng <bob.c.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Bob C Feng <bob.c.feng@intel.com>
Diffstat (limited to 'BaseTools/Edk2ToolsBuild.py')
-rw-r--r--BaseTools/Edk2ToolsBuild.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/BaseTools/Edk2ToolsBuild.py b/BaseTools/Edk2ToolsBuild.py
index 057d2e9e06..1ea8187de6 100644
--- a/BaseTools/Edk2ToolsBuild.py
+++ b/BaseTools/Edk2ToolsBuild.py
@@ -11,6 +11,7 @@ import os
import sys
import logging
import argparse
+import multiprocessing
from edk2toolext import edk2_logging
from edk2toolext.environment import self_describing_environment
from edk2toolext.base_abstract_invocable import BaseAbstractInvocable
@@ -141,7 +142,8 @@ class Edk2ToolsBuild(BaseAbstractInvocable):
return ret
elif self.tool_chain_tag.lower().startswith("gcc"):
- ret = RunCmd("make", "-C .", workingdir=shell_env.get_shell_var("EDK_TOOLS_PATH"))
+ cpu_count = self.GetCpuThreads()
+ ret = RunCmd("make", f"-C . -j {cpu_count}", workingdir=shell_env.get_shell_var("EDK_TOOLS_PATH"))
if ret != 0:
raise Exception("Failed to build.")
@@ -154,6 +156,18 @@ class Edk2ToolsBuild(BaseAbstractInvocable):
logging.critical("Tool Chain not supported")
return -1
+ def GetCpuThreads(self) -> int:
+ ''' Function to return number of cpus. If error return 1'''
+ cpus = 1
+ try:
+ cpus = multiprocessing.cpu_count()
+ except:
+ # from the internet there are cases where cpu_count is not implemented.
+ # will handle error by just doing single proc build
+ pass
+ return cpus
+
+
def main():
Edk2ToolsBuild().Invoke()