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

View File

@ -2855,45 +2855,42 @@ 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: # Append depex from dependent libraries, if not "BEFORE", "AFTER" expresion
DepexList = RetVal[ModuleType] #
# for M in [self.Module] + self.DependentLibraryList:
# Append depex from dependent libraries, if not "BEFORE", "AFTER" expresion Inherited = False
# for D in M.Depex[self.Arch, self.ModuleType]:
for M in [self.Module] + self.DependentLibraryList: if DepexList != []:
Inherited = False DepexList.append('AND')
for D in M.Depex[self.Arch, ModuleType]: DepexList.append('(')
if DepexList != []: #replace D with value if D is FixedAtBuild PCD
DepexList.append('AND') NewList = []
DepexList.append('(') for item in D:
#replace D with value if D is FixedAtBuild PCD if '.' not in item:
NewList = [] NewList.append(item)
for item in D: else:
if '.' not in item: if item not in self._FixedPcdVoidTypeDict:
NewList.append(item) EdkLogger.error("build", FORMAT_INVALID, "{} used in [Depex] section should be used as FixedAtBuild type and VOID* datum type in the module.".format(item))
else: else:
if item not in self._FixedPcdVoidTypeDict: Value = self._FixedPcdVoidTypeDict[item]
EdkLogger.error("build", FORMAT_INVALID, "{} used in [Depex] section should be used as FixedAtBuild type and VOID* datum type in the module.".format(item)) if len(Value.split(',')) != 16:
else: EdkLogger.error("build", FORMAT_INVALID,
Value = self._FixedPcdVoidTypeDict[item] "{} used in [Depex] section should be used as FixedAtBuild type and VOID* datum type and 16 bytes in the module.".format(item))
if len(Value.split(',')) != 16: NewList.append(Value)
EdkLogger.error("build", FORMAT_INVALID, DepexList.extend(NewList)
"{} used in [Depex] section should be used as FixedAtBuild type and VOID* datum type and 16 bytes in the module.".format(item)) if DepexList[-1] == 'END': # no need of a END at this time
NewList.append(Value) DepexList.pop()
DepexList.extend(NewList) DepexList.append(')')
if DepexList[-1] == 'END': # no need of a END at this time Inherited = True
DepexList.pop() if Inherited:
DepexList.append(')') EdkLogger.verbose("DEPEX[%s] (+%s) = %s" % (self.Name, M.BaseName, DepexList))
Inherited = True if 'BEFORE' in DepexList or 'AFTER' in DepexList:
if Inherited: break
EdkLogger.verbose("DEPEX[%s] (+%s) = %s" % (self.Name, M.BaseName, DepexList)) if len(DepexList) > 0:
if 'BEFORE' in DepexList or 'AFTER' in DepexList: EdkLogger.verbose('')
break return {self.ModuleType:DepexList}
if len(DepexList) > 0:
EdkLogger.verbose('')
return RetVal
## Merge dependency expression ## Merge dependency expression
# #
@ -2904,31 +2901,28 @@ 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 = ''
#
# Append depex from dependent libraries, if not "BEFORE", "AFTER" expresion
#
for M in [self.Module] + self.DependentLibraryList:
Inherited = False
for D in M.DepexExpression[self.Arch, self.ModuleType]:
if DepexExpressionString != '':
DepexExpressionString += ' AND '
DepexExpressionString += '('
DepexExpressionString += D
DepexExpressionString = DepexExpressionString.rstrip('END').strip()
DepexExpressionString += ')'
Inherited = True
if Inherited:
EdkLogger.verbose("DEPEX[%s] (+%s) = %s" % (self.Name, M.BaseName, DepexExpressionString))
if 'BEFORE' in DepexExpressionString or 'AFTER' in DepexExpressionString:
break
if len(DepexExpressionString) > 0:
EdkLogger.verbose('')
for ModuleType in RetVal: return {self.ModuleType:DepexExpressionString}
DepexExpressionString = RetVal[ModuleType]
#
# Append depex from dependent libraries, if not "BEFORE", "AFTER" expresion
#
for M in [self.Module] + self.DependentLibraryList:
Inherited = False
for D in M.DepexExpression[self.Arch, ModuleType]:
if DepexExpressionString != '':
DepexExpressionString += ' AND '
DepexExpressionString += '('
DepexExpressionString += D
DepexExpressionString = DepexExpressionString.rstrip('END').strip()
DepexExpressionString += ')'
Inherited = True
if Inherited:
EdkLogger.verbose("DEPEX[%s] (+%s) = %s" % (self.Name, M.BaseName, DepexExpressionString))
if 'BEFORE' in DepexExpressionString or 'AFTER' in DepexExpressionString:
break
if len(DepexExpressionString) > 0:
EdkLogger.verbose('')
RetVal[ModuleType] = DepexExpressionString
return RetVal
# 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.