BaseTools:Make BaseTools support new rules to generate RAW FFS FILE

BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1765

If RAW FFS File Rule has no section for its data.For RAW FFS File,
directly call GenFfs tool to generate FFS file.

Ffs Rule:
[Rule.Common.USER_DEFINED.MicroCode]
  FILE RAW = $(NAMED_GUID) {
        $(INF_OUTPUT)/$(MODULE_NAME).bin
  }
[Rule.Common.USER_DEFINED.LOGO]
  FILE RAW = $(NAMED_GUID) {
                       |.bmp
  }

As shown in the rule above,if SectionType and FileType not defined,
FFS files are generated directly, and no other type of file is
generated.

The patch is to make the BaseTools support these two rules

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
This commit is contained in:
Fan, ZhijuX 2019-05-29 13:29:34 +08:00 committed by Feng, Bob C
parent 6cbed0e36f
commit 04797875d1
5 changed files with 46 additions and 7 deletions

View File

@ -122,6 +122,7 @@ BINARY_FILE_TYPE_VER = 'VER'
BINARY_FILE_TYPE_UI = 'UI'
BINARY_FILE_TYPE_BIN = 'BIN'
BINARY_FILE_TYPE_FV = 'FV'
BINARY_FILE_TYPE_RAW = 'RAW_BINARY'
PLATFORM_COMPONENT_TYPE_LIBRARY_CLASS = 'LIBRARY_CLASS'
PLATFORM_COMPONENT_TYPE_MODULE = 'MODULE'

View File

@ -93,7 +93,7 @@ class EfiSection (EfiSectionClassObject):
if '.depex' in SuffixMap:
FileList.append(Filename)
else:
FileList, IsSect = Section.Section.GetFileList(FfsInf, self.FileType, self.FileExtension, Dict, IsMakefile=IsMakefile)
FileList, IsSect = Section.Section.GetFileList(FfsInf, self.FileType, self.FileExtension, Dict, IsMakefile=IsMakefile, SectionType=SectionType)
if IsSect :
return FileList, self.Alignment
@ -217,6 +217,26 @@ class EfiSection (EfiSectionClassObject):
Ui=StringData, IsMakefile=IsMakefile)
OutputFileList.append(OutputFile)
#
# If Section Type is BINARY_FILE_TYPE_RAW
#
elif SectionType == BINARY_FILE_TYPE_RAW:
"""If File List is empty"""
if FileList == []:
if self.Optional == True:
GenFdsGlobalVariable.VerboseLogger("Optional Section don't exist!")
return [], None
else:
EdkLogger.error("GenFds", GENFDS_ERROR, "Output file for %s section could not be found for %s" % (SectionType, InfFileName))
elif len(FileList) > 1:
EdkLogger.error("GenFds", GENFDS_ERROR,
"Files suffixed with %s are not allowed to have more than one file in %s[Binaries] section" % (
self.FileExtension, InfFileName))
else:
for File in FileList:
File = GenFdsGlobalVariable.MacroExtend(File, Dict)
OutputFileList.append(File)
else:
"""If File List is empty"""

View File

@ -3749,8 +3749,19 @@ class FdfParser:
#
def _GetEfiSection(self, Obj):
OldPos = self.GetFileBufferPos()
EfiSectionObj = EfiSection()
if not self._GetNextWord():
return False
CurrentLine = self._CurrentLine()[self.CurrentOffsetWithinLine:].split()[0].strip()
if self._Token == '{' and Obj.FvFileType == "RAW" and TAB_SPLIT in CurrentLine:
if self._IsToken(TAB_VALUE_SPLIT):
EfiSectionObj.FileExtension = self._GetFileExtension()
elif self._GetNextToken():
EfiSectionObj.FileName = self._Token
EfiSectionObj.SectionType = BINARY_FILE_TYPE_RAW
Obj.SectionList.append(EfiSectionObj)
return True
else:
return False
SectionName = self._Token
if SectionName not in {
@ -3816,7 +3827,6 @@ class FdfParser:
Obj.SectionList.append(FvImageSectionObj)
return True
EfiSectionObj = EfiSection()
EfiSectionObj.SectionType = SectionName
if not self._GetNextToken():

View File

@ -147,7 +147,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
# @param self The object pointer
# @param Dict dictionary contains macro and value pair
#
def __InfParse__(self, Dict = {}):
def __InfParse__(self, Dict = None, IsGenFfs=False):
GenFdsGlobalVariable.VerboseLogger( " Begine parsing INf file : %s" %self.InfFileName)
@ -348,7 +348,10 @@ class FfsInfStatement(FfsInfStatementClassObject):
#
# Set OutputPath = ${WorkSpace}\Build\Fv\Ffs\${ModuleGuid}+ ${ModuleName}\
#
if IsGenFfs:
Rule = self.__GetRule__()
if GlobalData.gGuidPatternEnd.match(Rule.NameGuid):
self.ModuleGuid = Rule.NameGuid
self.OutputPath = os.path.join(GenFdsGlobalVariable.FfsDir, \
self.ModuleGuid + self.BaseName)
if not os.path.exists(self.OutputPath) :
@ -438,7 +441,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
# Parse Inf file get Module related information
#
self.__InfParse__(Dict)
self.__InfParse__(Dict, IsGenFfs=True)
Arch = self.GetCurrentArch()
SrcFile = mws.join( GenFdsGlobalVariable.WorkSpaceDir, self.InfFileName);
DestFile = os.path.join( self.OutputPath, self.ModuleGuid + '.ffs')

View File

@ -106,7 +106,7 @@ class Section (SectionClassObject):
# @param Dict dictionary contains macro and its value
# @retval tuple (File list, boolean)
#
def GetFileList(FfsInf, FileType, FileExtension, Dict = {}, IsMakefile=False):
def GetFileList(FfsInf, FileType, FileExtension, Dict = None, IsMakefile=False, SectionType=None):
IsSect = FileType in Section.SectFileType
if FileExtension is not None:
@ -134,6 +134,11 @@ class Section (SectionClassObject):
else:
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))
elif FileType is None and SectionType == BINARY_FILE_TYPE_RAW:
for File in FfsInf.BinFileList:
if File.Ext == Suffix:
FileList.append(File.Path)
if (not IsMakefile and Suffix is not None and os.path.exists(FfsInf.EfiOutputPath)) or (IsMakefile and Suffix is not None):
#
# Get Makefile path and time stamp