[edk2-devel] [PATCH EDK2 v1 1/1] BaseTools:Support decimal version number in ECC check
wenyi,xie via groups.io
xiewenyi2=huawei.com at groups.io
Fri Mar 18 06:09:24 UTC 2022
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 at intel.com>
Cc: Liming Gao <gaoliming at byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen at intel.com>
Signed-off-by: Wenyi Xie <xiewenyi2 at 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
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87732): https://edk2.groups.io/g/devel/message/87732
Mute This Topic: https://groups.io/mt/89862756/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list