]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFsp2Pkg/Tools/GenCfgOpt.py
IntelFsp2Pkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / IntelFsp2Pkg / Tools / GenCfgOpt.py
index 04b61a5672c8554eeef3382216d683b4a02e09fb..450c4e3eb9ecb6528fa8f9ae0640a138b18d069d 100644 (file)
@@ -1,13 +1,7 @@
 ## @ GenCfgOpt.py\r
 #\r
 # Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>\r
-# This program and the accompanying materials are licensed and made available under\r
-# the terms and conditions of the BSD License that accompanies this distribution.\r
-# The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php.\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 ##\r
 \r
@@ -88,6 +82,8 @@ are permitted provided that the following conditions are met:
 **/\r
 """\r
 \r
+BuildOptionPcd = []\r
+\r
 class CLogicalExpression:\r
     def __init__(self):\r
         self.index    = 0\r
@@ -561,6 +557,12 @@ EndList
                     self._PcdsDict[Match.group(1)] = Match.group(2)\r
                     if self.Debug:\r
                         print "INFO : PCD %s = [ %s ]" % (Match.group(1), Match.group(2))\r
+                    i = 0\r
+                    while i < len(BuildOptionPcd):\r
+                        Match = re.match("\s*([\w\.]+)\s*\=\s*(\w+)", BuildOptionPcd[i])\r
+                        if Match:\r
+                            self._PcdsDict[Match.group(1)] = Match.group(2)\r
+                        i += 1\r
             else:\r
                 Match = re.match("^\s*#\s+(!BSF|@Bsf|!HDR)\s+(.+)", DscLine)\r
                 if Match:\r
@@ -1038,6 +1040,13 @@ EndList
         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
@@ -1237,7 +1246,7 @@ EndList
                 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
@@ -1282,7 +1291,7 @@ EndList
                 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
@@ -1455,7 +1464,7 @@ EndList
 \r
 \r
 def Usage():\r
-    print "GenCfgOpt Version 0.52"\r
+    print "GenCfgOpt Version 0.53"\r
     print "Usage:"\r
     print "    GenCfgOpt  UPDTXT  PlatformDscFile BuildFvDir                 [-D Macros]"\r
     print "    GenCfgOpt  HEADER  PlatformDscFile BuildFvDir  InputHFile     [-D Macros]"\r
@@ -1465,7 +1474,14 @@ def Main():
     #\r
     # Parse the options and args\r
     #\r
+    i = 1\r
+\r
     GenCfgOpt = CGenCfgOpt()\r
+    while i < len(sys.argv):\r
+        if sys.argv[i].strip().lower() == "--pcd":\r
+            BuildOptionPcd.append(sys.argv[i+1])\r
+            i += 1\r
+        i += 1\r
     argc = len(sys.argv)\r
     if argc < 4:\r
         Usage()\r