From 29af38b0f8f2aa7b08f61a9df38a59dbc15e9302 Mon Sep 17 00:00:00 2001 From: Yunhua Feng Date: Thu, 11 Jan 2018 17:11:20 +0800 Subject: [PATCH] BaseTools: Enable MAX_CONCURRENT_THREAD_NUMBER = 0 feature when set 'MAX_CONCURRENT_THREAD_NUMBER=0', will auto-detect number of processor threads as MAX_CONCURRENT_THREAD_NUMBER. Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=775 Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng Reviewed-by: Yonghong Zhu --- BaseTools/Source/Python/build/build.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py index 38498046d7..de19756d99 100644 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -2,7 +2,7 @@ # build a platform or a module # # Copyright (c) 2014, Hewlett-Packard Development Company, L.P.
-# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -26,6 +26,7 @@ import platform import traceback import encodings.ascii import itertools +import multiprocessing from struct import * from threading import * @@ -936,7 +937,10 @@ class Build(): self.ThreadNumber = int(self.ThreadNumber, 0) if self.ThreadNumber == 0: - self.ThreadNumber = 1 + try: + self.ThreadNumber = multiprocessing.cpu_count() + except (ImportError, NotImplementedError): + self.ThreadNumber = 1 if not self.PlatformFile: PlatformFile = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM] -- 2.39.2