diff options
author | Yunhua Feng <yunhuax.feng@intel.com> | 2017-06-22 11:19:47 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2017-06-24 23:01:37 +0800 |
commit | 778aad47e8eed49cecb7e1bd7650d878d9ea50e3 (patch) | |
tree | b0758efed1b98cfbc1ab90e225b61038b75b2456 /BaseTools/Source/Python | |
parent | dfa41b4a483e562f3c739acfbc2d911550f50e47 (diff) | |
download | edk2-778aad47e8eed49cecb7e1bd7650d878d9ea50e3.tar.gz edk2-778aad47e8eed49cecb7e1bd7650d878d9ea50e3.tar.bz2 edk2-778aad47e8eed49cecb7e1bd7650d878d9ea50e3.zip |
BaseTools: Enhance DEC Defines section format check
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.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'BaseTools/Source/Python')
-rw-r--r-- | BaseTools/Source/Python/Workspace/MetaFileParser.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index d094403a00..6e236e68b0 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1656,6 +1656,7 @@ class DecParser(MetaFileParser): 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
@@ -1671,8 +1672,15 @@ class DecParser(MetaFileParser): # 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
@@ -1720,6 +1728,10 @@ class DecParser(MetaFileParser): 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()
@@ -1745,6 +1757,9 @@ class DecParser(MetaFileParser): # 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])
|