c:\r9tip\allpkg\edk2\mdemodulepkg\universal\pcd\pei\Service.h >-----Original Message----- >From: Zhu, Yonghong >Sent: Thursday, June 22, 2017 4:10 PM >To: edk2-devel@lists.01.org >Cc: Feng, YunhuaX <yunhuax.f...@intel.com>; Gao, Liming ><liming....@intel.com> >Subject: [Patch] BaseTools: Enhance DEC Defines section format check > >From: Yunhua Feng <yunhuax.f...@intel.com> > >1. break if Dec Defines Section is missing >2. break if Dec have more than one Defines Section >3. break if Dec Defines Section have arch attribute >4. break if no section head, like as: >#[Defines] > DEC_SPECIFICATION = 0x00010005 > PACKAGE_NAME = Nt32Pkg > >Cc: Liming Gao <liming....@intel.com> >Cc: Yonghong Zhu <yonghong....@intel.com> >Contributed-under: TianoCore Contribution Agreement 1.0 >Signed-off-by: Yunhua Feng <yunhuax.f...@intel.com> >--- > BaseTools/Source/Python/Workspace/MetaFileParser.py | 15 >+++++++++++++++ > 1 file changed, 15 insertions(+) > >diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py >b/BaseTools/Source/Python/Workspace/MetaFileParser.py >index d094403..6e236e6 100644 >--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py >+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py >@@ -1654,10 +1654,11 @@ class DecParser(MetaFileParser): > try: > Content = open(str(self.MetaFile), 'r').readlines() > except: > EdkLogger.error("Parser", FILE_READ_FAILURE, >ExtraData=self.MetaFile) > >+ self._DefinesCount = 0 > for Index in range(0, len(Content)): > Line, Comment = CleanString2(Content[Index]) > self._CurrentLine = Line > self._LineIndex = Index > >@@ -1669,12 +1670,19 @@ class DecParser(MetaFileParser): > continue > > # section header > if Line[0] == TAB_SECTION_START and Line[-1] == TAB_SECTION_END: > self._SectionHeaderParser() >+ if self._SectionName == TAB_DEC_DEFINES.upper(): >+ self._DefinesCount += 1 > self._Comments = [] > continue >+ if self._SectionType == MODEL_UNKNOWN: >+ EdkLogger.error("Parser", FORMAT_INVALID, >+ "" >+ "Not able to determine \"%s\" in which >section."%self._CurrentLine, >+ self.MetaFile, self._LineIndex + 1) > elif len(self._SectionType) == 0: > self._Comments = [] > continue > > # section content >@@ -1718,10 +1726,14 @@ class DecParser(MetaFileParser): > LineNo, > - 1, > 0 > ) > self._Comments = [] >+ if self._DefinesCount > 1: >+ EdkLogger.error('Parser', FORMAT_INVALID, 'Multiple [Defines] >section is exist.', self.MetaFile ) >+ if self._DefinesCount == 0: >+ EdkLogger.error('Parser', FORMAT_INVALID, 'No [Defines] section >exist.',self.MetaFile) > self._Done() > > > ## Section header parser > # >@@ -1743,10 +1755,13 @@ class DecParser(MetaFileParser): > self.MetaFile, self._LineIndex + 1, > self._CurrentLine) > ItemList = Item.split(TAB_SPLIT) > > # different types of PCD are permissible in one section > self._SectionName = ItemList[0].upper() >+ if self._SectionName == TAB_DEC_DEFINES.upper() and >(len(ItemList) > >1 or len(Line.split(TAB_COMMA_SPLIT)) > 1): >+ EdkLogger.error("Parser", FORMAT_INVALID, "Defines section >format is invalid", >+ self.MetaFile, self._LineIndex + 1, >self._CurrentLine) > if self._SectionName in self.DataType: > if self.DataType[self._SectionName] not in self._SectionType: > self._SectionType.append(self.DataType[self._SectionName]) > else: > EdkLogger.error("Parser", FORMAT_UNKNOWN_ERROR, "%s is not a >valid section name" % Item, >-- >2.6.1.windows.1
_______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel