diff options
author | wenyi,xie via groups.io <xiewenyi2=huawei.com@groups.io> | 2022-03-18 14:09:24 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2022-03-28 01:45:05 +0000 |
commit | ec30a4a0c324cf24f1824ab5169923f854986798 (patch) | |
tree | 73dc30c3890568aa80202bad86d8cae797aa164a /BaseTools | |
parent | 22130dcd98b4d4b76ac8d922adb4a2dbc86fa52c (diff) | |
download | edk2-ec30a4a0c324cf24f1824ab5169923f854986798.tar.gz edk2-ec30a4a0c324cf24f1824ab5169923f854986798.tar.bz2 edk2-ec30a4a0c324cf24f1824ab5169923f854986798.zip |
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>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Diffstat (limited to 'BaseTools')
-rw-r--r-- | BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py index 9c27c8e16a..2d98ac5ead 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):
|