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 <[email protected]> --- Source/Python/Workspace/MetaFileParser.py | 11 ++++++++--- Source/Python/Workspace/WorkspaceDatabase.py | 8 +++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Source/Python/Workspace/MetaFileParser.py b/Source/Python/Workspace/MetaFileParser.py index fe1f7fd..e7d6df6 100644 --- a/Source/Python/Workspace/MetaFileParser.py +++ b/Source/Python/Workspace/MetaFileParser.py @@ -341,13 +341,18 @@ class MetaFileParser(object): self._ValueList = [ReplaceMacro(Value, self._Macros) for Value in self._ValueList] 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) if type(self) == InfParser and self._Version < 0x00010005: # EDK module allows using defines as macros diff --git a/Source/Python/Workspace/WorkspaceDatabase.py b/Source/Python/Workspace/WorkspaceDatabase.py index c84d192..46eb5d3 100644 --- a/Source/Python/Workspace/WorkspaceDatabase.py +++ b/Source/Python/Workspace/WorkspaceDatabase.py @@ -1953,11 +1953,17 @@ class InfBuildData(ModuleBuildClassObject): def _GetInfVersion(self): if self._AutoGenVersion == None: RecordList = self._RawData[MODEL_META_DATA_HEADER, self._Arch, self._Platform] for Record in RecordList: if Record[1] == TAB_INF_DEFINES_INF_VERSION: - self._AutoGenVersion = int(Record[2], 0) + if '.' in Record[2]: + ValueList = Record[2].split('.') + Major = '%04o' % int(ValueList[0], 0) + Minor = '%04o' % int(ValueList[1], 0) + self._AutoGenVersion = int('0x' + Major + Minor, 0) + else: + self._AutoGenVersion = int(Record[2], 0) break if self._AutoGenVersion == None: self._AutoGenVersion = 0x00010000 return self._AutoGenVersion -- 2.6.1.windows.1 _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

