|
From: <yi...@us...> - 2011-11-17 03:10:15
|
Revision: 2410
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2410&view=rev
Author: yingke
Date: 2011-11-17 03:10:08 +0000 (Thu, 17 Nov 2011)
Log Message:
-----------
Fix an incremental build bug.
Signed-off-by: yingke
Reviewed-by: jsu1
Modified Paths:
--------------
trunk/BaseTools/Source/Python/AutoGen/GenMake.py
Modified: trunk/BaseTools/Source/Python/AutoGen/GenMake.py
===================================================================
--- trunk/BaseTools/Source/Python/AutoGen/GenMake.py 2011-11-16 06:26:09 UTC (rev 2409)
+++ trunk/BaseTools/Source/Python/AutoGen/GenMake.py 2011-11-17 03:10:08 UTC (rev 2410)
@@ -31,6 +31,8 @@
## Regular expression for matching macro used in header file inclusion
gMacroPattern = re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICODE)
+gIsFileMap = {}
+
## pattern for include style in Edk.x code
gProtocolDefinition = "Protocol/%(HeaderKey)s/%(HeaderKey)s.h"
gGuidDefinition = "Guid/%(HeaderKey)s/%(HeaderKey)s.h"
@@ -421,6 +423,7 @@
self.FileListMacros = {}
self.ListFileMacros = {}
+ self.FileCache = {}
self.FileDependency = []
self.LibraryBuildCommandList = []
self.LibraryFileList = []
@@ -722,24 +725,26 @@
EdkLogger.debug(EdkLogger.DEBUG_1, "Try to get dependency files for %s" % File)
FileStack = [File] + ForceList
DependencySet = set()
- MacroUsedByIncludedFile = False
if self._AutoGenObject.Arch not in gDependencyDatabase:
gDependencyDatabase[self._AutoGenObject.Arch] = {}
DepDb = gDependencyDatabase[self._AutoGenObject.Arch]
- # add path of given source file into search path list.
- if File.Dir not in SearchPathList:
- SearchPathList.append(File.Dir)
while len(FileStack) > 0:
F = FileStack.pop()
+ FullPathDependList = []
+ if F in self.FileCache:
+ for CacheFile in self.FileCache[F]:
+ FullPathDependList.append(CacheFile)
+ if CacheFile not in DependencySet:
+ FileStack.append(CacheFile)
+ DependencySet.update(FullPathDependList)
+ continue
+
CurrentFileDependencyList = []
if F in DepDb:
CurrentFileDependencyList = DepDb[F]
- for Dep in CurrentFileDependencyList:
- if Dep not in FileStack and Dep not in DependencySet:
- FileStack.append(Dep)
else:
try:
Fd = open(F.Path, 'r')
@@ -755,7 +760,6 @@
FileContent = unicode(FileContent, "utf-16")
IncludedFileList = gIncludePattern.findall(FileContent)
- CurrentFilePath = F.Dir
for Inc in IncludedFileList:
Inc = Inc.strip()
# if there's macro used to reference header file, expand it
@@ -766,41 +770,44 @@
if HeaderType in gIncludeMacroConversion:
Inc = gIncludeMacroConversion[HeaderType] % {"HeaderKey" : HeaderKey}
else:
- # not known macro used in #include
- MacroUsedByIncludedFile = True
- continue
+ # not known macro used in #include, always build the file by
+ # returning a empty dependency
+ self.FileCache[File] = []
+ return []
Inc = os.path.normpath(Inc)
- for SearchPath in [CurrentFilePath] + SearchPathList:
- FilePath = os.path.join(SearchPath, Inc)
- if not os.path.isfile(FilePath) or FilePath in CurrentFileDependencyList:
+ CurrentFileDependencyList.append(Inc)
+ DepDb[F] = CurrentFileDependencyList
+
+ CurrentFilePath = F.Dir
+ PathList = [CurrentFilePath] + SearchPathList
+ for Inc in CurrentFileDependencyList:
+ for SearchPath in PathList:
+ FilePath = os.path.join(SearchPath, Inc)
+ if FilePath in gIsFileMap:
+ if not gIsFileMap[FilePath]:
continue
- FilePath = PathClass(FilePath)
- CurrentFileDependencyList.append(FilePath)
- if FilePath not in FileStack and FilePath not in DependencySet:
- FileStack.append(FilePath)
- break
+ # If isfile is called too many times, the performance is slow down.
+ elif not os.path.isfile(FilePath):
+ gIsFileMap[FilePath] = False
+ continue
else:
- EdkLogger.debug(EdkLogger.DEBUG_9, "%s included by %s was not found "\
- "in any given path:\n\t%s" % (Inc, F, "\n\t".join(SearchPathList)))
+ gIsFileMap[FilePath] = True
+ FilePath = PathClass(FilePath)
+ FullPathDependList.append(FilePath)
+ if FilePath not in DependencySet:
+ FileStack.append(FilePath)
+ break
+ else:
+ EdkLogger.debug(EdkLogger.DEBUG_9, "%s included by %s was not found "\
+ "in any given path:\n\t%s" % (Inc, F, "\n\t".join(SearchPathList)))
- if not MacroUsedByIncludedFile:
- if F == File:
- CurrentFileDependencyList += ForceList
- #
- # Don't keep the file in cache if it uses macro in included file.
- # So it will be scanned again if another file includes this file.
- #
- DepDb[F] = CurrentFileDependencyList
- DependencySet.update(CurrentFileDependencyList)
+ self.FileCache[F] = FullPathDependList
+ DependencySet.update(FullPathDependList)
- #
- # If there's macro used in included file, always build the file by
- # returning a empty dependency
- #
- if MacroUsedByIncludedFile:
- DependencyList = []
- else:
- DependencyList = list(DependencySet) # remove duplicate ones
+ DependencySet.update(ForceList)
+ if File in DependencySet:
+ DependencySet.remove(File)
+ DependencyList = list(DependencySet) # remove duplicate ones
return DependencyList
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|