diff options
author | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-09-18 12:17:25 +0000 |
---|---|---|
committer | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-09-18 12:17:25 +0000 |
commit | b36d134faf4305247830522b8e2bb255e98c5699 (patch) | |
tree | ec37795cbc86b693528a062030cb516039bcb1c2 /BaseTools/Source/Python/GenFds | |
parent | e7fe4028631b6a7d70e3c02c7c40ff1504321daa (diff) | |
download | edk2-platforms-b36d134faf4305247830522b8e2bb255e98c5699.tar.xz |
Sync BaseTools Branch (version r2321) to EDKII main trunk.
Signed-off-by: lgao4
Reviewed-by: gikidy
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12372 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/Python/GenFds')
-rw-r--r-- | BaseTools/Source/Python/GenFds/CapsuleData.py | 50 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/FdfParser.py | 101 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/FfsInfStatement.py | 71 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/GenFds.py | 5 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/Section.py | 6 |
5 files changed, 208 insertions, 25 deletions
diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py b/BaseTools/Source/Python/GenFds/CapsuleData.py index 85307b90c6..aef8df0e16 100644 --- a/BaseTools/Source/Python/GenFds/CapsuleData.py +++ b/BaseTools/Source/Python/GenFds/CapsuleData.py @@ -43,7 +43,7 @@ class CapsuleFfs (CapsuleData): #
# @param self The object pointer
#
- def __init_(self) :
+ def __init__(self) :
self.Ffs = None
self.FvName = None
@@ -87,3 +87,51 @@ class CapsuleFv (CapsuleData): else:
FvFile = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FvName)
return FvFile
+
+## FD class for capsule data
+#
+#
+class CapsuleFd (CapsuleData):
+ ## The constructor
+ #
+ # @param self The object pointer
+ #
+ def __init__(self) :
+ self.Ffs = None
+ self.FdName = None
+ self.CapsuleName = None
+
+ ## generate FD capsule data
+ #
+ # @param self The object pointer
+ # @retval string Generated file name
+ #
+ def GenCapsuleSubItem(self):
+ if self.FdName.find('.fd') == -1:
+ if self.FdName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
+ FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(self.FdName.upper())
+ FdFile = FdObj.GenFd()
+ return FdFile
+ else:
+ FdFile = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FdName)
+ return FdFile
+
+## AnyFile class for capsule data
+#
+#
+class CapsuleAnyFile (CapsuleData):
+ ## The constructor
+ #
+ # @param self The object pointer
+ #
+ def __init__(self) :
+ self.Ffs = None
+ self.FileName = None
+
+ ## generate AnyFile capsule data
+ #
+ # @param self The object pointer
+ # @retval string Generated file name
+ #
+ def GenCapsuleSubItem(self):
+ return self.FileName
\ No newline at end of file diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index 5cdbe88889..c4b3f273f0 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -2298,10 +2298,15 @@ class FdfParser: if not self.__IsKeyword( "FILE"):
return False
- FfsFileObj = FfsFileStatement.FileStatement()
-
if not self.__GetNextWord():
raise Warning("expected FFS type", self.FileName, self.CurrentLineNumber)
+
+ if ForCapsule and self.__Token == 'DATA':
+ self.__UndoToken()
+ self.__UndoToken()
+ return False
+
+ FfsFileObj = FfsFileStatement.FileStatement()
FfsFileObj.FvFileType = self.__Token
if not self.__IsToken( "="):
@@ -2917,7 +2922,9 @@ class FdfParser: IsInf = self.__GetInfStatement(Obj, True)
IsFile = self.__GetFileStatement(Obj, True)
IsFv = self.__GetFvStatement(Obj)
- if not IsInf and not IsFile and not IsFv:
+ IsFd = self.__GetFdStatement(Obj)
+ IsAnyFile = self.__GetAnyFileStatement(Obj)
+ if not (IsInf or IsFile or IsFv or IsFd or IsAnyFile):
break
## __GetFvStatement() method
@@ -2945,6 +2952,65 @@ class FdfParser: CapsuleObj.CapsuleDataList.append(CapsuleFv)
return True
+ ## __GetFdStatement() method
+ #
+ # Get FD for capsule
+ #
+ # @param self The object pointer
+ # @param CapsuleObj for whom FD is got
+ # @retval True Successfully find a FD statement
+ # @retval False Not able to find a FD statement
+ #
+ def __GetFdStatement(self, CapsuleObj):
+
+ if not self.__IsKeyword("FD"):
+ return False
+
+ if not self.__IsToken("="):
+ raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
+
+ if not self.__GetNextToken():
+ raise Warning("expected FD name", self.FileName, self.CurrentLineNumber)
+
+ CapsuleFd = CapsuleData.CapsuleFd()
+ CapsuleFd.FdName = self.__Token
+ CapsuleObj.CapsuleDataList.append(CapsuleFd)
+ return True
+
+ ## __GetAnyFileStatement() method
+ #
+ # Get AnyFile for capsule
+ #
+ # @param self The object pointer
+ # @param CapsuleObj for whom AnyFile is got
+ # @retval True Successfully find a Anyfile statement
+ # @retval False Not able to find a AnyFile statement
+ #
+ def __GetAnyFileStatement(self, CapsuleObj):
+
+ if not self.__IsKeyword("FILE"):
+ return False
+
+ if not self.__IsKeyword("DATA"):
+ self.__UndoToken()
+ return False
+
+ if not self.__IsToken("="):
+ raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
+
+ if not self.__GetNextToken():
+ raise Warning("expected File name", self.FileName, self.CurrentLineNumber)
+
+ AnyFileName = self.__Token
+ AnyFileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(AnyFileName)
+ if not os.path.exists(AnyFileName):
+ raise Warning("File %s not exists"%AnyFileName, self.FileName, self.CurrentLineNumber)
+
+ CapsuleAnyFile = CapsuleData.CapsuleAnyFile()
+ CapsuleAnyFile.FileName = AnyFileName
+ CapsuleObj.CapsuleDataList.append(CapsuleAnyFile)
+ return True
+
## __GetRule() method
#
# Get Rule section contents and store its data into rule list of self.Profile
@@ -3930,16 +3996,18 @@ class FdfParser: def __GetReferencedFdCapTuple(self, CapObj, RefFdList = [], RefFvList = []):
for CapsuleDataObj in CapObj.CapsuleDataList :
- if CapsuleDataObj.FvName != None and CapsuleDataObj.FvName.upper() not in RefFvList:
+ if hasattr(CapsuleDataObj, 'FvName') and CapsuleDataObj.FvName != None and CapsuleDataObj.FvName.upper() not in RefFvList:
RefFvList.append (CapsuleDataObj.FvName.upper())
+ elif hasattr(CapsuleDataObj, 'FdName') and CapsuleDataObj.FdName != None and CapsuleDataObj.FdName.upper() not in RefFdList:
+ RefFdList.append (CapsuleDataObj.FdName.upper())
elif CapsuleDataObj.Ffs != None:
- if isinstance(CapsuleDataObj.Ffs, FfsFileStatement.FileStatement):
- if CapsuleDataObj.Ffs.FvName != None and CapsuleDataObj.Ffs.FvName.upper() not in RefFvList:
- RefFvList.append(CapsuleDataObj.Ffs.FvName.upper())
- elif CapsuleDataObj.Ffs.FdName != None and CapsuleDataObj.Ffs.FdName.upper() not in RefFdList:
- RefFdList.append(CapsuleDataObj.Ffs.FdName.upper())
- else:
- self.__GetReferencedFdFvTupleFromSection(CapsuleDataObj.Ffs, RefFdList, RefFvList)
+ if isinstance(CapsuleDataObj.Ffs, FfsFileStatement.FileStatement):
+ if CapsuleDataObj.Ffs.FvName != None and CapsuleDataObj.Ffs.FvName.upper() not in RefFvList:
+ RefFvList.append(CapsuleDataObj.Ffs.FvName.upper())
+ elif CapsuleDataObj.Ffs.FdName != None and CapsuleDataObj.Ffs.FdName.upper() not in RefFdList:
+ RefFdList.append(CapsuleDataObj.Ffs.FdName.upper())
+ else:
+ self.__GetReferencedFdFvTupleFromSection(CapsuleDataObj.Ffs, RefFdList, RefFvList)
## __GetFvInFd() method
#
@@ -4139,12 +4207,19 @@ class FdfParser: return False
if __name__ == "__main__":
- parser = FdfParser("..\LakeportX64Pkg.fdf")
+ import sys
+ try:
+ test_file = sys.argv[1]
+ except IndexError, v:
+ print "Usage: %s filename" % sys.argv[0]
+ sys.exit(1)
+
+ parser = FdfParser(test_file)
try:
parser.ParseFile()
parser.CycleReferenceCheck()
except Warning, X:
- print str(X)
+ print str(X)
else:
print "Success!"
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py index 742b2162fe..b9e18f6bca 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -36,6 +36,7 @@ from Common.BuildToolError import * from GuidSection import GuidSection
from FvImageSection import FvImageSection
from Common.Misc import PeImageClass
+from AutoGen.GenDepex import DependencyExpression
## generate FFS from INF
#
@@ -54,17 +55,75 @@ class FfsInfStatement(FfsInfStatementClassObject): self.OptRomDefs = {}
self.PiSpecVersion = '0x00000000'
self.InfModule = None
- self.FinalBuildTargetList = []
+ self.FinalTargetSuffixMap = {}
- ## GetFinalBuildTargetList() method
+ ## GetFinalTargetSuffixMap() method
#
# Get final build target list
- def GetFinalBuildTargetList(self):
+ def GetFinalTargetSuffixMap(self):
if not self.InfModule or not self.CurrentArch:
return []
- if not self.FinalBuildTargetList:
- self.FinalBuildTargetList = GenFdsGlobalVariable.GetModuleCodaTargetList(self.InfModule, self.CurrentArch)
- return self.FinalBuildTargetList
+ if not self.FinalTargetSuffixMap:
+ FinalBuildTargetList = GenFdsGlobalVariable.GetModuleCodaTargetList(self.InfModule, self.CurrentArch)
+ for File in FinalBuildTargetList:
+ self.FinalTargetSuffixMap.setdefault(os.path.splitext(File)[1], []).append(File)
+
+ # Check if current INF module has DEPEX
+ if '.depex' not in self.FinalTargetSuffixMap and self.InfModule.ModuleType != "USER_DEFINED" \
+ and not self.InfModule.DxsFile and not self.InfModule.LibraryClass:
+ ModuleType = self.InfModule.ModuleType
+ PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, self.CurrentArch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
+
+ if ModuleType != DataType.SUP_MODULE_USER_DEFINED:
+ for LibraryClass in PlatformDataBase.LibraryClasses.GetKeys():
+ if LibraryClass.startswith("NULL") and PlatformDataBase.LibraryClasses[LibraryClass, ModuleType]:
+ self.InfModule.LibraryClasses[LibraryClass] = PlatformDataBase.LibraryClasses[LibraryClass, ModuleType]
+
+ StrModule = str(self.InfModule)
+ PlatformModule = None
+ if StrModule in PlatformDataBase.Modules:
+ PlatformModule = PlatformDataBase.Modules[StrModule]
+ for LibraryClass in PlatformModule.LibraryClasses:
+ if LibraryClass.startswith("NULL"):
+ self.InfModule.LibraryClasses[LibraryClass] = PlatformModule.LibraryClasses[LibraryClass]
+
+ DependencyList = [self.InfModule]
+ LibraryInstance = {}
+ DepexList = []
+ while len(DependencyList) > 0:
+ Module = DependencyList.pop(0)
+ if not Module:
+ continue
+ for Dep in Module.Depex[self.CurrentArch, ModuleType]:
+ if DepexList != []:
+ DepexList.append('AND')
+ DepexList.append('(')
+ DepexList.extend(Dep)
+ if DepexList[-1] == 'END': # no need of a END at this time
+ DepexList.pop()
+ DepexList.append(')')
+ if 'BEFORE' in DepexList or 'AFTER' in DepexList:
+ break
+ for LibName in Module.LibraryClasses:
+ if LibName in LibraryInstance:
+ continue
+ if PlatformModule and LibName in PlatformModule.LibraryClasses:
+ LibraryPath = PlatformModule.LibraryClasses[LibName]
+ else:
+ LibraryPath = PlatformDataBase.LibraryClasses[LibName, ModuleType]
+ if not LibraryPath:
+ LibraryPath = Module.LibraryClasses[LibName]
+ if not LibraryPath:
+ continue
+ LibraryModule = GenFdsGlobalVariable.WorkSpace.BuildObject[LibraryPath, self.CurrentArch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
+ LibraryInstance[LibName] = LibraryModule
+ DependencyList.append(LibraryModule)
+ if DepexList:
+ Dpx = DependencyExpression(DepexList, ModuleType, True)
+ if len(Dpx.PostfixNotation) != 0:
+ # It means this module has DEPEX
+ self.FinalTargetSuffixMap['.depex'] = [os.path.join(self.EfiOutputPath, self.BaseName) + '.depex']
+ return self.FinalTargetSuffixMap
## __InfParse() method
#
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py index 9088a876e4..cadd36c922 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -36,9 +36,10 @@ from Common import EdkLogger from Common.String import * from Common.Misc import DirCache,PathClass from Common.Misc import SaveFileOnChange +from Common.BuildVersion import gBUILD_VERSION ## Version and Copyright -versionNumber = "1.0" +versionNumber = "1.0" + ' ' + gBUILD_VERSION __version__ = "%prog Version " + versionNumber __copyright__ = "Copyright (c) 2007 - 2010, Intel Corporation All rights reserved." @@ -311,7 +312,7 @@ def myOptionParser(): Parser.add_option("-r", "--rom_image", dest="uiFdName", help="Build the image using the [FD] section named by FdUiName.") Parser.add_option("-i", "--FvImage", dest="uiFvName", help="Build the FV image using the [FV] section named by UiFvName") Parser.add_option("-C", "--CapsuleImage", dest="uiCapName", help="Build the Capsule image using the [Capsule] section named by UiCapName") - Parser.add_option("-b", "--buildtarget", type="choice", choices=['DEBUG','RELEASE'], dest="BuildTarget", help="Build TARGET is one of list: DEBUG, RELEASE.", + Parser.add_option("-b", "--buildtarget", type="choice", choices=['DEBUG','RELEASE', 'NOOPT'], dest="BuildTarget", help="Build TARGET is one of list: DEBUG, RELEASE, NOOPT.", action="callback", callback=SingleCheckCallback) Parser.add_option("-t", "--tagname", type="string", dest="ToolChain", help="Using the tools: TOOL_CHAIN_TAG name to build the platform.", action="callback", callback=SingleCheckCallback) diff --git a/BaseTools/Source/Python/GenFds/Section.py b/BaseTools/Source/Python/GenFds/Section.py index d26f464ab9..ef9720a660 100644 --- a/BaseTools/Source/Python/GenFds/Section.py +++ b/BaseTools/Source/Python/GenFds/Section.py @@ -140,9 +140,9 @@ class Section (SectionClassObject): GenFdsGlobalVariable.InfLogger ("\nCurrent ARCH \'%s\' of File %s is not in the Support Arch Scope of %s specified by INF %s in FDF" %(FfsInf.CurrentArch, File.File, File.Arch, FfsInf.InfFileName))
if Suffix != None:
- for File in FfsInf.GetFinalBuildTargetList():
- if os.path.splitext(File)[1] in (Suffix):
- FileList.append(File)
+ SuffixMap = FfsInf.GetFinalTargetSuffixMap()
+ if Suffix in SuffixMap:
+ FileList.extend(SuffixMap[Suffix])
#Process the file lists is alphabetical for a same section type
if len (FileList) > 1:
|