From 3ab1434a6ede4e006ef0b001108c354f4fa6d91e Mon Sep 17 00:00:00 2001 From: Yonghong Zhu Date: Mon, 9 Nov 2015 07:43:07 +0000 Subject: BaseTools: Allow decimal values in the EDK II meta-data file Because the EDK II meta-data specifications already allow using decimal values in the EDK II Meta-data file [Defines] section, this patch update code to allow this usage. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18746 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Source/Python/Workspace/MetaFileParser.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'BaseTools/Source/Python/Workspace/MetaFileParser.py') diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index fe1f7fd6f6..e7d6df6595 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -343,9 +343,14 @@ 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: - self._Version = int(Value, 0) - except: + if re.match(r'0[xX][\da-f-A-F]{5,8}', Value): + self._Version = int(Value, 0) + elif re.match(r'\d+\.\d+', Value): + ValueList = Value.split('.') + Major = '%04o' % int(ValueList[0], 0) + Minor = '%04o' % int(ValueList[1], 0) + self._Version = int('0x' + Major + Minor, 0) + else: EdkLogger.error('Parser', FORMAT_INVALID, "Invalid version number", ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1) -- cgit v1.2.3