BaseTools/ECC: Fix some issues of ECC tool
authorHess Chen <hesheng.chen@intel.com>
Tue, 9 Dec 2014 06:41:58 +0000 (06:41 +0000)
committerhchen30 <hchen30@Edk2>
Tue, 9 Dec 2014 06:41:58 +0000 (06:41 +0000)
Add support for the usage which is defined in the above line for a Protocol/Ppi/Guid
Add support for “!ERROR”
Ignore issue of parsing a macro

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hess Chen <hesheng.chen@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16487 6f19259b-4bc3-4df7-8a09-765794883524

BaseTools/Source/Python/Common/DataType.py
BaseTools/Source/Python/CommonDataClass/DataClass.py
BaseTools/Source/Python/Ecc/Check.py
BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py

index 57e5063ff2f1e783b1240657c9aa192d460a91fe..6d66523847479543dae0f0230aade83037d4c21c 100644 (file)
@@ -442,6 +442,7 @@ TAB_ELSE = '!else'
 TAB_IF_DEF = '!ifdef'\r
 TAB_IF_N_DEF = '!ifndef'\r
 TAB_IF_EXIST = '!if exist'\r
+TAB_ERROR = '!ERROR'\r
 \r
 #\r
 # Unknown section\r
index 3f6c3c65a58209c4df448c494f0ce704d21bfe84..3be369a0f472d15cded1d1f4679e42e3acbe219e 100644 (file)
@@ -86,6 +86,7 @@ MODEL_META_DATA_CONDITIONAL_STATEMENT_IF = 5004
 MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE = 5005\r
 MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF = 5006\r
 MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF = 5007\r
+MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR = 5400\r
 MODEL_META_DATA_BUILD_OPTION = 5008\r
 MODEL_META_DATA_COMPONENT = 5009\r
 MODEL_META_DATA_USER_EXTENSION = 5010\r
@@ -164,6 +165,7 @@ MODEL_LIST = [('MODEL_UNKNOWN', MODEL_UNKNOWN),
               ("MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE", MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE),\r
               ("MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF", MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF),\r
               ("MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF", MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF),\r
+              ("MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR", MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR),\r
               ("MODEL_META_DATA_COMPONENT_SOURCE_OVERRIDE_PATH", MODEL_META_DATA_COMPONENT_SOURCE_OVERRIDE_PATH),\r
               ("MODEL_META_DATA_BUILD_OPTION", MODEL_META_DATA_BUILD_OPTION),\r
               ("MODEL_META_DATA_COMPONENT", MODEL_META_DATA_COMPONENT),\r
index cfa96c156e309db0bce09f1aa9278763089cfcca..5bee6dba7cdcd99cac7eb561d636310d4d9da0d4 100644 (file)
@@ -63,7 +63,7 @@ class Check(object):
     def GeneralCheckNonAcsii(self):\r
         if EccGlobalData.gConfig.GeneralCheckNonAcsii == '1' or EccGlobalData.gConfig.GeneralCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking Non-ACSII char in file ...")\r
-            SqlCommand = """select ID, FullPath, ExtName from File"""\r
+            SqlCommand = """select ID, FullPath, ExtName from File where ExtName in ('.dec', '.inf', '.dsc', 'c', 'h')"""\r
             RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)\r
             for Record in RecordSet:\r
                 if Record[2].upper() not in EccGlobalData.gConfig.BinaryExtList:\r
index 1c3e968785adaf55b7352f90eff6a22216f49b10..9f31d4d4de07a7386c2e35c5445467562c621241 100644 (file)
@@ -461,13 +461,14 @@ class InfParser(MetaFileParser):
                                      MODEL_PCD_DYNAMIC_EX,\r
                                      MODEL_PCD_DYNAMIC]:\r
                 Line = Content[Index].strip()\r
-                if Line.startswith(TAB_COMMENT_SPLIT):\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
+                    Usage += ' ' + Line[Line.find(TAB_COMMENT_SPLIT):]\r
                     Line = Line[:Line.find(TAB_COMMENT_SPLIT)]\r
-                else:\r
-                    Usage = ''\r
             else:\r
             # skip empty, commented, block commented lines\r
                 Line = CleanString(Content[Index], AllowCppStyleComment=True)\r
@@ -545,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
@@ -561,6 +563,7 @@ class InfParser(MetaFileParser):
                             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
@@ -731,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
@@ -1117,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
@@ -1152,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
@@ -1809,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