]> git.proxmox.com Git - mirror_edk2.git/commitdiff
GenCfgOpt.py: remove tailing space from output file
authorChasel, Chiu <chasel.chiu@intel.com>
Wed, 26 Sep 2018 11:50:42 +0000 (19:50 +0800)
committerChasel, Chiu <chasel.chiu@intel.com>
Fri, 28 Sep 2018 00:44:46 +0000 (08:44 +0800)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1212

UPD header files generated by GenCfgOpt.py may have
tailing white space from some of the UPD description in DSC,
especially when python script automatically switching lines
for long description string. This patch will always remove
tailing white space for UPD header files.

Test: Verified the patch can remove tailing space in
      output header files when UPD DSC contains intentional
      tailing white space.

Cc: Jiewen Yao <Jiewen.yao@intel.com>
Cc: Gao Liming <liming.gao@intel.com>
Cc: Zhu Yonghong <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
IntelFsp2Pkg/Tools/GenCfgOpt.py

index 04b61a5672c8554eeef3382216d683b4a02e09fb..059cfcb7e4179ba7b91b939f4f11f5539962b07e 100644 (file)
@@ -1038,6 +1038,13 @@ EndList
         NewTextBody.extend(OldTextBody)\r
         return NewTextBody\r
 \r
         NewTextBody.extend(OldTextBody)\r
         return NewTextBody\r
 \r
+    def WriteLinesWithoutTailingSpace (self, HeaderFd, Line):\r
+        TxtBody2 = Line.splitlines(True)\r
+        for Line2 in TxtBody2:\r
+            Line2 = Line2.rstrip()\r
+            Line2 += '\n'\r
+            HeaderFd.write (Line2)\r
+        return 0\r
     def CreateHeaderFile (self, InputHeaderFile):\r
         FvDir = self._FvDir\r
 \r
     def CreateHeaderFile (self, InputHeaderFile):\r
         FvDir = self._FvDir\r
 \r
@@ -1237,7 +1244,7 @@ EndList
                 Index += 1\r
                 for Item in range(len(StructStart)):\r
                     if Index >= StructStartWithComment[Item] and Index <= StructEnd[Item]:\r
                 Index += 1\r
                 for Item in range(len(StructStart)):\r
                     if Index >= StructStartWithComment[Item] and Index <= StructEnd[Item]:\r
-                        HeaderFd.write (Line)\r
+                        self.WriteLinesWithoutTailingSpace(HeaderFd, Line)\r
             HeaderFd.write("#pragma pack()\n\n")\r
             HeaderFd.write("#endif\n")\r
             HeaderFd.close()\r
             HeaderFd.write("#pragma pack()\n\n")\r
             HeaderFd.write("#endif\n")\r
             HeaderFd.close()\r
@@ -1282,7 +1289,7 @@ EndList
                 Index += 1\r
                 for Item in range(len(StructStart)):\r
                     if Index >= StructStartWithComment[Item] and Index <= StructEnd[Item]:\r
                 Index += 1\r
                 for Item in range(len(StructStart)):\r
                     if Index >= StructStartWithComment[Item] and Index <= StructEnd[Item]:\r
-                        HeaderFd.write (Line)\r
+                        self.WriteLinesWithoutTailingSpace(HeaderFd, Line)\r
         HeaderFd.write("#pragma pack()\n\n")\r
         HeaderFd.write("#endif\n")\r
         HeaderFd.close()\r
         HeaderFd.write("#pragma pack()\n\n")\r
         HeaderFd.write("#endif\n")\r
         HeaderFd.close()\r