summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/build/build.py
diff options
context:
space:
mode:
authorCarsey, Jaben <jaben.carsey@intel.com>2018-04-17 22:40:15 +0800
committerYonghong Zhu <yonghong.zhu@intel.com>2018-04-18 22:15:36 +0800
commit9eb87141eca12b1f15afa4b769af04d1395891c6 (patch)
tree82ac481092b68ea3684f94bf7dc90c3c584aea52 /BaseTools/Source/Python/build/build.py
parent55c84777ee638be8735a5c421941e7eb71633bdf (diff)
downloadedk2-9eb87141eca12b1f15afa4b769af04d1395891c6.tar.gz
edk2-9eb87141eca12b1f15afa4b769af04d1395891c6.tar.bz2
edk2-9eb87141eca12b1f15afa4b769af04d1395891c6.zip
BaseTools: refactor and remove un-needed use of .keys() on dictionaries
sometimes just delete it. sometimes the loop needed .values() instead Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/build/build.py')
-rw-r--r--BaseTools/Source/Python/build/build.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index ede963bc23..36bb1fecf7 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -53,7 +53,7 @@ import Common.EdkLogger
import Common.GlobalData as GlobalData
from GenFds.GenFds import GenFds
-from collections import OrderedDict
+from collections import OrderedDict,defaultdict
# Version and Copyright
VersionNumber = "0.60" + ' ' + gBUILD_VERSION
@@ -524,8 +524,7 @@ class BuildTask:
BuildTask._Thread.acquire(True)
# start a new build thread
- Bo = BuildTask._ReadyQueue.keys()[0]
- Bt = BuildTask._ReadyQueue.pop(Bo)
+ Bo,Bt = BuildTask._ReadyQueue.popitem()
# move into running queue
BuildTask._RunningQueueLock.acquire()
@@ -1000,7 +999,7 @@ class Build():
GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = self.ToolChainList[0]
if self.ToolChainFamily:
GlobalData.gGlobalDefines['FAMILY'] = self.ToolChainFamily[0]
- if 'PREBUILD' in GlobalData.gCommandLineDefines.keys():
+ if 'PREBUILD' in GlobalData.gCommandLineDefines:
self.Prebuild = GlobalData.gCommandLineDefines.get('PREBUILD')
else:
self.Db.InitDatabase()
@@ -1041,7 +1040,7 @@ class Build():
self.Prebuild += self.PassCommandOption(self.BuildTargetList, self.ArchList, self.ToolChainList, self.PlatformFile, self.Target)
def InitPostBuild(self):
- if 'POSTBUILD' in GlobalData.gCommandLineDefines.keys():
+ if 'POSTBUILD' in GlobalData.gCommandLineDefines:
self.Postbuild = GlobalData.gCommandLineDefines.get('POSTBUILD')
else:
Platform = self.Db._MapPlatform(str(self.PlatformFile))
@@ -1524,7 +1523,7 @@ class Build():
# First get the XIP base address for FV map file.
GuidPattern = re.compile("[-a-fA-F0-9]+")
GuidName = re.compile("\(GUID=[-a-fA-F0-9]+")
- for FvName in Wa.FdfProfile.FvDict.keys():
+ for FvName in Wa.FdfProfile.FvDict:
FvMapBuffer = os.path.join(Wa.FvDir, FvName + '.Fv.map')
if not os.path.exists(FvMapBuffer):
continue
@@ -1961,15 +1960,14 @@ class Build():
self._SaveMapFile (MapBuffer, Wa)
def _GenFfsCmd(self):
- CmdListDict = {}
+ # convert dictionary of Cmd:(Inf,Arch)
+ # to a new dictionary of (Inf,Arch):Cmd,Cmd,Cmd...
+ CmdSetDict = defaultdict(set)
GenFfsDict = GenFds.GenFfsMakefile('', GlobalData.gFdfParser, self, self.ArchList, GlobalData)
for Cmd in GenFfsDict:
tmpInf, tmpArch = GenFfsDict[Cmd]
- if (tmpInf, tmpArch) not in CmdListDict.keys():
- CmdListDict[tmpInf, tmpArch] = [Cmd]
- else:
- CmdListDict[tmpInf, tmpArch].append(Cmd)
- return CmdListDict
+ CmdSetDict[tmpInf, tmpArch].add(Cmd)
+ return CmdSetDict
## Build a platform in multi-thread mode
#