]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFsp2Pkg/Tools/GenCfgOpt.py
IntelFsp2Pkg: Raise exception for invalid BSF option
[mirror_edk2.git] / IntelFsp2Pkg / Tools / GenCfgOpt.py
index e8cec95aa7352086a4bb5c44b34cb932464ca242..6dc1b10b34697c7b7fb490135c6cf9c767b0c628 100644 (file)
@@ -1,6 +1,6 @@
 ## @ GenCfgOpt.py\r
 #\r
-# Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2014 - 2017, 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
@@ -523,9 +523,16 @@ EndList
                                     if Match:\r
                                         IncludeFilePath = Match.group(1)\r
                                         IncludeFilePath = self.ExpandMacros(IncludeFilePath)\r
-                                        try:\r
-                                            IncludeDsc  = open(IncludeFilePath, "r")\r
-                                        except:\r
+                                        PackagesPath = os.getenv("PACKAGES_PATH")\r
+                                        if PackagesPath:\r
+                                          for PackagePath in PackagesPath.split(os.pathsep):\r
+                                              IncludeFilePathAbs = os.path.join(os.path.normpath(PackagePath), os.path.normpath(IncludeFilePath))\r
+                                              if os.path.exists(IncludeFilePathAbs):\r
+                                                  IncludeDsc  = open(IncludeFilePathAbs, "r")\r
+                                                  break\r
+                                        else:\r
+                                          IncludeDsc  = open(IncludeFilePath, "r")\r
+                                        if IncludeDsc == None:\r
                                             print("ERROR: Cannot open file '%s'" % IncludeFilePath)\r
                                             raise SystemExit\r
                                         NewDscLines = IncludeDsc.readlines()\r
@@ -875,6 +882,9 @@ EndList
         IsArray = False\r
         if Length in [1,2,4,8]:\r
             Type = "UINT%d" % (Length * 8)\r
+            if Name.startswith("UnusedUpdSpace") and Length != 1:\r
+                IsArray = True\r
+                Type = "UINT8"\r
         else:\r
             IsArray = True\r
             Type = "UINT8"\r
@@ -1129,7 +1139,7 @@ EndList
             HeaderFd.write("#ifndef __%s__\n"   % FileName)\r
             HeaderFd.write("#define __%s__\n\n" % FileName)\r
             HeaderFd.write("#include <%s>\n\n" % HeaderFileName)\r
-            HeaderFd.write("#pragma pack(push, 1)\n\n")\r
+            HeaderFd.write("#pragma pack(1)\n\n")\r
 \r
             Export = False\r
             for Line in IncLines:\r
@@ -1177,7 +1187,7 @@ EndList
                 for Item in range(len(StructStart)):\r
                     if Index >= StructStartWithComment[Item] and Index <= StructEnd[Item]:\r
                         HeaderFd.write (Line)\r
-            HeaderFd.write("#pragma pack(pop)\n\n")\r
+            HeaderFd.write("#pragma pack()\n\n")\r
             HeaderFd.write("#endif\n")\r
             HeaderFd.close()\r
 \r
@@ -1188,7 +1198,7 @@ EndList
         HeaderFd.write("#ifndef __%s__\n"   % FileName)\r
         HeaderFd.write("#define __%s__\n\n" % FileName)\r
         HeaderFd.write("#include <FspEas.h>\n\n")\r
-        HeaderFd.write("#pragma pack(push, 1)\n\n")\r
+        HeaderFd.write("#pragma pack(1)\n\n")\r
 \r
         for item in range(len(UpdRegionCheck)):\r
             Index = 0\r
@@ -1222,13 +1232,14 @@ EndList
                 for Item in range(len(StructStart)):\r
                     if Index >= StructStartWithComment[Item] and Index <= StructEnd[Item]:\r
                         HeaderFd.write (Line)\r
-        HeaderFd.write("#pragma pack(pop)\n\n")\r
+        HeaderFd.write("#pragma pack()\n\n")\r
         HeaderFd.write("#endif\n")\r
         HeaderFd.close()\r
 \r
         return 0\r
 \r
     def WriteBsfStruct  (self, BsfFd, Item):\r
+        LogExpr = CLogicalExpression()\r
         if Item['type'] == "None":\r
             Space = "gPlatformFspPkgTokenSpaceGuid"\r
         else:\r
@@ -1250,6 +1261,9 @@ EndList
                 for Option in OptList:\r
                     Option = Option.strip()\r
                     (OpVal, OpStr) = Option.split(':')\r
+                    test = LogExpr.getNumber (OpVal)\r
+                    if test is None:\r
+                        raise Exception("Selection Index '%s' is not a number" % OpVal)\r
                     TmpList.append((OpVal, OpStr))\r
         return  TmpList\r
 \r
@@ -1418,11 +1432,12 @@ def Main():
             else:\r
                 OutFile = sys.argv[4]\r
                 Start = 5\r
-            GenCfgOpt.ParseBuildMode(sys.argv[3])\r
-            if GenCfgOpt.ParseMacros(sys.argv[Start:]) != 0:\r
-                print "ERROR: Macro parsing failed !"\r
-                return 3\r
+            if argc > Start:\r
+                if GenCfgOpt.ParseMacros(sys.argv[Start:]) != 0:\r
+                    print "ERROR: Macro parsing failed !"\r
+                    return 3\r
 \r
+        GenCfgOpt.ParseBuildMode(sys.argv[3])\r
         FvDir = sys.argv[3]\r
         if not os.path.exists(FvDir):\r
             os.makedirs(FvDir)\r