* [PATCH EDK2 v1 0/1] BaseTools:Support decimal version number in ECC check @ 2022-03-18 6:09 wenyi,xie 2022-03-18 6:09 ` [PATCH EDK2 v1 1/1] " wenyi,xie 0 siblings, 1 reply; 3+ messages in thread From: wenyi,xie @ 2022-03-18 6:09 UTC (permalink / raw) To: devel, bob.c.feng, gaoliming, yuwei.chen; +Cc: songdongkuang, xiewenyi2 Main Changes : 1.support decimal type version number when running ecc check. Wenyi Xie (1): BaseTools:Support decimal version number in ECC check BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) -- 2.20.1.windows.1 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH EDK2 v1 1/1] BaseTools:Support decimal version number in ECC check 2022-03-18 6:09 [PATCH EDK2 v1 0/1] BaseTools:Support decimal version number in ECC check wenyi,xie @ 2022-03-18 6:09 ` wenyi,xie 2022-03-26 12:32 ` [edk2-devel] " Bob Feng 0 siblings, 1 reply; 3+ messages in thread From: wenyi,xie @ 2022-03-18 6:09 UTC (permalink / raw) To: devel, bob.c.feng, gaoliming, yuwei.chen; +Cc: songdongkuang, xiewenyi2 REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3872 When doing ecc inf version check, the decimal type version number like 1.27 is treated as invalid version. So the code should be updated to support decimal type version number. Cc: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Yuwei Chen <yuwei.chen@intel.com> Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com> --- BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py index 9c27c8e16a05..2d98ac5eadb2 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py @@ -31,6 +31,10 @@ from GenFds.FdfParser import FdfParser from Common.LongFilePathSupport import OpenLongFilePath as open from Common.LongFilePathSupport import CodecOpenLongFilePath +## RegEx for finding file versions +hexVersionPattern = re.compile(r'0[xX][\da-f-A-F]{5,8}') +decVersionPattern = re.compile(r'\d+\.\d+') + ## A decorator used to parse macro definition def ParseMacro(Parser): def MacroParser(self): @@ -331,11 +335,19 @@ class MetaFileParser(object): Name, Value = self._ValueList[1], self._ValueList[2] # Sometimes, we need to make differences between EDK and EDK2 modules if Name == 'INF_VERSION': - try: + if hexVersionPattern.match(Value): self._Version = int(Value, 0) - except: + elif decVersionPattern.match(Value): + ValueList = Value.split('.') + Major = int(ValueList[0], 0) + Minor = int(ValueList[1], 0) + if Major > 0xffff or Minor > 0xffff: + EdkLogger.error('Parser', FORMAT_INVALID, "Invalid version number", + ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) + self._Version = int('0x{0:04x}{1:04x}'.format(Major, Minor), 0) + else: EdkLogger.error('Parser', FORMAT_INVALID, "Invalid version number", - ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1) + ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) elif Name == 'MODULE_UNI_FILE': UniFile = os.path.join(os.path.dirname(self.MetaFile), Value) if os.path.exists(UniFile): -- 2.20.1.windows.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [edk2-devel] [PATCH EDK2 v1 1/1] BaseTools:Support decimal version number in ECC check 2022-03-18 6:09 ` [PATCH EDK2 v1 1/1] " wenyi,xie @ 2022-03-26 12:32 ` Bob Feng 0 siblings, 0 replies; 3+ messages in thread From: Bob Feng @ 2022-03-26 12:32 UTC (permalink / raw) To: devel@edk2.groups.io, xiewenyi2@huawei.com, Gao, Liming, Chen, Christine Cc: songdongkuang@huawei.com This patch looks good. Reviewed-by: Bob Feng<bob.c.feng@intel.com> -----Original Message----- From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of wenyi,xie via groups.io Sent: Friday, March 18, 2022 2:09 PM To: devel@edk2.groups.io; Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; Chen, Christine <yuwei.chen@intel.com> Cc: songdongkuang@huawei.com; xiewenyi2@huawei.com Subject: [edk2-devel] [PATCH EDK2 v1 1/1] BaseTools:Support decimal version number in ECC check REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3872 When doing ecc inf version check, the decimal type version number like 1.27 is treated as invalid version. So the code should be updated to support decimal type version number. Cc: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Yuwei Chen <yuwei.chen@intel.com> Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com> --- BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py index 9c27c8e16a05..2d98ac5eadb2 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py @@ -31,6 +31,10 @@ from GenFds.FdfParser import FdfParser from Common.LongFilePathSupport import OpenLongFilePath as open from Common.LongFilePathSupport import CodecOpenLongFilePath +## RegEx for finding file versions +hexVersionPattern = re.compile(r'0[xX][\da-f-A-F]{5,8}') +decVersionPattern = re.compile(r'\d+\.\d+') + ## A decorator used to parse macro definition def ParseMacro(Parser): def MacroParser(self): @@ -331,11 +335,19 @@ class MetaFileParser(object): Name, Value = self._ValueList[1], self._ValueList[2] # Sometimes, we need to make differences between EDK and EDK2 modules if Name == 'INF_VERSION': - try: + if hexVersionPattern.match(Value): self._Version = int(Value, 0) - except: + elif decVersionPattern.match(Value): + ValueList = Value.split('.') + Major = int(ValueList[0], 0) + Minor = int(ValueList[1], 0) + if Major > 0xffff or Minor > 0xffff: + EdkLogger.error('Parser', FORMAT_INVALID, "Invalid version number", + ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) + self._Version = int('0x{0:04x}{1:04x}'.format(Major, Minor), 0) + else: EdkLogger.error('Parser', FORMAT_INVALID, "Invalid version number", - ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1) + ExtraData=self._CurrentLine, + File=self.MetaFile, Line=self._LineIndex + 1) elif Name == 'MODULE_UNI_FILE': UniFile = os.path.join(os.path.dirname(self.MetaFile), Value) if os.path.exists(UniFile): -- 2.20.1.windows.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-03-26 12:32 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-03-18 6:09 [PATCH EDK2 v1 0/1] BaseTools:Support decimal version number in ECC check wenyi,xie 2022-03-18 6:09 ` [PATCH EDK2 v1 1/1] " wenyi,xie 2022-03-26 12:32 ` [edk2-devel] " Bob Feng
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox