BaseTools: AutoGen - change class variable to funciton variable

This variable is only used in one function, make it local there.
Also when iterating on the variable, use dict.items() to get value
instead of re-looking up the value multiple times.

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-07-20 01:57:39 +08:00 committed by Yonghong Zhu
parent 49a4797e9c
commit 0f78fd7349

View File

@ -436,7 +436,6 @@ cleanlib:
self.ListFileMacros = {} self.ListFileMacros = {}
self.FileCache = {} self.FileCache = {}
self.FileDependency = []
self.LibraryBuildCommandList = [] self.LibraryBuildCommandList = []
self.LibraryFileList = [] self.LibraryFileList = []
self.LibraryMakefileList = [] self.LibraryMakefileList = []
@ -891,26 +890,26 @@ cleanlib:
if Item in SourceFileList: if Item in SourceFileList:
SourceFileList.remove(Item) SourceFileList.remove(Item)
self.FileDependency = self.GetFileDependency( FileDependencyDict = self.GetFileDependency(
SourceFileList, SourceFileList,
ForceIncludedFile, ForceIncludedFile,
self._AutoGenObject.IncludePathList + self._AutoGenObject.BuildOptionIncPathList self._AutoGenObject.IncludePathList + self._AutoGenObject.BuildOptionIncPathList
) )
DepSet = None DepSet = None
for File in self.FileDependency: for File,Dependency in FileDependencyDict.items():
if not self.FileDependency[File]: if not Dependency:
self.FileDependency[File] = ['$(FORCE_REBUILD)'] FileDependencyDict[File] = ['$(FORCE_REBUILD)']
continue continue
self._AutoGenObject.AutoGenDepSet |= set(self.FileDependency[File]) self._AutoGenObject.AutoGenDepSet |= set(Dependency)
# skip non-C files # skip non-C files
if File.Ext not in [".c", ".C"] or File.Name == "AutoGen.c": if File.Ext not in [".c", ".C"] or File.Name == "AutoGen.c":
continue continue
elif DepSet is None: elif DepSet is None:
DepSet = set(self.FileDependency[File]) DepSet = set(Dependency)
else: else:
DepSet &= set(self.FileDependency[File]) DepSet &= set(Dependency)
# in case nothing in SourceFileList # in case nothing in SourceFileList
if DepSet is None: if DepSet is None:
DepSet = set() DepSet = set()
@ -920,13 +919,13 @@ cleanlib:
for File in DepSet: for File in DepSet:
self.CommonFileDependency.append(self.PlaceMacro(File.Path, self.Macros)) self.CommonFileDependency.append(self.PlaceMacro(File.Path, self.Macros))
for File in self.FileDependency: for File in FileDependencyDict:
# skip non-C files # skip non-C files
if File.Ext not in [".c", ".C"] or File.Name == "AutoGen.c": if File.Ext not in [".c", ".C"] or File.Name == "AutoGen.c":
continue continue
NewDepSet = set(self.FileDependency[File]) NewDepSet = set(FileDependencyDict[File])
NewDepSet -= DepSet NewDepSet -= DepSet
self.FileDependency[File] = ["$(COMMON_DEPS)"] + list(NewDepSet) FileDependencyDict[File] = ["$(COMMON_DEPS)"] + list(NewDepSet)
# Convert target description object to target string in makefile # Convert target description object to target string in makefile
for Type in self._AutoGenObject.Targets: for Type in self._AutoGenObject.Targets:
@ -944,8 +943,8 @@ cleanlib:
for Dep in T.Dependencies: for Dep in T.Dependencies:
Deps.append(self.PlaceMacro(str(Dep), self.Macros)) Deps.append(self.PlaceMacro(str(Dep), self.Macros))
# Add inclusion-dependencies # Add inclusion-dependencies
if len(T.Inputs) == 1 and T.Inputs[0] in self.FileDependency: if len(T.Inputs) == 1 and T.Inputs[0] in FileDependencyDict:
for F in self.FileDependency[T.Inputs[0]]: for F in FileDependencyDict[T.Inputs[0]]:
Deps.append(self.PlaceMacro(str(F), self.Macros)) Deps.append(self.PlaceMacro(str(F), self.Macros))
# Add source-dependencies # Add source-dependencies
for F in T.Inputs: for F in T.Inputs: