Re: [EXTERNAL] [edk2-devel] [PATCH 1/1] BaseTools/Ecc: Update structpcd parsing method.
Ah! Gotcha. I missed that this was specific to ECC. Thanks! - Bret From: Chen, Christine<mailto:yuwei.c...@intel.com> Sent: Wednesday, April 7, 2021 6:42 PM To: Bret Barkelew<mailto:bret.barke...@microsoft.com>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> Cc: Liang, MingyueX<mailto:mingyuex.li...@intel.com>; Feng, Bob C<mailto:bob.c.f...@intel.com>; Liming Gao<mailto:gaolim...@byosoft.com.cn> Subject: RE: [EXTERNAL] [edk2-devel] [PATCH 1/1] BaseTools/Ecc: Update structpcd parsing method. Hi Bret, This patch adds the ECC check for structurePcd written in des/dsc file, as the origin check is only for non-structured Pcd. Best Regards, Yuwei (Christine) From: Bret Barkelew Sent: Friday, April 2, 2021 12:43 AM To: devel@edk2.groups.io; Chen, Christine Cc: Liang, MingyueX ; Feng, Bob C ; Liming Gao Subject: RE: [EXTERNAL] [edk2-devel] [PATCH 1/1] BaseTools/Ecc: Update structpcd parsing method. What does “update” mean in this context? What behavior is changing? - Bret From: Yuwei Chen via groups.io<mailto:yuwei.chen=intel@groups.io> Sent: Thursday, April 1, 2021 12:04 AM To: devel@edk2.groups.io<mailto:devel@edk2.groups.io> Cc: mliang2x<mailto:mingyuex.li...@intel.com>; Feng, Bob C<mailto:bob.c.f...@intel.com>; Liming Gao<mailto:gaolim...@byosoft.com.cn> Subject: [EXTERNAL] [edk2-devel] [PATCH 1/1] BaseTools/Ecc: Update structpcd parsing method. From: mliang2x mailto:mingyuex.li...@intel.com>> Update the pcdparser method in Dec and DSC files. Signed-off-by: Mingyue Liang mailto:mingyuex.li...@intel.com>> Cc: Bob Feng mailto:bob.c.f...@intel.com>> Cc: Liming Gao mailto:gaolim...@byosoft.com.cn>> Cc: Yuwei Chen mailto:yuwei.c...@intel.com>> --- .../Ecc/MetaFileWorkspace/MetaFileParser.py | 464 ++ 1 file changed, 265 insertions(+), 199 deletions(-) diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py index 9c27c8e16a05..588d3dbe6ed5 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py @@ -22,7 +22,7 @@ import Ecc.EccToolError as EccToolError from CommonDataClass.DataClass import * from Common.DataType import * from Common.StringUtils import * -from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData +from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData, AnalyzeDscPcd, AnalyzePcdExpression, ParseFieldValue, StructPattern from Common.Expression import * from CommonDataClass.Exceptions import * @@ -31,6 +31,8 @@ from GenFds.FdfParser import FdfParser from Common.LongFilePathSupport import OpenLongFilePath as open from Common.LongFilePathSupport import CodecOpenLongFilePath +CODEPattern = re.compile(r"{CODE\([a-fA-F0-9Xx\{\},\s]*\)}") + ## A decorator used to parse macro definition def ParseMacro(Parser): def MacroParser(self): @@ -174,6 +176,11 @@ class MetaFileParser(object): # UNI object and extra UNI object self._UniObj = None self._UniExtraObj = None +# StructPcd var +self._PcdCodeValue = "" +self._PcdDataTypeCODE = False +self._CurrentPcdName = "" +self._GuidDict = {} # for Parser PCD value {GUID(gTokeSpaceGuidName)} ## Store the parsed data in table def _Store(self, *Args): @@ -395,6 +402,40 @@ class MetaFileParser(object): Macros.update(self._SectionsMacroDict[(self._SectionType, Scope1, Scope2)]) return Macros +def ProcessMultipleLineCODEValue(self, Content): +CODEBegin = False +CODELine = "" +continuelinecount = 0 +newContent = [] +for Index in range(0, len(Content)): +Line = Content[Index] +if CODEBegin: +CODELine = CODELine + Line +continuelinecount +=1 +if ")}" in Line: +newContent.append(CODELine) +for _ in range(continuelinecount): +newContent.append("") +CODEBegin = False +CODELine = "" +continuelinecount = 0 +else: +if not Line: +newContent.append(Line) +continue +if "{CODE(" not in Line: +newContent.append(Line) +continue +elif CODEPattern.findall(Line): +newContent.append(Line) +continue +else: +CODEBegin = True +CODELine = Line + +return newContent + + _SectionParser = {} Finishe
Re: [EXTERNAL] [edk2-devel] [PATCH 1/1] BaseTools/Ecc: Update structpcd parsing method.
Hi Bret, This patch adds the ECC check for structurePcd written in des/dsc file, as the origin check is only for non-structured Pcd. Best Regards, Yuwei (Christine) From: Bret Barkelew Sent: Friday, April 2, 2021 12:43 AM To: devel@edk2.groups.io; Chen, Christine Cc: Liang, MingyueX ; Feng, Bob C ; Liming Gao Subject: RE: [EXTERNAL] [edk2-devel] [PATCH 1/1] BaseTools/Ecc: Update structpcd parsing method. What does "update" mean in this context? What behavior is changing? - Bret From: Yuwei Chen via groups.io<mailto:yuwei.chen=intel@groups.io> Sent: Thursday, April 1, 2021 12:04 AM To: devel@edk2.groups.io<mailto:devel@edk2.groups.io> Cc: mliang2x<mailto:mingyuex.li...@intel.com>; Feng, Bob C<mailto:bob.c.f...@intel.com>; Liming Gao<mailto:gaolim...@byosoft.com.cn> Subject: [EXTERNAL] [edk2-devel] [PATCH 1/1] BaseTools/Ecc: Update structpcd parsing method. From: mliang2x mailto:mingyuex.li...@intel.com>> Update the pcdparser method in Dec and DSC files. Signed-off-by: Mingyue Liang mailto:mingyuex.li...@intel.com>> Cc: Bob Feng mailto:bob.c.f...@intel.com>> Cc: Liming Gao mailto:gaolim...@byosoft.com.cn>> Cc: Yuwei Chen mailto:yuwei.c...@intel.com>> --- .../Ecc/MetaFileWorkspace/MetaFileParser.py | 464 ++ 1 file changed, 265 insertions(+), 199 deletions(-) diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py index 9c27c8e16a05..588d3dbe6ed5 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py @@ -22,7 +22,7 @@ import Ecc.EccToolError as EccToolError from CommonDataClass.DataClass import * from Common.DataType import * from Common.StringUtils import * -from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData +from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData, AnalyzeDscPcd, AnalyzePcdExpression, ParseFieldValue, StructPattern from Common.Expression import * from CommonDataClass.Exceptions import * @@ -31,6 +31,8 @@ from GenFds.FdfParser import FdfParser from Common.LongFilePathSupport import OpenLongFilePath as open from Common.LongFilePathSupport import CodecOpenLongFilePath +CODEPattern = re.compile(r"{CODE\([a-fA-F0-9Xx\{\},\s]*\)}") + ## A decorator used to parse macro definition def ParseMacro(Parser): def MacroParser(self): @@ -174,6 +176,11 @@ class MetaFileParser(object): # UNI object and extra UNI object self._UniObj = None self._UniExtraObj = None +# StructPcd var +self._PcdCodeValue = "" +self._PcdDataTypeCODE = False +self._CurrentPcdName = "" +self._GuidDict = {} # for Parser PCD value {GUID(gTokeSpaceGuidName)} ## Store the parsed data in table def _Store(self, *Args): @@ -395,6 +402,40 @@ class MetaFileParser(object): Macros.update(self._SectionsMacroDict[(self._SectionType, Scope1, Scope2)]) return Macros +def ProcessMultipleLineCODEValue(self, Content): +CODEBegin = False +CODELine = "" +continuelinecount = 0 +newContent = [] +for Index in range(0, len(Content)): +Line = Content[Index] +if CODEBegin: +CODELine = CODELine + Line +continuelinecount +=1 +if ")}" in Line: +newContent.append(CODELine) +for _ in range(continuelinecount): +newContent.append("") +CODEBegin = False +CODELine = "" +continuelinecount = 0 +else: +if not Line: +newContent.append(Line) +continue +if "{CODE(" not in Line: +newContent.append(Line) +continue +elif CODEPattern.findall(Line): +newContent.append(Line) +continue +else: +CODEBegin = True +CODELine = Line + +return newContent + + _SectionParser = {} Finished= property(_GetFinished, _SetFinished) _Macros = property(_GetMacros) @@ -812,6 +853,8 @@ class DscParser(MetaFileParser): Content = open(str(self.MetaFile.Path), 'r').readlines() except: EdkLogger.error("Parser", FILE_READ_FAILURE, ExtraData=self.MetaFile) + +Content = self.ProcessMultipleLineCODEValue(Content) # # Insert a record for file # @@ -1018,24 +1061,71 @@ class DscParser(MetaFileParser): # @ParseMacro
Re: [EXTERNAL] [edk2-devel] [PATCH 1/1] BaseTools/Ecc: Update structpcd parsing method.
What does “update” mean in this context? What behavior is changing? - Bret From: Yuwei Chen via groups.io<mailto:yuwei.chen=intel@groups.io> Sent: Thursday, April 1, 2021 12:04 AM To: devel@edk2.groups.io<mailto:devel@edk2.groups.io> Cc: mliang2x<mailto:mingyuex.li...@intel.com>; Feng, Bob C<mailto:bob.c.f...@intel.com>; Liming Gao<mailto:gaolim...@byosoft.com.cn> Subject: [EXTERNAL] [edk2-devel] [PATCH 1/1] BaseTools/Ecc: Update structpcd parsing method. From: mliang2x Update the pcdparser method in Dec and DSC files. Signed-off-by: Mingyue Liang Cc: Bob Feng Cc: Liming Gao Cc: Yuwei Chen --- .../Ecc/MetaFileWorkspace/MetaFileParser.py | 464 ++ 1 file changed, 265 insertions(+), 199 deletions(-) diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py index 9c27c8e16a05..588d3dbe6ed5 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py @@ -22,7 +22,7 @@ import Ecc.EccToolError as EccToolError from CommonDataClass.DataClass import * from Common.DataType import * from Common.StringUtils import * -from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData +from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData, AnalyzeDscPcd, AnalyzePcdExpression, ParseFieldValue, StructPattern from Common.Expression import * from CommonDataClass.Exceptions import * @@ -31,6 +31,8 @@ from GenFds.FdfParser import FdfParser from Common.LongFilePathSupport import OpenLongFilePath as open from Common.LongFilePathSupport import CodecOpenLongFilePath +CODEPattern = re.compile(r"{CODE\([a-fA-F0-9Xx\{\},\s]*\)}") + ## A decorator used to parse macro definition def ParseMacro(Parser): def MacroParser(self): @@ -174,6 +176,11 @@ class MetaFileParser(object): # UNI object and extra UNI object self._UniObj = None self._UniExtraObj = None +# StructPcd var +self._PcdCodeValue = "" +self._PcdDataTypeCODE = False +self._CurrentPcdName = "" +self._GuidDict = {} # for Parser PCD value {GUID(gTokeSpaceGuidName)} ## Store the parsed data in table def _Store(self, *Args): @@ -395,6 +402,40 @@ class MetaFileParser(object): Macros.update(self._SectionsMacroDict[(self._SectionType, Scope1, Scope2)]) return Macros +def ProcessMultipleLineCODEValue(self, Content): +CODEBegin = False +CODELine = "" +continuelinecount = 0 +newContent = [] +for Index in range(0, len(Content)): +Line = Content[Index] +if CODEBegin: +CODELine = CODELine + Line +continuelinecount +=1 +if ")}" in Line: +newContent.append(CODELine) +for _ in range(continuelinecount): +newContent.append("") +CODEBegin = False +CODELine = "" +continuelinecount = 0 +else: +if not Line: +newContent.append(Line) +continue +if "{CODE(" not in Line: +newContent.append(Line) +continue +elif CODEPattern.findall(Line): +newContent.append(Line) +continue +else: +CODEBegin = True +CODELine = Line + +return newContent + + _SectionParser = {} Finished= property(_GetFinished, _SetFinished) _Macros = property(_GetMacros) @@ -812,6 +853,8 @@ class DscParser(MetaFileParser): Content = open(str(self.MetaFile.Path), 'r').readlines() except: EdkLogger.error("Parser", FILE_READ_FAILURE, ExtraData=self.MetaFile) + +Content = self.ProcessMultipleLineCODEValue(Content) # # Insert a record for file # @@ -1018,24 +1061,71 @@ class DscParser(MetaFileParser): # @ParseMacro def _PcdParser(self): +if self._PcdDataTypeCODE: +self._PcdCodeValue = self._PcdCodeValue + "\n " + self._CurrentLine +if self._CurrentLine.endswith(")}"): +self._CurrentLine = "|".join((self._CurrentPcdName, self._PcdCodeValue)) +self._PcdDataTypeCODE = False +self._PcdCodeValue = "" +else: +self._ValueList = None +return TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT, 1) +self._CurrentPcdName = TokenList[0] +if
Re: [edk2-devel] [PATCH 1/1] BaseTools/Ecc: Update structpcd parsing method.
Please ignore this patch, sorry for wrong sending. Thanks, Yuwei > -Original Message- > From: devel@edk2.groups.io On Behalf Of Yuwei > Chen > Sent: Thursday, April 1, 2021 3:04 PM > To: devel@edk2.groups.io > Cc: Liang, MingyueX ; Feng, Bob C > ; Liming Gao > Subject: [edk2-devel] [PATCH 1/1] BaseTools/Ecc: Update structpcd parsing > method. > > From: mliang2x > > Update the pcdparser method in Dec and DSC files. > > Signed-off-by: Mingyue Liang > Cc: Bob Feng > Cc: Liming Gao > Cc: Yuwei Chen > --- > .../Ecc/MetaFileWorkspace/MetaFileParser.py | 464 ++ > 1 file changed, 265 insertions(+), 199 deletions(-) > > diff --git > a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py > b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py > index 9c27c8e16a05..588d3dbe6ed5 100644 > --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py > +++ > b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py > @@ -22,7 +22,7 @@ import Ecc.EccToolError as EccToolError from > CommonDataClass.DataClass import * from Common.DataType import * > from Common.StringUtils import * -from Common.Misc import > GuidStructureStringToGuidString, CheckPcdDatum, PathClass, > AnalyzePcdData > +from Common.Misc import GuidStructureStringToGuidString, > CheckPcdDatum, > +PathClass, AnalyzePcdData, AnalyzeDscPcd, AnalyzePcdExpression, > +ParseFieldValue, StructPattern > from Common.Expression import * > from CommonDataClass.Exceptions import * > > @@ -31,6 +31,8 @@ from GenFds.FdfParser import FdfParser from > Common.LongFilePathSupport import OpenLongFilePath as open from > Common.LongFilePathSupport import CodecOpenLongFilePath > > +CODEPattern = re.compile(r"{CODE\([a-fA-F0-9Xx\{\},\s]*\)}") > + > ## A decorator used to parse macro definition def ParseMacro(Parser): > def MacroParser(self): > @@ -174,6 +176,11 @@ class MetaFileParser(object): > # UNI object and extra UNI object > self._UniObj = None > self._UniExtraObj = None > +# StructPcd var > +self._PcdCodeValue = "" > +self._PcdDataTypeCODE = False > +self._CurrentPcdName = "" > +self._GuidDict = {} # for Parser PCD value > + {GUID(gTokeSpaceGuidName)} > > ## Store the parsed data in table > def _Store(self, *Args): > @@ -395,6 +402,40 @@ class MetaFileParser(object): > Macros.update(self._SectionsMacroDict[(self._SectionType, > Scope1, > Scope2)]) > return Macros > > +def ProcessMultipleLineCODEValue(self, Content): > +CODEBegin = False > +CODELine = "" > +continuelinecount = 0 > +newContent = [] > +for Index in range(0, len(Content)): > +Line = Content[Index] > +if CODEBegin: > +CODELine = CODELine + Line > +continuelinecount +=1 > +if ")}" in Line: > +newContent.append(CODELine) > +for _ in range(continuelinecount): > +newContent.append("") > +CODEBegin = False > +CODELine = "" > +continuelinecount = 0 > +else: > +if not Line: > +newContent.append(Line) > +continue > +if "{CODE(" not in Line: > +newContent.append(Line) > +continue > +elif CODEPattern.findall(Line): > +newContent.append(Line) > +continue > +else: > +CODEBegin = True > +CODELine = Line > + > +return newContent > + > + > _SectionParser = {} > Finished= property(_GetFinished, _SetFinished) > _Macros = property(_GetMacros) > @@ -812,6 +853,8 @@ class DscParser(MetaFileParser): > Content = open(str(self.MetaFile.Path), 'r').readlines() > except: > EdkLogger.error("Parser", FILE_READ_FAILURE, > ExtraData=self.MetaFile) > + > +Content = self.ProcessMultipleLineCODEValue(Content) > # > # Insert a record for file > # > @@ -1018,24 +1061,71 @@ class DscParser(MetaFileParser): > # > @ParseMacro > def _PcdParser(self): > +if self._PcdDataTypeCODE: > +self._PcdCodeValue = self._PcdCodeValue + "\n " + > self._CurrentLine > +if
[edk2-devel] [PATCH 1/1] BaseTools/Ecc: Update structpcd parsing method.
From: mliang2x Update the pcdparser method in Dec and DSC files. Signed-off-by: Mingyue Liang Cc: Bob Feng Cc: Liming Gao Cc: Yuwei Chen --- .../Ecc/MetaFileWorkspace/MetaFileParser.py | 464 ++ 1 file changed, 265 insertions(+), 199 deletions(-) diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py index 9c27c8e16a05..588d3dbe6ed5 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py @@ -22,7 +22,7 @@ import Ecc.EccToolError as EccToolError from CommonDataClass.DataClass import * from Common.DataType import * from Common.StringUtils import * -from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData +from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData, AnalyzeDscPcd, AnalyzePcdExpression, ParseFieldValue, StructPattern from Common.Expression import * from CommonDataClass.Exceptions import * @@ -31,6 +31,8 @@ from GenFds.FdfParser import FdfParser from Common.LongFilePathSupport import OpenLongFilePath as open from Common.LongFilePathSupport import CodecOpenLongFilePath +CODEPattern = re.compile(r"{CODE\([a-fA-F0-9Xx\{\},\s]*\)}") + ## A decorator used to parse macro definition def ParseMacro(Parser): def MacroParser(self): @@ -174,6 +176,11 @@ class MetaFileParser(object): # UNI object and extra UNI object self._UniObj = None self._UniExtraObj = None +# StructPcd var +self._PcdCodeValue = "" +self._PcdDataTypeCODE = False +self._CurrentPcdName = "" +self._GuidDict = {} # for Parser PCD value {GUID(gTokeSpaceGuidName)} ## Store the parsed data in table def _Store(self, *Args): @@ -395,6 +402,40 @@ class MetaFileParser(object): Macros.update(self._SectionsMacroDict[(self._SectionType, Scope1, Scope2)]) return Macros +def ProcessMultipleLineCODEValue(self, Content): +CODEBegin = False +CODELine = "" +continuelinecount = 0 +newContent = [] +for Index in range(0, len(Content)): +Line = Content[Index] +if CODEBegin: +CODELine = CODELine + Line +continuelinecount +=1 +if ")}" in Line: +newContent.append(CODELine) +for _ in range(continuelinecount): +newContent.append("") +CODEBegin = False +CODELine = "" +continuelinecount = 0 +else: +if not Line: +newContent.append(Line) +continue +if "{CODE(" not in Line: +newContent.append(Line) +continue +elif CODEPattern.findall(Line): +newContent.append(Line) +continue +else: +CODEBegin = True +CODELine = Line + +return newContent + + _SectionParser = {} Finished= property(_GetFinished, _SetFinished) _Macros = property(_GetMacros) @@ -812,6 +853,8 @@ class DscParser(MetaFileParser): Content = open(str(self.MetaFile.Path), 'r').readlines() except: EdkLogger.error("Parser", FILE_READ_FAILURE, ExtraData=self.MetaFile) + +Content = self.ProcessMultipleLineCODEValue(Content) # # Insert a record for file # @@ -1018,24 +1061,71 @@ class DscParser(MetaFileParser): # @ParseMacro def _PcdParser(self): +if self._PcdDataTypeCODE: +self._PcdCodeValue = self._PcdCodeValue + "\n " + self._CurrentLine +if self._CurrentLine.endswith(")}"): +self._CurrentLine = "|".join((self._CurrentPcdName, self._PcdCodeValue)) +self._PcdDataTypeCODE = False +self._PcdCodeValue = "" +else: +self._ValueList = None +return TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT, 1) +self._CurrentPcdName = TokenList[0] +if len(TokenList) == 2 and TokenList[1].strip().startswith("{CODE"): +self._PcdDataTypeCODE = True +self._PcdCodeValue = TokenList[1].strip() + +if self._PcdDataTypeCODE: +if self._CurrentLine.endswith(")}"): +self._PcdDataTypeCODE = False +self._PcdCodeValue = "" +else: +self._ValueList = None +return self._ValueList[0:1] = GetSplitValueList(TokenList[0], TAB_SPLIT) +PcdNameTockens = GetSplitValueList(TokenList[0], TAB_SPLIT) +if len(PcdNameTockens) == 2: +
[edk2-devel] [PATCH 1/1] BaseTools/Ecc: Update structpcd parsing method.
From: mliang2x Update the pcdparser method in Dec and DSC files. Signed-off-by: Mingyue Liang Cc: Bob Feng Cc: Liming Gao Cc: Yuwei Chen --- .../Ecc/MetaFileWorkspace/MetaFileParser.py | 464 ++ 1 file changed, 265 insertions(+), 199 deletions(-) diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py index 9c27c8e16a05..588d3dbe6ed5 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py @@ -22,7 +22,7 @@ import Ecc.EccToolError as EccToolError from CommonDataClass.DataClass import * from Common.DataType import * from Common.StringUtils import * -from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData +from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData, AnalyzeDscPcd, AnalyzePcdExpression, ParseFieldValue, StructPattern from Common.Expression import * from CommonDataClass.Exceptions import * @@ -31,6 +31,8 @@ from GenFds.FdfParser import FdfParser from Common.LongFilePathSupport import OpenLongFilePath as open from Common.LongFilePathSupport import CodecOpenLongFilePath +CODEPattern = re.compile(r"{CODE\([a-fA-F0-9Xx\{\},\s]*\)}") + ## A decorator used to parse macro definition def ParseMacro(Parser): def MacroParser(self): @@ -174,6 +176,11 @@ class MetaFileParser(object): # UNI object and extra UNI object self._UniObj = None self._UniExtraObj = None +# StructPcd var +self._PcdCodeValue = "" +self._PcdDataTypeCODE = False +self._CurrentPcdName = "" +self._GuidDict = {} # for Parser PCD value {GUID(gTokeSpaceGuidName)} ## Store the parsed data in table def _Store(self, *Args): @@ -395,6 +402,40 @@ class MetaFileParser(object): Macros.update(self._SectionsMacroDict[(self._SectionType, Scope1, Scope2)]) return Macros +def ProcessMultipleLineCODEValue(self, Content): +CODEBegin = False +CODELine = "" +continuelinecount = 0 +newContent = [] +for Index in range(0, len(Content)): +Line = Content[Index] +if CODEBegin: +CODELine = CODELine + Line +continuelinecount +=1 +if ")}" in Line: +newContent.append(CODELine) +for _ in range(continuelinecount): +newContent.append("") +CODEBegin = False +CODELine = "" +continuelinecount = 0 +else: +if not Line: +newContent.append(Line) +continue +if "{CODE(" not in Line: +newContent.append(Line) +continue +elif CODEPattern.findall(Line): +newContent.append(Line) +continue +else: +CODEBegin = True +CODELine = Line + +return newContent + + _SectionParser = {} Finished= property(_GetFinished, _SetFinished) _Macros = property(_GetMacros) @@ -812,6 +853,8 @@ class DscParser(MetaFileParser): Content = open(str(self.MetaFile.Path), 'r').readlines() except: EdkLogger.error("Parser", FILE_READ_FAILURE, ExtraData=self.MetaFile) + +Content = self.ProcessMultipleLineCODEValue(Content) # # Insert a record for file # @@ -1018,24 +1061,71 @@ class DscParser(MetaFileParser): # @ParseMacro def _PcdParser(self): +if self._PcdDataTypeCODE: +self._PcdCodeValue = self._PcdCodeValue + "\n " + self._CurrentLine +if self._CurrentLine.endswith(")}"): +self._CurrentLine = "|".join((self._CurrentPcdName, self._PcdCodeValue)) +self._PcdDataTypeCODE = False +self._PcdCodeValue = "" +else: +self._ValueList = None +return TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT, 1) +self._CurrentPcdName = TokenList[0] +if len(TokenList) == 2 and TokenList[1].strip().startswith("{CODE"): +self._PcdDataTypeCODE = True +self._PcdCodeValue = TokenList[1].strip() + +if self._PcdDataTypeCODE: +if self._CurrentLine.endswith(")}"): +self._PcdDataTypeCODE = False +self._PcdCodeValue = "" +else: +self._ValueList = None +return self._ValueList[0:1] = GetSplitValueList(TokenList[0], TAB_SPLIT) +PcdNameTockens = GetSplitValueList(TokenList[0], TAB_SPLIT) +if len(PcdNameTockens) == 2: +