]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Allow decimal values in the EDK II meta-data file
authorYonghong Zhu <yonghong.zhu@intel.com>
Mon, 9 Nov 2015 07:43:07 +0000 (07:43 +0000)
committeryzhu52 <yzhu52@Edk2>
Mon, 9 Nov 2015 07:43:07 +0000 (07:43 +0000)
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 <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
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
BaseTools/Source/Python/Workspace/WorkspaceDatabase.py

index fe1f7fd6f642bf76effea2e4d34a4ff1c1fa2184..e7d6df659590b00f138ea9c982c7b5993de59a8e 100644 (file)
@@ -343,9 +343,14 @@ class MetaFileParser(object):
         Name, Value = self._ValueList[1], self._ValueList[2]\r
         # Sometimes, we need to make differences between EDK and EDK2 modules \r
         if Name == 'INF_VERSION':\r
-            try:\r
-                self._Version = int(Value, 0)\r
-            except:\r
+            if re.match(r'0[xX][\da-f-A-F]{5,8}', Value):\r
+                self._Version = int(Value, 0)   \r
+            elif re.match(r'\d+\.\d+', Value):\r
+                ValueList = Value.split('.')\r
+                Major = '%04o' % int(ValueList[0], 0)\r
+                Minor = '%04o' % int(ValueList[1], 0)\r
+                self._Version = int('0x' + Major + Minor, 0)\r
+            else:\r
                 EdkLogger.error('Parser', FORMAT_INVALID, "Invalid version number",\r
                                 ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)\r
 \r
index c84d19243c76e10fd1cef78c98f08c1e6045ee68..46eb5d3a8c2f4d9ce29fb37dc4014eb48cd68450 100644 (file)
@@ -1955,7 +1955,13 @@ class InfBuildData(ModuleBuildClassObject):
             RecordList = self._RawData[MODEL_META_DATA_HEADER, self._Arch, self._Platform]\r
             for Record in RecordList:\r
                 if Record[1] == TAB_INF_DEFINES_INF_VERSION:\r
-                    self._AutoGenVersion = int(Record[2], 0)\r
+                    if '.' in Record[2]:\r
+                        ValueList = Record[2].split('.')\r
+                        Major = '%04o' % int(ValueList[0], 0)\r
+                        Minor = '%04o' % int(ValueList[1], 0)\r
+                        self._AutoGenVersion = int('0x' + Major + Minor, 0)\r
+                    else:\r
+                        self._AutoGenVersion = int(Record[2], 0)\r
                     break\r
             if self._AutoGenVersion == None:\r
                 self._AutoGenVersion = 0x00010000\r