summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/AutoGen
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2011-11-25 06:21:03 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2011-11-25 06:21:03 +0000
commit2bcc713e74b944bb5aefb433ef33fb4002a62d76 (patch)
tree7aa002279415c1fafbedbf287d256177746e0a4a /BaseTools/Source/Python/AutoGen
parentc32dcd284c19bbb0b1db3606a243d9d69d37d6ab (diff)
downloadedk2-platforms-2bcc713e74b944bb5aefb433ef33fb4002a62d76.tar.xz
Sync BaseTool trunk (version r2423) into EDKII BaseTools. The change mainly includes:
1. Fix !include issues 2. Fix Trim to skip the postfix 'U' for hexadecimal and decimal numbers 3. Fix building error C2733 when building C++ code. 4. Add GCC46 tool chain definition 5. Add new RVCT and RVCTLINUX tool chains Signed-off-by: lgao4 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12782 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/Python/AutoGen')
-rw-r--r--BaseTools/Source/Python/AutoGen/GenC.py6
-rw-r--r--BaseTools/Source/Python/AutoGen/GenMake.py101
-rw-r--r--BaseTools/Source/Python/AutoGen/StrGather.py2
-rw-r--r--BaseTools/Source/Python/AutoGen/UniClassObject.py2
4 files changed, 61 insertions, 50 deletions
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 561114d141..5638bfd043 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -310,11 +310,14 @@ gAutoGenHPrologueString = TemplateString("""
#ifndef _${File}_${Guid}
#define _${File}_${Guid}
+""")
+
+gAutoGenHCppPrologueString = """
#ifdef __cplusplus
extern "C" {
#endif
-""")
+"""
gAutoGenHEpilogueString = """
@@ -1970,6 +1973,7 @@ def CreateHeaderCode(Info, AutoGenC, AutoGenH):
AutoGenH.Append(gAutoGenHeaderString.Replace({'FileName':'AutoGen.h'}))
# header file Prologue
AutoGenH.Append(gAutoGenHPrologueString.Replace({'File':'AUTOGENH','Guid':Info.Guid.replace('-','_')}))
+ AutoGenH.Append(gAutoGenHCppPrologueString)
if Info.AutoGenVersion >= 0x00010005:
# header files includes
AutoGenH.Append("#include <%s>\n" % gBasicHeaderFile)
diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py
index b34977d7a9..b2ebff324d 100644
--- a/BaseTools/Source/Python/AutoGen/GenMake.py
+++ b/BaseTools/Source/Python/AutoGen/GenMake.py
@@ -31,6 +31,8 @@ gIncludePattern = re.compile(r"^[ \t]*#?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n
## 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 @@ cleanlib:
self.FileListMacros = {}
self.ListFileMacros = {}
+ self.FileCache = {}
self.FileDependency = []
self.LibraryBuildCommandList = []
self.LibraryFileList = []
@@ -722,24 +725,26 @@ cleanlib:
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 @@ cleanlib:
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 @@ cleanlib:
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)))
-
- 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)
+ 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 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
+ self.FileCache[F] = FullPathDependList
+ DependencySet.update(FullPathDependList)
+
+ DependencySet.update(ForceList)
+ if File in DependencySet:
+ DependencySet.remove(File)
+ DependencyList = list(DependencySet) # remove duplicate ones
return DependencyList
@@ -1314,16 +1321,16 @@ ${END}\t@cd $(BUILD_DIR)\n
# macros passed to GenFds
MacroList.append('"%s=%s"' % ("EFI_SOURCE", GlobalData.gEfiSource.replace('\\', '\\\\')))
MacroList.append('"%s=%s"' % ("EDK_SOURCE", GlobalData.gEdkSource.replace('\\', '\\\\')))
- for MacroName in GlobalData.gGlobalDefines:
- if GlobalData.gGlobalDefines[MacroName] != "":
- MacroList.append('"%s=%s"' % (MacroName, GlobalData.gGlobalDefines[MacroName].replace('\\', '\\\\')))
+ MacroDict = {}
+ MacroDict.update(GlobalData.gGlobalDefines)
+ MacroDict.update(GlobalData.gCommandLineDefines)
+ MacroDict.pop("EFI_SOURCE", "dummy")
+ MacroDict.pop("EDK_SOURCE", "dummy")
+ for MacroName in MacroDict:
+ if MacroDict[MacroName] != "":
+ MacroList.append('"%s=%s"' % (MacroName, MacroDict[MacroName].replace('\\', '\\\\')))
else:
MacroList.append('"%s"' % MacroName)
- for MacroName in GlobalData.gCommandLineDefines:
- if GlobalData.gCommandLineDefines[MacroName] != "":
- MacroList.append('"%s=%s"' % (MacroName, GlobalData.gCommandLineDefines[MacroName].replace('\\', '\\\\')))
- else:
- MacroList.append('"%s"' % MacroName)
else:
FdfFileList = []
diff --git a/BaseTools/Source/Python/AutoGen/StrGather.py b/BaseTools/Source/Python/AutoGen/StrGather.py
index 7187f0a440..b84d9f90aa 100644
--- a/BaseTools/Source/Python/AutoGen/StrGather.py
+++ b/BaseTools/Source/Python/AutoGen/StrGather.py
@@ -62,7 +62,7 @@ OFFSET = 'offset'
STRING = 'string'
TO = 'to'
STRING_TOKEN = re.compile('STRING_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE)
-COMPATIBLE_STRING_TOKEN = re.compile('STRING_TOKEN *\(([A-Za-z0-9_]+) *\)', re.MULTILINE | re.UNICODE)
+COMPATIBLE_STRING_TOKEN = re.compile('STRING_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE)
EFI_HII_ARRAY_SIZE_LENGTH = 4
EFI_HII_PACKAGE_HEADER_LENGTH = 4
diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/Source/Python/AutoGen/UniClassObject.py
index 54751bab4e..ea27607fce 100644
--- a/BaseTools/Source/Python/AutoGen/UniClassObject.py
+++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py
@@ -260,7 +260,7 @@ class UniFileClassObject(object):
Name = Item.split()[1]
# Check the string name is the upper character
- if not self.IsCompatibleMode and Name != '':
+ if Name != '':
MatchString = re.match('[A-Z0-9_]+', Name, re.UNICODE)
if MatchString == None or MatchString.end(0) != len(Name):
EdkLogger.error('Unicode File Parser', FORMAT_INVALID, 'The string token name %s defined in UNI file %s contains the invalid lower case character.' %(Name, self.File))