]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
BaseTools/ECC: Fix some issues of ECC tool
[mirror_edk2.git] / BaseTools / Source / Python / Ecc / MetaFileWorkspace / MetaFileParser.py
index 6da2b6babe5ca21610474c2a530ff84dfe762ce2..9f31d4d4de07a7386c2e35c5445467562c621241 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is used to parse meta files\r
 #\r
-# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -14,7 +14,7 @@
 ##\r
 # Import Modules\r
 #\r
-import os\r
+import Common.LongFilePathOs as os\r
 import re\r
 import time\r
 import copy\r
@@ -31,7 +31,8 @@ from Common.Expression import *
 from CommonDataClass.Exceptions import *\r
 \r
 from MetaFileTable import MetaFileStorage\r
-from GenFds.FdfParser import FdfParser  \r
+from GenFds.FdfParser import FdfParser\r
+from Common.LongFilePathSupport import OpenLongFilePath as open\r
 \r
 ## A decorator used to parse macro definition\r
 def ParseMacro(Parser):\r
@@ -432,6 +433,7 @@ class InfParser(MetaFileParser):
     def Start(self):\r
         NmakeLine = ''\r
         Content = ''\r
+        Usage = ''\r
         try:\r
             Content = open(str(self.MetaFile), 'r').readlines()\r
         except:\r
@@ -450,8 +452,27 @@ class InfParser(MetaFileParser):
         IsFindBlockComment = False\r
 \r
         for Index in range(0, len(Content)):\r
+            if self._SectionType in [MODEL_EFI_GUID,\r
+                                     MODEL_EFI_PROTOCOL,\r
+                                     MODEL_EFI_PPI,\r
+                                     MODEL_PCD_FIXED_AT_BUILD,\r
+                                     MODEL_PCD_PATCHABLE_IN_MODULE,\r
+                                     MODEL_PCD_FEATURE_FLAG,\r
+                                     MODEL_PCD_DYNAMIC_EX,\r
+                                     MODEL_PCD_DYNAMIC]:\r
+                Line = Content[Index].strip()\r
+                if Line.startswith(TAB_SPECIAL_COMMENT):\r
+                    Usage += ' ' + Line[Line.find(TAB_SPECIAL_COMMENT):]\r
+                    continue\r
+                elif Line.startswith(TAB_COMMENT_SPLIT):\r
+                    continue\r
+                elif Line.find(TAB_COMMENT_SPLIT) > 0:\r
+                    Usage += ' ' + Line[Line.find(TAB_COMMENT_SPLIT):]\r
+                    Line = Line[:Line.find(TAB_COMMENT_SPLIT)]\r
+            else:\r
             # skip empty, commented, block commented lines\r
-            Line = CleanString(Content[Index], AllowCppStyleComment=True)\r
+                Line = CleanString(Content[Index], AllowCppStyleComment=True)\r
+                Usage = ''\r
             NextLine = ''\r
             if Index + 1 < len(Content):\r
                 NextLine = CleanString(Content[Index + 1])\r
@@ -525,6 +546,7 @@ class InfParser(MetaFileParser):
             # LineBegin=-1, ColumnBegin=-1, LineEnd=-1, ColumnEnd=-1, Enabled=-1\r
             #\r
             self._ValueList[0] = self._ValueList[0].replace('/', '\\')\r
+            Usage = Usage.strip()\r
             for Arch, Platform in self._Scope:\r
                 self._Store(self._SectionType,\r
                             self._ValueList[0],\r
@@ -538,8 +560,10 @@ class InfParser(MetaFileParser):
                             -1,\r
                             self._LineIndex+1,\r
                             -1,\r
-                            0\r
+                            0,\r
+                            Usage\r
                             )\r
+            Usage = ''\r
         if IsFindBlockComment:\r
             EdkLogger.error("Parser", FORMAT_INVALID, "Open block comments (starting with /*) are expected to end with */", \r
                             File=self.MetaFile)\r
@@ -710,6 +734,7 @@ class DscParser(MetaFileParser):
         TAB_ELSE_IF.upper()                         :   MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSEIF,\r
         TAB_ELSE.upper()                            :   MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE,\r
         TAB_END_IF.upper()                          :   MODEL_META_DATA_CONDITIONAL_STATEMENT_ENDIF,\r
+        TAB_ERROR.upper()                           :   MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR,\r
     }\r
 \r
     # Valid names in define section\r
@@ -1054,7 +1079,7 @@ class DscParser(MetaFileParser):
 \r
     ## Override parent's method since we'll do all macro replacements in parser\r
     def _GetMacros(self):\r
-        Macros = {}\r
+        Macros = dict( [('ARCH','IA32'), ('FAMILY','MSFT'),('TOOL_CHAIN_TAG','VS2008x86'),('TARGET','DEBUG')])\r
         Macros.update(self._FileLocalMacros)\r
         Macros.update(self._GetApplicableSectionMacro())\r
         Macros.update(GlobalData.gEdkGlobal)\r
@@ -1096,6 +1121,7 @@ class DscParser(MetaFileParser):
             MODEL_META_DATA_BUILD_OPTION                    :   self.__ProcessBuildOption,\r
             MODEL_UNKNOWN                                   :   self._Skip,\r
             MODEL_META_DATA_USER_EXTENSION                  :   self._Skip,\r
+            MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR     :   self._Skip,\r
         }\r
         \r
         self._RawTable = self._Table\r
@@ -1131,9 +1157,10 @@ class DscParser(MetaFileParser):
                 # Only catch expression evaluation error here. We need to report\r
                 # the precise number of line on which the error occurred\r
                 #\r
-                EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expression: %s" % str(Excpt),\r
-                                File=self._FileWithError, ExtraData=' '.join(self._ValueList), \r
-                                Line=self._LineIndex+1)\r
+                pass\r
+#                 EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expression: %s" % str(Excpt),\r
+#                                 File=self._FileWithError, ExtraData=' '.join(self._ValueList),\r
+#                                 Line=self._LineIndex+1)\r
             except MacroException, Excpt:\r
                 EdkLogger.error('Parser', FORMAT_INVALID, str(Excpt),\r
                                 File=self._FileWithError, ExtraData=' '.join(self._ValueList), \r
@@ -1788,7 +1815,10 @@ class Fdf(FdfObject):
         # Load Fdf file if filename is not None\r
         #\r
         if Filename != None:\r
-            self.LoadFdfFile(Filename)\r
+            try:\r
+                self.LoadFdfFile(Filename)\r
+            except Exception:\r
+                pass\r
 \r
     #\r
     # Insert a FDF file record into database\r