BaseTools: AutoGen refactor to iterate less

Don't iterate over new dictionaries with one item

Create the data and then add to dictionary.

Note: if you diff ignoring whitespace changes you
can more easily see the relevant changes.

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>
This commit is contained in:
Jaben Carsey 2018-08-03 23:11:08 +08:00 committed by Yonghong Zhu
parent 830bf22fa5
commit 0258ba6256
1 changed files with 56 additions and 62 deletions

View File

@ -2855,16 +2855,13 @@ class ModuleAutoGen(AutoGen):
if self.DxsFile or self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes: if self.DxsFile or self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes:
return {} return {}
RetVal = {self.ModuleType:[]} DepexList = []
for ModuleType in RetVal:
DepexList = RetVal[ModuleType]
# #
# Append depex from dependent libraries, if not "BEFORE", "AFTER" expresion # Append depex from dependent libraries, if not "BEFORE", "AFTER" expresion
# #
for M in [self.Module] + self.DependentLibraryList: for M in [self.Module] + self.DependentLibraryList:
Inherited = False Inherited = False
for D in M.Depex[self.Arch, ModuleType]: for D in M.Depex[self.Arch, self.ModuleType]:
if DepexList != []: if DepexList != []:
DepexList.append('AND') DepexList.append('AND')
DepexList.append('(') DepexList.append('(')
@ -2893,7 +2890,7 @@ class ModuleAutoGen(AutoGen):
break break
if len(DepexList) > 0: if len(DepexList) > 0:
EdkLogger.verbose('') EdkLogger.verbose('')
return RetVal return {self.ModuleType:DepexList}
## Merge dependency expression ## Merge dependency expression
# #
@ -2904,16 +2901,13 @@ class ModuleAutoGen(AutoGen):
if self.DxsFile or self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes: if self.DxsFile or self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes:
return {} return {}
RetVal = {self.ModuleType:''} DepexExpressionString = ''
for ModuleType in RetVal:
DepexExpressionString = RetVal[ModuleType]
# #
# Append depex from dependent libraries, if not "BEFORE", "AFTER" expresion # Append depex from dependent libraries, if not "BEFORE", "AFTER" expresion
# #
for M in [self.Module] + self.DependentLibraryList: for M in [self.Module] + self.DependentLibraryList:
Inherited = False Inherited = False
for D in M.DepexExpression[self.Arch, ModuleType]: for D in M.DepexExpression[self.Arch, self.ModuleType]:
if DepexExpressionString != '': if DepexExpressionString != '':
DepexExpressionString += ' AND ' DepexExpressionString += ' AND '
DepexExpressionString += '(' DepexExpressionString += '('
@ -2927,8 +2921,8 @@ class ModuleAutoGen(AutoGen):
break break
if len(DepexExpressionString) > 0: if len(DepexExpressionString) > 0:
EdkLogger.verbose('') EdkLogger.verbose('')
RetVal[ModuleType] = DepexExpressionString
return RetVal return {self.ModuleType:DepexExpressionString}
# Get the tiano core user extension, it is contain dependent library. # Get the tiano core user extension, it is contain dependent library.
# @retval: a list contain tiano core userextension. # @retval: a list contain tiano core userextension.