From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mx.groups.io with SMTP id smtpd.web09.6658.1647583828713755353 for ; Thu, 17 Mar 2022 23:10:29 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: huawei.com, ip: 45.249.212.187, mailfrom: xiewenyi2@huawei.com) Received: from kwepemi100005.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KKYXJ2bBVzcb4h; Fri, 18 Mar 2022 14:10:24 +0800 (CST) Received: from kwepemm600004.china.huawei.com (7.193.23.242) by kwepemi100005.china.huawei.com (7.221.188.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Fri, 18 Mar 2022 14:10:26 +0800 Received: from kwephisprg16640.huawei.com (10.247.83.252) by kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Fri, 18 Mar 2022 14:10:25 +0800 From: "wenyi,xie" To: , , , CC: , Subject: [PATCH EDK2 v1 1/1] BaseTools:Support decimal version number in ECC check Date: Fri, 18 Mar 2022 14:09:24 +0800 Message-ID: <20220318060924.480865-2-xiewenyi2@huawei.com> X-Mailer: git-send-email 2.18.0.huawei.25 In-Reply-To: <20220318060924.480865-1-xiewenyi2@huawei.com> References: <20220318060924.480865-1-xiewenyi2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.247.83.252] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600004.china.huawei.com (7.193.23.242) X-CFilter-Loop: Reflected Content-Type: text/plain 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 Cc: Liming Gao Cc: Yuwei Chen Signed-off-by: Wenyi Xie --- 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