]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Add comments in StructurePcd DSC file.
authorChen, Christine <Yuwei.Chen@intel.com>
Mon, 7 Dec 2020 07:57:54 +0000 (15:57 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 15 Dec 2020 07:17:12 +0000 (07:17 +0000)
Currently VFR files have variables comments which will not be
added into StructurePcd.dsc file. Thus, it is not convenient for
developer to Modify Pcds. To solve this problem, The comments will
be modified to user friendly format and added after the corresponding
Pcd values in StructurePcd.dsc file.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Yuwei Chen <yuwei.chen@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
BaseTools/Scripts/ConvertFceToStructurePcd.py

index aeda3ff26dfe5c11dddf624de4c4c28a203bf040..867660fba9cfd3890c32a5fd72ea6584e92ae473 100644 (file)
@@ -52,6 +52,7 @@ infstatement = '''[Pcd]
 \r
 SECTION='PcdsDynamicHii'\r
 PCD_NAME='gStructPcdTokenSpaceGuid.Pcd'\r
+Max_Pcd_Len = 100\r
 \r
 WARNING=[]\r
 ERRORMSG=[]\r
@@ -278,6 +279,9 @@ class Config(object):
     part = []\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
+        comment_list[0] = comment_list[0].replace('//', '')\r
+        comment = comment_list[0].strip()\r
         line=value_re.sub('',line) #delete \\... in "Q...." line\r
         list1=line.split(' ')\r
         value=self.value_parser(list1)\r
@@ -289,7 +293,7 @@ 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]\r
+            text = offset, name[0], guid[0], value, attribute[0], comment\r
             part.append(text)\r
     return(part)\r
 \r
@@ -479,7 +483,7 @@ class mainprocess(object):
       tmp_id=[id_key] #['0_0',[(struct,[name...]),(struct,[name...])]]\r
       tmp_info={} #{name:struct}\r
       for section in config_dict[id_key]:\r
-        c_offset,c_name,c_guid,c_value,c_attribute = section\r
+        c_offset,c_name,c_guid,c_value,c_attribute,c_comment = section\r
         if c_name in efi_dict:\r
           struct = efi_dict[c_name]\r
           title='%s%s|L"%s"|%s|0x00||%s\n'%(PCD_NAME,c_name,c_name,self.guid.guid_parser(c_guid),self.attribute_dict[c_attribute])\r
@@ -499,9 +503,14 @@ class mainprocess(object):
           if c_offset in struct_dict:\r
             offset_name=struct_dict[c_offset]\r
             info = "%s%s.%s|%s\n"%(PCD_NAME,c_name,offset_name,c_value)\r
+            blank_length = Max_Pcd_Len - len(info)\r
+            if blank_length <= 0:\r
+                info_comment = "%s%s.%s|%s%s# %s\n"%(PCD_NAME,c_name,offset_name,c_value,"     ",c_comment)\r
+            else:\r
+                info_comment = "%s%s.%s|%s%s# %s\n"%(PCD_NAME,c_name,offset_name,c_value,blank_length*" ",c_comment)\r
             inf = "%s%s\n"%(PCD_NAME,c_name)\r
             inf_list.append(inf)\r
-            tmp_info[info]=title\r
+            tmp_info[info_comment]=title\r
           else:\r
             print("ERROR: Can't find offset %s with struct name %s"%(c_offset,struct))\r
             ERRORMSG.append("ERROR: Can't find offset %s with name %s"%(c_offset,struct))\r