]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/FdfParser.py
BaseTools: FdfParser remove class never used.
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / FdfParser.py
index 2782be4b984956b5ed703814789965f69a7014a3..e35057931f03e9c5fd0d5add5aff775725e747ea 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # parse FDF file\r
 #\r
-#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 #  Copyright (c) 2015, Hewlett Packard Enterprise Development, L.P.<BR>\r
 #\r
 #  This program and the accompanying materials\r
@@ -59,6 +59,7 @@ import Common.LongFilePathOs as os
 from Common.LongFilePathSupport import OpenLongFilePath as open\r
 from Capsule import EFI_CERT_TYPE_PKCS7_GUID\r
 from Capsule import EFI_CERT_TYPE_RSA2048_SHA256_GUID\r
+from Common.RangeExpression import RangeExpression\r
 \r
 ##define T_CHAR_SPACE                ' '\r
 ##define T_CHAR_NULL                 '\0'\r
@@ -135,21 +136,6 @@ class Warning (Exception):
     def __str__(self):\r
         return self.Message\r
 \r
-## The MACRO class that used to record macro value data when parsing include file\r
-#\r
-#\r
-class MacroProfile :\r
-    ## The constructor\r
-    #\r
-    #   @param  self        The object pointer\r
-    #   @param  FileName    The file that to be parsed\r
-    #\r
-    def __init__(self, FileName, Line):\r
-        self.FileName = FileName\r
-        self.DefinedAtLine  = Line\r
-        self.MacroName = None\r
-        self.MacroValue = None\r
-\r
 ## The Include file content class that used to record file data when parsing include file\r
 #\r
 # May raise Exception when opening file.\r
@@ -167,6 +153,10 @@ class IncludeFileProfile :
             fsock = open(FileName, "rb", 0)\r
             try:\r
                 self.FileLinesList = fsock.readlines()\r
+                for index, line in enumerate(self.FileLinesList):\r
+                    if not line.endswith('\n'):\r
+                        self.FileLinesList[index] += '\n'\r
+\r
             finally:\r
                 fsock.close()\r
 \r
@@ -921,6 +911,13 @@ class FdfParser:
 \r
         MacroDict.update(GlobalData.gGlobalDefines)\r
         MacroDict.update(GlobalData.gCommandLineDefines)\r
+        if GlobalData.BuildOptionPcd:\r
+            for Item in GlobalData.BuildOptionPcd:\r
+                if type(Item) is tuple:\r
+                    continue\r
+                PcdName, TmpValue = Item.split("=")\r
+                TmpValue = BuildOptionValue(TmpValue, {})\r
+                MacroDict[PcdName.strip()] = TmpValue\r
         # Highest priority\r
 \r
         return MacroDict\r
@@ -1138,8 +1135,7 @@ class FdfParser:
 \r
         if not self.__GetNextToken():\r
             return False\r
-        p = re.compile('[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}')\r
-        if p.match(self.__Token) != None:\r
+        if RangeExpression.RegGuidPattern.match(self.__Token) != None:\r
             return True\r
         else:\r
             self.__UndoToken()\r
@@ -2307,7 +2303,7 @@ class FdfParser:
                            "WRITE_DISABLED_CAP", "WRITE_STATUS", "READ_ENABLED_CAP", \\r
                            "READ_DISABLED_CAP", "READ_STATUS", "READ_LOCK_CAP", \\r
                            "READ_LOCK_STATUS", "WRITE_LOCK_CAP", "WRITE_LOCK_STATUS", \\r
-                           "WRITE_POLICY_RELIABLE", "WEAK_ALIGNMENT"):\r
+                           "WRITE_POLICY_RELIABLE", "WEAK_ALIGNMENT", "FvUsedSizeEnable"):\r
                 self.__UndoToken()\r
                 return False\r
 \r
@@ -2361,7 +2357,7 @@ class FdfParser:
 \r
     def __GetFvExtEntryStatement(self, FvObj):\r
 \r
-        if not self.__IsKeyword( "FV_EXT_ENTRY"):\r
+        if not (self.__IsKeyword( "FV_EXT_ENTRY") or self.__IsKeyword( "FV_EXT_ENTRY_TYPE")):\r
             return False\r
 \r
         if not self.__IsKeyword ("TYPE"):\r
@@ -2482,6 +2478,8 @@ class FdfParser:
         if not self.__GetNextToken():\r
             raise Warning("expected INF file path", self.FileName, self.CurrentLineNumber)\r
         ffsInf.InfFileName = self.__Token\r
+        if not ffsInf.InfFileName.endswith('.inf'):\r
+            raise Warning("expected .inf file path", self.FileName, self.CurrentLineNumber)\r
 \r
         ffsInf.CurrentLineNum = self.CurrentLineNumber\r
         ffsInf.CurrentLineContent = self.__CurrentLine()\r
@@ -2763,7 +2761,8 @@ class FdfParser:
         while True:\r
             AlignValue = None\r
             if self.__GetAlignment():\r
-                if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):\r
+                if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",\r
+                                        "256K", "512K", "1M", "2M", "4M", "8M", "16M"):\r
                     raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)\r
                 #For FFS, Auto is default option same to ""\r
                 if not self.__Token == "Auto":\r
@@ -2822,7 +2821,8 @@ class FdfParser:
             FfsFileObj.CheckSum = True\r
 \r
         if self.__GetAlignment():\r
-            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):\r
+            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",\r
+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):\r
                 raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)\r
             #For FFS, Auto is default option same to ""\r
             if not self.__Token == "Auto":\r
@@ -2893,7 +2893,8 @@ class FdfParser:
 \r
         AlignValue = None\r
         if self.__GetAlignment():\r
-            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):\r
+            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",\r
+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):\r
                 raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)\r
             AlignValue = self.__Token\r
 \r
@@ -3182,7 +3183,8 @@ class FdfParser:
 \r
         AlignValue = None\r
         if self.__GetAlignment():\r
-            if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):\r
+            if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",\r
+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):\r
                 raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)\r
             AlignValue = self.__Token\r
 \r
@@ -3773,7 +3775,8 @@ class FdfParser:
 \r
         AlignValue = ""\r
         if self.__GetAlignment():\r
-            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):\r
+            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",\r
+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):\r
                 raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)\r
             #For FFS, Auto is default option same to ""\r
             if not self.__Token == "Auto":\r
@@ -3822,7 +3825,8 @@ class FdfParser:
 \r
             SectAlignment = ""\r
             if self.__GetAlignment():\r
-                if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):\r
+                if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",\r
+                                        "256K", "512K", "1M", "2M", "4M", "8M", "16M"):\r
                     raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)\r
                 if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not SectionName == 'TE'):\r
                     raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)\r
@@ -3901,7 +3905,8 @@ class FdfParser:
                 FvImageSectionObj.FvFileType = self.__Token\r
 \r
                 if self.__GetAlignment():\r
-                    if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):\r
+                    if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",\r
+                                            "256K", "512K", "1M", "2M", "4M", "8M", "16M"):\r
                         raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)\r
                     FvImageSectionObj.Alignment = self.__Token\r
 \r
@@ -3968,7 +3973,8 @@ class FdfParser:
                 EfiSectionObj.BuildNum = self.__Token\r
 \r
         if self.__GetAlignment():\r
-            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):\r
+            if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",\r
+                                    "256K", "512K", "1M", "2M", "4M", "8M", "16M"):\r
                 raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)\r
             if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not SectionName == 'TE'):\r
                 raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)\r