]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Scripts/ConvertFceToStructurePcd.py
BaseTools: Adjust StructurePcd List Order.
[mirror_edk2.git] / BaseTools / Scripts / ConvertFceToStructurePcd.py
index 867660fba9cfd3890c32a5fd72ea6584e92ae473..91361ea2b94dad1d270efa8502453576d2b48510 100644 (file)
@@ -277,6 +277,7 @@ class Config(object):
     attribute_re=re.compile(r'attribute=(\w+)')\r
     value_re = re.compile(r'(//.*)')\r
     part = []\r
+    part_without_comment = []\r
     for x in section[1:]:\r
         line=x.split('\n')[0]\r
         comment_list = value_re.findall(line) # the string \\... in "Q...." line\r
@@ -293,8 +294,18 @@ class Config(object):
           if attribute[0] in ['0x3','0x7']:\r
             offset = int(offset[0], 16)\r
             #help = help_re.findall(x)\r
-            text = offset, name[0], guid[0], value, attribute[0], comment\r
-            part.append(text)\r
+            text_without_comment = offset, name[0], guid[0], value, attribute[0]\r
+            if text_without_comment in part_without_comment:\r
+                # check if exists same Pcd with different comments, add different comments in one line with "|".\r
+                dupl_index = part_without_comment.index(text_without_comment)\r
+                part[dupl_index] = list(part[dupl_index])\r
+                if comment not in part[dupl_index][-1]:\r
+                    part[dupl_index][-1] += " | " + comment\r
+                part[dupl_index] = tuple(part[dupl_index])\r
+            else:\r
+                text = offset, name[0], guid[0], value, attribute[0], comment\r
+                part_without_comment.append(text_without_comment)\r
+                part.append(text)\r
     return(part)\r
 \r
   def value_parser(self, list1):\r
@@ -532,6 +543,18 @@ class mainprocess(object):
       i.sort()\r
     return keys,title_all,info_list,header_list,inf_list\r
 \r
+  def correct_sort(self, PcdString):\r
+    # sort the Pcd list with two rules:\r
+    # First sort through Pcd name;\r
+    # Second if the Pcd exists several elements, sort them through index value.\r
+    if ("]|") in PcdString:\r
+        Pcdname = PcdString.split("[")[0]\r
+        Pcdindex = int(PcdString.split("[")[1].split("]")[0])\r
+    else:\r
+        Pcdname = PcdString.split("|")[0]\r
+        Pcdindex = 0\r
+    return Pcdname, Pcdindex\r
+\r
   def remove_bracket(self,List):\r
     for i in List:\r
       for j in i:\r
@@ -543,7 +566,7 @@ class mainprocess(object):
           List[List.index(i)][i.index(j)] = j\r
     for i in List:\r
       if type(i) == type([0,0]):\r
-        i.sort()\r
+        i.sort(key = lambda x:(self.correct_sort(x)[0], self.correct_sort(x)[1]))\r
     return List\r
 \r
   def write_all(self):\r